diff --git a/.gitattributes b/.gitattributes index bed0738c7eeb449bca98b5d2f33c89a1ee56349a..b008f3118b47b1a1ac585399769d536dc107b23e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,60 +1,40 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text -*.avro filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ckpt filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.lz4 filter=lfs diff=lfs merge=lfs -text -*.mds filter=lfs diff=lfs merge=lfs -text -*.mlmodel filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.safetensors filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text -# Audio files - uncompressed -*.pcm filter=lfs diff=lfs merge=lfs -text -*.sam filter=lfs diff=lfs merge=lfs -text -*.raw filter=lfs diff=lfs merge=lfs -text -# Audio files - compressed -*.aac filter=lfs diff=lfs merge=lfs -text -*.flac filter=lfs diff=lfs merge=lfs -text -*.mp3 filter=lfs diff=lfs merge=lfs -text -*.ogg filter=lfs diff=lfs merge=lfs -text -*.wav filter=lfs diff=lfs merge=lfs -text -# Image files - uncompressed -*.bmp filter=lfs diff=lfs merge=lfs -text -*.gif filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -*.tiff filter=lfs diff=lfs merge=lfs -text -# Image files - compressed -*.jpg filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.webp filter=lfs diff=lfs merge=lfs -text -# Video files - compressed -*.mp4 filter=lfs diff=lfs merge=lfs -text -*.webm filter=lfs diff=lfs merge=lfs -text +# Xet tracking for binary/large files. +# Run `git xet install` once per clone before any of these take effect. + +# osu! archives and arbitrary content-addressed blobs +*.osz filter=xet diff=xet merge=xet -text +*.bin filter=xet diff=xet merge=xet -text + +# Audio +*.mp3 filter=xet diff=xet merge=xet -text +*.ogg filter=xet diff=xet merge=xet -text +*.wav filter=xet diff=xet merge=xet -text +*.flac filter=xet diff=xet merge=xet -text + +# Images +*.jpg filter=xet diff=xet merge=xet -text +*.jpeg filter=xet diff=xet merge=xet -text +*.png filter=xet diff=xet merge=xet -text +*.gif filter=xet diff=xet merge=xet -text +*.webp filter=xet diff=xet merge=xet -text + +# Video +*.mp4 filter=xet diff=xet merge=xet -text +*.avi filter=xet diff=xet merge=xet -text +*.mkv filter=xet diff=xet merge=xet -text +*.webm filter=xet diff=xet merge=xet -text + +# Parquet tables (use_content_defined_chunking enables Xet dedup at chunk level) +*.parquet filter=xet diff=xet merge=xet -text + +# Force LF and treat as text for source/config files +*.py text eol=lf +*.rs text eol=lf +*.toml text eol=lf +*.md text eol=lf +*.json text eol=lf +*.yaml text eol=lf +*.yml text eol=lf +.gitkeep text eol=lf +.gitignore text eol=lf +.gitattributes text eol=lf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..723f9736c99abc193fe719fee3af1a570862b06e --- /dev/null +++ b/.gitignore @@ -0,0 +1,49 @@ +# Local-only inputs (not part of the dataset) +osu_archives/ +osu-wiki/ + +# Python / uv +# NB: pyproject.toml, uv.lock, and .python-version ARE committed (lockfile + pin). +__pycache__/ +*.pyc +*.pyo +.venv/ +venv/ +.env +*.egg-info/ +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ + +# Rust (workspace target dir + per-crate fallback) +target/ +crates/*/target/ + +# osu_fetcher state DB + run lock (per-machine; not part of the dataset) +.fetcher.state.db +.fetcher.state.db-* +.fetcher.state.db.run.lock +*.run.lock + +# osu_fetcher credentials (real file ignored; .example is committed) +osu_fetcher.toml +!osu_fetcher.toml.example + +# Editors / OS +.idea/ +.vscode/* +!.vscode/settings.json +*.swp +*.swo +.DS_Store +Thumbs.db + +# Local scratch / logs +.scratch/ +*.log + +# Single-writer ingest lock (PID + timestamp; written by python/ingest_osz.py) +.ingest.lock + +# Smoke-test sandboxes +smoke_test_*/ diff --git a/.python-version b/.python-version new file mode 100644 index 0000000000000000000000000000000000000000..24ee5b1be9961e38a503c8e764b7385dbb6ba124 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000000000000000000000000000000000..367fc309bbb1286423cc0ba823d69b90cd3fa439 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3259 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aes" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66bd29a732b644c0431c6140f370d097879203d79b80c94a6747ba0872adaef8" +dependencies = [ + "cipher", + "cpubits", + "cpufeatures 0.3.0", +] + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "async-compression" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79b3f8a79cccc2898f31920fc69f304859b3bd567490f75ebf51ae1c792a9ac" +dependencies = [ + "compression-codecs", + "compression-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +dependencies = [ + "hybrid-array", + "zeroize", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2", +] + +[[package]] +name = "brotli" +version = "8.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "bzip2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" +dependencies = [ + "libbz2-rs-sys", +] + +[[package]] +name = "cc" +version = "1.2.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16d90359e986641506914ba71350897565610e87ce0ad9e6f28569db3dd5c6d" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "cipher" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e34d8227fe1ba289043aeb13792056ff80fd6de1a9f49137a5f499de8e8c78ea" +dependencies = [ + "crypto-common 0.2.1", + "inout", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "cmov" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f88a43d011fc4a6876cb7344703e297c71dda42494fee094d5f7c76bf13f746" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "compression-codecs" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2548391e9c1929c21bf6aa2680af86fe4c1b33e6cea9ac1cfeec0bd11218cf" +dependencies = [ + "brotli", + "compression-core", + "flate2", + "memchr", +] + +[[package]] +name = "compression-core" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" + +[[package]] +name = "condtype" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf0a07a401f374238ab8e2f11a104d2851bf9ce711ec69804834de8af45c7af" + +[[package]] +name = "console" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "unicode-width", + "windows-sys 0.59.0", +] + +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + +[[package]] +name = "constant_time_eq" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" + +[[package]] +name = "cpubits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef0c543070d296ea414df2dd7625d1b24866ce206709d8a4a424f28377f5861" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77727bb15fa921304124b128af125e7e3b968275d1b108b379190264f4423710" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "ctrlc" +version = "3.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0b1fab2ae45819af2d0731d60f2afe17227ebb1a1538a236da84c93e9a60162" +dependencies = [ + "dispatch2", + "nix", + "windows-sys 0.61.2", +] + +[[package]] +name = "ctutils" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e" +dependencies = [ + "cmov", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "deadpool" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0be2b1d1d6ec8d846f05e137292d0b89133caf95ef33695424c09568bdd39b1b" +dependencies = [ + "deadpool-runtime", + "lazy_static", + "num_cpus", + "tokio", +] + +[[package]] +name = "deadpool-runtime" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b" + +[[package]] +name = "deflate64" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac6b926516df9c60bfa16e107b21086399f8285a44ca9711344b9e553c5146e2" + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" +dependencies = [ + "block-buffer 0.12.0", + "const-oid", + "crypto-common 0.2.1", + "ctutils", + "zeroize", +] + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags", + "block2", + "libc", + "objc2", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "divan" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a405457ec78b8fe08b0e32b4a3570ab5dff6dd16eb9e76a5ee0a9d9cbd898933" +dependencies = [ + "cfg-if", + "clap", + "condtype", + "divan-macros", + "libc", + "regex-lite", +] + +[[package]] +name = "divan-macros" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9556bc800956545d6420a640173e5ba7dfa82f38d3ea5a167eb555bc69ac3323" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", + "zlib-rs", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 5.3.0", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "wasip2", + "wasip3", + "wasm-bindgen", +] + +[[package]] +name = "governor" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0746aa765db78b521451ef74221663b57ba595bf83f75d0ce23cc09447c8139f" +dependencies = [ + "cfg-if", + "dashmap", + "futures-sink", + "futures-timer", + "futures-util", + "no-std-compat", + "nonzero_ext", + "parking_lot", + "portable-atomic", + "quanta", + "rand 0.8.6", + "smallvec", + "spinning_top", +] + +[[package]] +name = "h2" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest 0.11.2", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hybrid-array" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d46837a0ed51fe95bd3b05de33cd64a1ee88fc797477ca48446872504507c5" +dependencies = [ + "typenum", +] + +[[package]] +name = "hyper" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "tokio", + "tokio-rustls", + "tower-service", + "webpki-roots", +] + +[[package]] +name = "hyper-util" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + +[[package]] +name = "indicatif" +version = "0.17.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width", + "web-time", +] + +[[package]] +name = "inout" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "iri-string" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" +dependencies = [ + "cfg-if", + "futures-util", + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libbz2-rs-sys" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a6a8c165077efc8f3a971534c50ea6a1a18b329ef4a66e897a7e3a1494565f" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "lzma-rust2" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47bb1e988e6fb779cf720ad431242d3f03167c1b3f2b1aae7f1a94b2495b36ae" +dependencies = [ + "sha2 0.10.9", +] + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "mio" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "nix" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6d0705320c1e6ba1d912b5e37cf18071b6c2e9b7fa8215a1e8a7651966f5d3" +dependencies = [ + "bitflags", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "no-std-compat" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" + +[[package]] +name = "nonzero_ext" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bf9645c8b145698bb0b18a4637dcacbc421ea49bef2317e4fd8065a387cf21" + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-conv" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + +[[package]] +name = "objc2" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "osu_fetcher" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "bytes", + "clap", + "console", + "futures", + "governor", + "hex", + "indicatif", + "nonzero_ext", + "reqwest", + "rusqlite", + "serde", + "serde_json", + "sha2 0.11.0", + "tempfile", + "thiserror", + "tokio", + "tokio-util", + "toml", + "tracing", + "tracing-subscriber", + "url", + "wiremock", + "zip", +] + +[[package]] +name = "osu_indexer" +version = "0.1.0" +dependencies = [ + "anyhow", + "base64", + "clap", + "crc32fast", + "ctrlc", + "hex", + "rayon", + "rosu-map 0.2.1", + "rosu-pp", + "rosu-storyboard", + "serde", + "serde_json", + "sha2 0.11.0", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", + "unicode-normalization", + "zip", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "pbkdf2" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629" +dependencies = [ + "digest 0.11.2", + "hmac", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppmd-rust" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efca4c95a19a79d1c98f791f10aebd5c1363b473244630bb7dbde1dc98455a24" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quanta" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3ab5a9d756f0d97bdc89019bd2e4ea098cf9cde50ee7564dde6b81ccc8f06c7" +dependencies = [ + "crossbeam-utils", + "libc", + "once_cell", + "raw-cpuid", + "wasi", + "web-sys", + "winapi", +] + +[[package]] +name = "quinn" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +dependencies = [ + "bytes", + "cfg_aliases", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2", + "thiserror", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +dependencies = [ + "bytes", + "getrandom 0.3.4", + "lru-slab", + "rand 0.9.4", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.60.2", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "raw-cpuid" +version = "11.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186" +dependencies = [ + "bitflags", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-lite" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973" + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-util", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "webpki-roots", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rosu-map" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907d85647905d8de0b5560a8e2d87b7bf457b4b22cdd8f2025c1ff384435ec25" + +[[package]] +name = "rosu-map" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b92ea634d8b3eaa4d7fba7bd12045dda1a50ce81401c96af0d9c851b0737544" + +[[package]] +name = "rosu-mods" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc58d42f8f2308b4b241de147827af84179d0a318de250495c7c5e47cb701cd9" + +[[package]] +name = "rosu-pp" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "697808a7bff3a12f18f519c7111de1df1846ae5b937561d56117658626cab978" +dependencies = [ + "divan", + "rosu-map 0.2.1", + "rosu-mods", +] + +[[package]] +name = "rosu-storyboard" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c60c524ce7966ed36c573f40244a0646bd8cf7554841f30de7394403f40218" +dependencies = [ + "rosu-map 0.1.2", +] + +[[package]] +name = "rusqlite" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c2c118cb077cca2822033836dfb1b975355dfb784b5e8da48f7b6c5db74e60e" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.2", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.2", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spinning_top" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96d2d1d716fb500937168cc09353ffdc7a012be8475ac7308e1bdf0e3923300" +dependencies = [ + "lock_api", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "terminal_size" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" +dependencies = [ + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "js-sys", + "num-conv", + "powerfmt", + "serde_core", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.52.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67dee974fe86fd92cc45b7a95fdd2f99a36a6d7b0d431a231178d3d670bbcc6" +dependencies = [ + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "futures-util", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "async-compression", + "bitflags", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "iri-string", + "pin-project-lite", + "tokio", + "tokio-util", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typed-path" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e28f89b80c87b8fb0cf04ab448d5dd0dd0ade2f8891bae878de66a75a28600e" + +[[package]] +name = "typenum" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.3+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +dependencies = [ + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f371d383f2fb139252e0bfac3b81b265689bf45b6874af544ffa4c975ac1ebf8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "web-sys" +version = "0.3.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2dfbb17949fa2088e5d39408c48368947b86f7834484e87b73de55bc14d97d" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" + +[[package]] +name = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + +[[package]] +name = "wiremock" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08db1edfb05d9b3c1542e521aea074442088292f00b5f28e435c714a98f85031" +dependencies = [ + "assert-json-diff", + "base64", + "deadpool", + "futures", + "http", + "http-body-util", + "hyper", + "hyper-util", + "log", + "once_cell", + "regex", + "serde", + "serde_json", + "tokio", + "url", +] + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "yoke" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zip" +version = "8.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +dependencies = [ + "aes", + "bzip2", + "constant_time_eq", + "crc32fast", + "deflate64", + "flate2", + "getrandom 0.4.2", + "hmac", + "indexmap", + "lzma-rust2", + "memchr", + "pbkdf2", + "ppmd-rust", + "sha1", + "time", + "typed-path", + "zeroize", + "zopfli", + "zstd", +] + +[[package]] +name = "zlib-rs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be3d40e40a133f9c916ee3f9f4fa2d9d63435b5fbe1bfc6d9dae0aa0ada1513" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" + +[[package]] +name = "zopfli" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249" +dependencies = [ + "bumpalo", + "crc32fast", + "log", + "simd-adler32", +] + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.16+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..c1c2617f2fd6c3d5454314ff5da20c845cbcfca5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,31 @@ +[workspace] +resolver = "2" +members = [ + "crates/osu_indexer", + "crates/osu_fetcher", +] + +[workspace.package] +edition = "2021" +license = "MIT OR Apache-2.0" +publish = false + +[workspace.dependencies] +# Shared across crates. Versions verified on crates.io 2026-04-26. +serde = { version = "1", features = ["derive"] } +serde_json = "1" +clap = { version = "4", features = ["derive"] } +anyhow = "1" +thiserror = "2" +tracing = "0.1" +tracing-subscriber = { version = "0.3", features = ["env-filter"] } +sha2 = "0.11" +hex = "0.4" +zip = "8" +rayon = "1.10" +ctrlc = { version = "3.4", features = ["termination"] } + +[profile.release] +opt-level = 3 +lto = "thin" +codegen-units = 1 diff --git a/README.md b/README.md index c9c3d251e70c3355c0c6a6e089c2b2a4b53004fb..78bc0b9da73a64904444274aadf33e4eccee8cc1 100644 --- a/README.md +++ b/README.md @@ -15,95 +15,6 @@ tags: - beatmaps - storyboards - multimodal -configs: - - config_name: archive_revisions_all - data_files: - - split: all - path: data/v1/all_revisions/archive_revisions/**/*.parquet - - config_name: latest_revisions_all - data_files: - - split: all - path: data/v1/all_revisions/latest_revisions/**/*.parquet - - config_name: set_revisions_all - data_files: - - split: all - path: data/v1/all_revisions/set_revisions/**/*.parquet - - config_name: logical_files_all_revisions - data_files: - - split: all - path: data/v1/all_revisions/logical_files/**/*.parquet - - config_name: beatmaps_latest - data_files: - - split: train - path: data/v1/latest/beatmaps/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/beatmaps/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/beatmaps/p_split=test/**/*.parquet - - config_name: beatmaps_all_revisions - data_files: - - split: all - path: data/v1/all_revisions/beatmaps/**/*.parquet - - config_name: hit_objects_latest - data_files: - - split: train - path: data/v1/latest/hit_objects_common/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/hit_objects_common/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/hit_objects_common/p_split=test/**/*.parquet - - config_name: difficulty_attributes_latest - data_files: - - split: train - path: data/v1/latest/difficulty_attributes/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/difficulty_attributes/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/difficulty_attributes/p_split=test/**/*.parquet - - config_name: storyboard_sources_latest - data_files: - - split: train - path: data/v1/latest/storyboard_sources/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/storyboard_sources/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/storyboard_sources/p_split=test/**/*.parquet - - config_name: storyboard_elements_latest - data_files: - - split: train - path: data/v1/latest/storyboard_elements/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/storyboard_elements/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/storyboard_elements/p_split=test/**/*.parquet - - config_name: storyboard_commands_latest - data_files: - - split: train - path: data/v1/latest/storyboard_commands/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/storyboard_commands/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/storyboard_commands/p_split=test/**/*.parquet - - config_name: storyboard_variables_latest - data_files: - - split: train - path: data/v1/latest/storyboard_variables/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/storyboard_variables/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/storyboard_variables/p_split=test/**/*.parquet - - config_name: references_latest - data_files: - - split: train - path: data/v1/latest/asset_references/p_split=train/**/*.parquet - - split: validation - path: data/v1/latest/asset_references/p_split=validation/**/*.parquet - - split: test - path: data/v1/latest/asset_references/p_split=test/**/*.parquet - - config_name: problems_all - data_files: - - split: all - path: data/v1/all_revisions/problems/**/*.parquet --- # osu-everything @@ -112,10 +23,9 @@ configs: beatmapset archives and parsed metadata. The bucket keeps the original `.osz` archives and compact Parquet metadata. -It does not publish extracted file blobs, per-revision manifests, or the old -global blobs registry. This avoids the previous hundreds-of-thousands of -small files while preserving the raw archive bytes needed for later asset -extraction. +It does not publish extracted member blobs, per-revision manifests, or a global +blob registry. This keeps file counts low while preserving the raw archive +bytes needed for later asset extraction. Canonical bucket: @@ -130,19 +40,17 @@ osu-everything/ ├── archives/sha256/aa/bb/.osz ├── data/v1/ │ ├── all_revisions//part-.parquet -│ └── latest/
/p_split=/part-*.parquet +│ └── latest/
/part-*.parquet ├── schemas/v1/*.schema.json └── state/fetcher/state.db ``` `all_revisions` is the append-only metadata history. Its physical layout is -deliberately compact: each table receives one Parquet file per ingest chunk, -with logical partition columns such as `set_shard`, `ruleset`, `key_count`, -and `split` kept inside the Parquet body. +compact: each table receives one Parquet file per ingest chunk, and compaction +rewrites older fragments into larger `compact-*.parquet` files. -`latest` is a regenerated convenience view. It contains the latest ingested -revision per beatmapset and is physically split only by `p_split=train`, -`p_split=validation`, or `p_split=test`. +`latest` is a regenerated convenience view containing the latest ingested +revision per beatmapset. ## Loading @@ -154,36 +62,35 @@ hf sync \ ./osu-everything/data/v1/latest/beatmaps ``` -Load with Hugging Face Datasets: +Load with PyArrow: ```python -from datasets import load_dataset +import pyarrow.dataset as ds -beatmaps = load_dataset( - "parquet", - data_files="./osu-everything/data/v1/latest/beatmaps/p_split=train/**/*.parquet", - split="train", -) +beatmaps = ds.dataset( + "./osu-everything/data/v1/latest/beatmaps", + format="parquet", +).to_table() ``` -Large object streams should be scoped by table and split: +Large tables should be scoped by prefix: ```bash hf sync \ - hf://buckets/lekdan/osu-everything/data/v1/latest/hit_objects_mania/p_split=train \ - ./osu-everything/data/v1/latest/hit_objects_mania/p_split=train + hf://buckets/lekdan/osu-everything/data/v1/latest/hit_objects_mania \ + ./osu-everything/data/v1/latest/hit_objects_mania ``` -`all_revisions` is useful for historical comparisons and custom splits. It is -not physically split by `split`, so loading a whole all-revisions table reads -that whole table. +`all_revisions` is useful for historical comparisons and custom sampling. It +is organized by table, so loading a whole all-revisions table reads that whole +table. ## Raw Assets Raw audio, images, videos, and `.osu` text are inside the original `.osz` -archives under `archives/`. Metadata rows still carry `blob_sha256`, -`blob_path`, path, role, and reference fields as logical identifiers, but -there is no published extracted blob byte store. +archives under `archives/`. Metadata rows carry `blob_sha256`, archive member +paths, roles, and reference fields as logical identifiers, but there is no +published extracted blob byte store. Consumers that need bytes should open the archive from `archive_revisions.archive_path` and then use `logical_files.path_posix` or @@ -204,47 +111,19 @@ Primary table prefixes: | `data/v1/all_revisions/storyboard_*` | Storyboard sources, elements, commands, variables. | | `data/v1/all_revisions/asset_references` | Resolved and missing asset references. | | `data/v1/all_revisions/difficulty_attributes` | rosu-pp difficulty attributes. | -| `data/v1/latest/
` | Latest-only views for training and quick reads. | +| `data/v1/latest/
` | Latest-only views for quick reads and ML workloads. | See `schemas/v1/` for complete column definitions. -## Splits - -Splits are deterministic per beatmapset key: - -| Hash bucket | Split | -| --- | --- | -| 0-89 | train | -| 90-94 | validation | -| 95-99 | test | - -All revisions of the same beatmapset stay in the same split. The split is -stored in every set-keyed table as the `split` column. - -Training code can import `python/osu_dataset/splits.py` to recompute or -override the split without reading PyArrow: - -```python -from osu_dataset.splits import custom_hash_split, set_key_from_srid - -def experiment_split(set_revision_id: str) -> str: - return custom_hash_split( - set_key_from_srid(set_revision_id), - seed="my-experiment", - train=80, - validation=10, - ) -``` - ## Updating The maintained workflow is documented in `docs/PIPELINE_RUNBOOK.md`. Use `scripts/update_maps_v1.sh` for normal updates. A fresh update worker downloads only `data/`, `schemas/`, and `state/fetcher/`, then fetches and -ingests only new or changed `.osz` files. Upload uses an append-only -`hf buckets sync` for local `archives/` and `--delete` only for regenerated -metadata prefixes such as `data/` and `schemas/`. +ingests only new or changed `.osz` files. Upload uses append-only sync for +local `archives/` and `--delete` only for regenerated metadata prefixes such +as `data/` and `schemas/`. The update wrapper compacts `data/v1/all_revisions/` by default after ingest. It rewrites metadata fragments into fewer `compact-*.parquet` files, then diff --git a/crates/osu_fetcher/Cargo.toml b/crates/osu_fetcher/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..b7398e86257823ff1524c1e8992496081808f22b --- /dev/null +++ b/crates/osu_fetcher/Cargo.toml @@ -0,0 +1,55 @@ +[package] +name = "osu_fetcher" +version = "0.1.0" +edition.workspace = true +license.workspace = true +publish.workspace = true +description = "Discover and download missing osu! beatmapsets via the official osu! API and multiple mirrors." + +[dependencies] +# Async runtime + HTTP +tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "sync", "signal", "time", "io-util"] } +tokio-util = { version = "0.7", features = ["rt"] } +reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json", "gzip", "brotli", "stream"] } +async-trait = "0.1" +futures = "0.3" +bytes = "1" +url = "2" + +# Persistent state +rusqlite = { version = "0.32", features = ["bundled"] } + +# Config file parsing +toml = "0.8" + +# Rate limiting +governor = "0.7" +nonzero_ext = "0.3" + +# Progress reporting (terminal bar + ETA/rate) +indicatif = "0.17" +console = "0.15" + +# Workspace deps +clap.workspace = true +serde.workspace = true +serde_json.workspace = true +anyhow.workspace = true +thiserror.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true +sha2.workspace = true +hex.workspace = true +zip.workspace = true + +[dev-dependencies] +wiremock = "0.6" +tempfile = "3" + +[lib] +name = "osu_fetcher" +path = "src/lib.rs" + +[[bin]] +name = "osu_fetcher" +path = "src/main.rs" diff --git a/crates/osu_fetcher/README.md b/crates/osu_fetcher/README.md new file mode 100644 index 0000000000000000000000000000000000000000..537e80e3c71520bf3a32b100671f732188b9f459 --- /dev/null +++ b/crates/osu_fetcher/README.md @@ -0,0 +1,391 @@ +# osu_fetcher + +Discover and download missing osu! beatmapsets via the official osu! API +plus a fallback chain of public mirrors. Crash-safe, mirror-aware, and +designed to feed the rest of the `osu-everything` pipeline. The standalone +default `--archives-dir` is `osu_archives/`; the maintained dataset update +script overrides it to `incoming_osz/`. + +``` +osu_fetcher enumerate → discover → scan → download → status / verify / retry + (osu! API) (mirrors) (disk) (mirror pool + rate limits) +``` + +## Quick start + +```bash +# 1) Credentials. Copy the template and fill in your OAuth + beatconnect keys: +cp osu_fetcher.toml.example osu_fetcher.toml +${EDITOR:-nano} osu_fetcher.toml + +# 2) Build the release binary (workspace-aware): +cargo build --release -p osu_fetcher + +# 3) Populate the wanted set from the official API: +./target/release/osu_fetcher enumerate \ + --statuses ranked,approved,loved,qualified \ + --mode 0 + +# 4) Optional: mirror-index discovery for sets no longer surfaced by API search: +./target/release/osu_fetcher discover \ + --statuses ranked,approved,loved,qualified \ + --mode 0 \ + --min-quorum 2 + +# 5) Mark everything you already have on disk as success: +./target/release/osu_fetcher scan + +# 6) Download the gap. Idle workers greedily claim the next pending set. +./target/release/osu_fetcher download --concurrency 8 + +# 7) Inspect the queue at any time: +./target/release/osu_fetcher status +``` + +## Configuration + +`osu_fetcher.toml` (gitignored; template at `osu_fetcher.toml.example`): + +```toml +[osu_api] +client_id = "" +client_secret = "" + +[mirrors.beatconnect] +api_key = "" +``` + +Resolution order for every field: env var (e.g. `OSU_CLIENT_ID`) → config +file → error (osu! API id+secret are required) or skip-mirror (beatconnect +is optional). Env vars override the file so CI can inject secrets without +editing the file. + +## Subcommands + +| Command | What it does | +|---|---| +| `enumerate` | Paginates `/api/v2/beatmapsets/search?m={mode}&s={status}&sort=updated_desc` for each requested status, upserts every beatmapset into `sets`. Cursor checkpoints saved per-status after each successful page → can resume mid-run. **Incremental by default**: each run saves a `last_updated` high-water mark and the next run stops paginating once it crosses that mark; pass `--full-rescan` to re-walk everything. | +| `discover` | Walks mirror search/list surfaces for ranked/approved/loved/qualified candidates and promotes sets to `wanted` when at least `--min-quorum` independent mirrors agree. Use after `enumerate` to catch cached sets not surfaced by official API search. | +| `scan` | Walks `--archives-dir`, parses `.osz` filenames, marks each as `success` in the state DB. Optional `--verify` opens each archive and walks its zip entries; corrupt files stay pending. | +| `download` | Runs a bounded greedy worker pool. Each idle worker claims the next `pending wanted` row in `set_id` order and cycles mirrors per-set. See **Failure modes** below for the resilience guarantees. | +| `status` | Prints `wanted / pending / in_progress / success / failed / missing` counts. | +| `verify` | Walks `--archives-dir`, validates every `.osz`. With `--fix`, marks corrupt rows back to pending. | +| `retry` | Resets every `failed` and `missing` row back to `pending` so the next download run will retry. | + +## Global flags + +| Flag | Default | Purpose | +|---|---|---| +| `--config ` | `osu_fetcher.toml` | TOML credentials file. | +| `--state-db ` | `.fetcher.state.db` | SQLite WAL state DB; created on first use. | +| `--archives-dir ` | `osu_archives` | Where downloads land + where scan reads. | +| `--osu-rpm ` | `480` | Official osu! API requests-per-minute. Lower it if auth or API responses start throttling. | +| `--nerinyan-rpm ` | `480` | Per-mirror download RPM. Repeated for `--catboy-rpm`, `--sayobot-rpm`, `--nekoha-rpm`, `--beatconnect-rpm`, `--osudirect-rpm`, `--nzbasic-rpm`, `--osudl-rpm`, and `--osuapi-rpm`. Lower individual mirrors if an operator asks us to back off. | +| `--disable ` | — | Disable a mirror by name. Repeatable. | +| `--no-progress` | off | Disable the live terminal dashboard. Use for CI / quiet logs. | +| `--force-progress` | off | Render the live download dashboard directly to `/dev/tty`, useful when a wrapper script tees logs inside tmux. | +| `--verbose` | off | Re-enable per-set INFO logs; visually interrupts the dashboard while events fly. | + +## Live dashboard + +`download`, `enumerate`, `discover`, and `scan` render live terminal +progress while running. It is auto-disabled when stderr is not a TTY; pass +`--force-progress` to render the download dashboard through `/dev/tty`, or +`--no-progress` to keep it quiet. + +`download` shows a multi-pane view: + +``` +osu_fetcher download · 8 workers · running 4m 12s + + [████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░] 12534/30142 41% · ETA 1h 14m · 4.2 sets/s + ok 12420 failed 87 missing 27 aborted 0 · 4.2 GiB at 8.3 MiB/s · avg 348.5 KiB · 4 in flight + + mirror reqs ok miss 429 err inv ms ok% in + nerinyan 11203 11051 120 12 5 18 412 98.6% 3 + catboy 312 284 0 0 2 6 521 91.0% 1 + sayobot 14 12 0 0 0 2 780 85.7% 0 + nekoha 3 3 0 0 0 0 1024 100.0% 0 + beatconnect 4 4 0 0 0 0 298 100.0% 0 +``` + +Per-mirror columns: `reqs` total HTTP attempts · `ok` successful · `miss` +404s · `429` rate-limit hits · `err` connection / 5xx errors · `inv` +invalid-archive rejections (200 with non-osz body — the deep-verify catch) +· `ms` average request duration · `ok%` success rate · `in` current +in-flight requests against this mirror. + +Per-set INFO logs ("download ok") are demoted to debug while the dashboard +is active so the bar isn't repainted by every line; `--verbose` brings them +back. WARN/ERROR logs (download failures, requeues) still print and will +visibly interrupt the dashboard, which is intentional. + +`enumerate`, `discover`, and `scan` use counter spinners showing pages / +items processed, current cursor, quorum stats, and bad-name / +bad-archive counts as applicable. + +## Architecture + +``` + ┌─────────────────────────────────┐ + │ state DB (SQLite, WAL mode) │ + │ sets · mirror_attempts · meta │ + └─────────────────────────────────┘ + ▲ ▲ + │ │ + ┌─────────┴────┐ ┌─────┴───────┐ + │ enumerate │ │ download │ ← run lock (file) + │ (osu! API) │ │ (workers) │ + └──────────────┘ └─────────────┘ + │ + ▼ + ┌──────────────────────────┐ + │ MirrorPool │ + │ ┌────────────────────┐ │ + │ │ nerinyan (480 rpm) │ │ + │ │ catboy (480 rpm) │ │ + │ │ osudirect(480 rpm) │ │ + │ │ nekoha (480 rpm) │ │ + │ │ nzbasic (480 rpm) │ │ + │ │ sayobot (480 rpm) │ │ + │ │ osudl (480 rpm) │ │ + │ │ osuapi (480 rpm) │ │ + │ │ beatconn.(480 rpm) │ │ + │ └────────────────────┘ │ + │ classify_response → │ + │ deep verify_bytes │ + │ (zip + .osu file) │ + └──────────────────────────┘ + │ + ▼ + atomic_write (.partial → fsync → rename → dir-fsync) + │ + ▼ + osu_archives/.osz +``` + +State machine (per `set_id`): + +``` + pending ──claim──▶ in_progress ──finish_success──▶ success + ▲ │ │ + │ requeue │ ├──finish_failed────────▶ failed + └───────────────────┘ └──finish_missing───────▶ missing + (every mirror returned 404) +``` + +`retry` flips `{failed, missing}` back to `pending`. `requeue_in_progress` +fires at the start of every `download` run (and also on `enumerate`'s +startup as a safety net) to recover orphaned claims from a crashed prior +run. + +## Failure modes + +The download path is built around the assumption that this thing **will** +get killed mid-run — laptop closes, power blips, Ctrl-C, OS drops you while +streaming — and we don't ever want a half-written `.osz`, a state DB that +disagrees with the disk, or a row stuck in a permanent inconsistent state. + +### Ctrl-C / graceful shutdown +- A signal handler flips a `tokio_util::sync::CancellationToken`. +- Each worker checks the token before claiming the next row. +- **Each in-flight worker `select!`s its HTTP future against the token**, so + Ctrl-C aborts even mid-download (a 100 MB video on a slow mirror used to + block shutdown for 30+ s; now it tears down within milliseconds). +- On abort, the worker calls `release_claim(set_id)` so the row goes back + to `pending`. No abandoned `in_progress`. + +### Hard kill / SIGKILL / power off +- `in_progress` rows are stranded — the process didn't release them. +- On the next `download`, **`requeue_in_progress()`** flips every + `in_progress` row back to `pending`. SQLite's WAL mode handles its own + crash recovery for any in-flight transaction. +- `.partial` files left behind by a crashed write are removed by + **`cleanup_orphan_partials()`** at the start of every download run. + `scan` ignores them too (extension filter). + +### Mid-write power loss +- Bytes go to `.osz.partial`, get `flush()` + `sync_all()` (file fsync), + then `rename(.partial, .osz)`. +- After the rename we **`File::open(parent_dir).sync_all()`** to make the + rename's metadata durable. Without this step, some Linux filesystems can + lose the directory entry on power-off while the file's contents survive, + leaving us with bytes nothing references. +- Rename is atomic on the same filesystem, so an interrupt anywhere along + this path leaves either the old state (no `.osz`, just a `.partial`) or + the new (final `.osz`, no `.partial`). Never a half-written `.osz`. + +### Mirror returns 200 with garbage +This is the subtle one. A misconfigured mirror (or one rate-limiting via an +HTML page) can answer `200 OK` with a body that *isn't* a real `.osz`: +- HTML status / login page wrapped in zip-like bytes. +- A truncated archive whose magic byte passes a shallow check. +- A valid zip that happens to contain no `.osu` file (just a stray asset). + +A 4-byte magic check would let all three through. **`classify_response` +runs the full `verify::verify_bytes`** on every successful response — +opens the zip, walks entries, requires at least one `.osu`. On failure it +returns `MirrorError::InvalidArchive`, which the pool treats as a +recoverable error and **advances to the next mirror**. The bad bytes never +touch disk. + +### One mirror down, others up +- 404: pool advances. If *every* mirror 404s, the row is promoted from + `failed` to `missing` (so you can distinguish "transient" from "no mirror + has this anymore"). +- 5xx / network: pool advances. The row counts a regular `failed` and gets + `attempts` incremented. Run `retry` later to reset. +- 429: same as 5xx for outcome — but the per-mirror rate limiter holds the + next call back automatically, so you don't need to babysit it. +- Final failure logs include the full attempted mirror chain, for example + `nerinyan:HttpError,catboy:NotFound,osudirect:Timeout`. + +### Concurrent `osu_fetcher download` processes +Bad scenario: process B starts up while process A is still running. B's +`requeue_in_progress` would flip A's live in-flight claims back to +`pending`, then both processes might claim the same set, racing on the +final `rename` and one of them spuriously marking the row `failed`. + +Defense: an OS-level **exclusive file lock** on `.run.lock`, +acquired via `std::fs::File::try_lock` (Rust 1.89+). Held for the lifetime +of a download run. The kernel releases it on process exit — graceful, +panic, SIGKILL, or power-off — so there are no stale OS locks to clean +up. A second concurrent process bails immediately with a clear error +pointing at the lockfile. + +The zero-byte lockfile path can remain on disk after a clean exit. That file +is not the lock; the OS-held lock is. You should not need to delete it +manually. + +The lock is per-`--state-db` so running two distinct fetcher invocations +against two distinct DBs on the same machine doesn't deadlock. + +### `finish_success` DB write fails +After atomic_write puts the `.osz` on disk, we commit the success row. +If that DB write fails (disk full, locked DB), the worker now returns +**`Failed`** rather than `Success`. The on-disk file is harmless: the next +run sees the row as `in_progress`, requeues to `pending`, re-fetches, and +the new `atomic_write` overwrites the existing file with identical (or +newer) bytes. The state DB is never out of sync with the run statistics. + +### Cursor checkpoint corruption +`enumerate` saves the API's `cursor_string` into `meta` after every +*successful* page. If the API ever returned a malformed cursor, the next +run's `/search` call would error and we'd surface that — no silent data +corruption, no infinite loop. (Hasn't happened yet against the real API.) + +### Body size during stream +Whole-body buffering via `resp.bytes().await`. For typical maps (~5–50 MB) +this is cheap. For unusual large videos (~100+ MB) it's still fine on a +modern host. We never write incomplete bytes — we either get the full body +or an error. The trade-off: peak memory roughly equals +`concurrency * largest_concurrent_body`. With `--concurrency 8` and 100 MB +maps that's ~800 MB at peak — well within ordinary headroom. + +## State DB schema (v1) + +```sql +sets + set_id INTEGER PRIMARY KEY + wanted INTEGER NOT NULL DEFAULT 0 -- 0 or 1 + ranked_status TEXT -- ranked|approved|loved|qualified + artist, title, creator, api_last_updated TEXT + discovered_at INTEGER -- unix epoch + download_status TEXT NOT NULL DEFAULT 'pending' + -- pending|in_progress|success|failed|missing + attempts INTEGER NOT NULL DEFAULT 0 + last_error TEXT + last_mirror, flavor, saved_path, sha256 TEXT + bytes, last_attempt_at, completed_at INTEGER + +mirror_attempts -- append-only audit log + id, set_id, mirror, attempted_at, duration_ms, + http_status, bytes, outcome, error + -- outcome ∈ {success, not_found, http_error, + -- rate_limited, network, invalid_archive} + +meta -- key/value bag + schema_version + enumerate.cursor. + enumerate.high_water. + +mirror_discoveries -- v2 discovery table + set_id, mirror, claimed_status, has_osu_std, + title, artist, creator, last_updated, + first_seen_at, last_seen_at +``` + +WAL mode + `synchronous=NORMAL`. `foreign_keys=ON` so deleting a `sets` row +cascades to its `mirror_attempts`. + +## Mirror-by-mirror notes + +The dataset wants the **complete** archive only (video + storyboard + +skin + hitsounds), so the CLI no longer exposes a `--flavor` flag — +every download requests the unmodified `.osz` from each mirror. The +`Flavor` enum stays in the library so per-mirror URL builders keep their +flavor-aware paths for future use. + +| Mirror | Auth | Notes | +|---|---|---| +| nerinyan.moe | none | Fastest in our smoke tests. | +| catboy.best | none | Operated by osu.direct. Solid backup. | +| osu.direct | none | Documented 120 rpm rate limit. Returns 302 to a signed S3 URL (reqwest follows transparently). | +| nekoha.moe | none | Newer mirror; reasonable fallback. | +| direct.nzbasic.com | none | Same endpoint nzbasic's batch-beatmap-downloader uses (`{set_id}.osz`). Full-archive only, no novideo path. | +| osudl.org | none | Short-link mirror (`/s/{set_id}`). | +| osu! API download | osu! API credentials | Official `/api/v2/beatmapsets/{id}/download` endpoint. Can be disabled with `--disable osuapi`; requires an auth mode that can access downloads. | +| sayobot.cn | none | China-based; slower from Western users but occasionally has rare maps. | +| beatconnect.io | API key (token query param) | Slower; auto-skipped if no key configured. | + +Pool selection is **health-aware**, not priority-ordered: each request's +starting mirror is chosen via smooth weighted round-robin where +`weight = score² × MiB/s` (success rate squared × measured bandwidth). +Mirrors that consistently fail drop to "dormant" status — they get ~2% +probe traffic so we can detect recovery, but otherwise stay out of +rotation. Fallback after a transient failure walks the chain in +descending health order and exhausts every supported mirror before the set +is marked failed or missing. + +To add a mirror: implement the `Mirror` trait in +`src/mirrors/.rs`, add a per-mirror `RateLimited` field on +`MirrorLimiters`, register in `main::build_pool`. The per-mirror unit +tests live next to each impl and just exercise URL generation; HTTP +behavior is exercised via `tests/classify_response.rs`. + +## Tests + +```bash +cargo test -p osu_fetcher +``` + +Coverage: +- Unit tests — state DB migrations + transitions, rate limiter + pacing, config file resolution, mirror URL generators, ZIP validation, + file lock acquire/release. +- Integration tests (`tests/integration.rs`) — full `download::run` + orchestration: success, all-mirrors-404 → missing, 5xx fallback, + in-flight cancellation, requeue across restart, `--limit` cap, deep + verify advancing past invalid archives. +- **7 wiremock tests** (`tests/classify_response.rs`) — `classify_response` + against real HTTP responses: HTML 200, truncated zip, no-osu-files zip, + minimal-real osz, 404, 429. + +## Operational tips + +- **Dataset updates**: prefer `scripts/update_maps_v1.sh` from the repo root. + It seeds success rows from compact Parquet metadata, so update workers do + not need the historical archive tree. +- **Standalone first run**: `enumerate`, optionally `discover`, then `scan` + your existing archive folder to populate the success side, then `download`. + After that, run incremental `enumerate` to pick up new ranks. +- **Long runs**: tail the lockfile path printed by `download begin` to see + the active PID. Ctrl-C is responsive even mid-flight. +- **Disk full**: workers fail individual sets, the run continues. Free + space and run `retry` to drain the failed bucket. +- **Permanently missing maps** (DMCA / mapper deletions on every mirror): + they accumulate in `missing`. Tolerated; not retried by `download` until + you `retry` them explicitly. +- **Rate-limit tuning**: if a mirror op asks you to slow down, lower + `---rpm`. The update wrapper passes `480` rpm by default for every + fetcher target. diff --git a/crates/osu_fetcher/src/api.rs b/crates/osu_fetcher/src/api.rs new file mode 100644 index 0000000000000000000000000000000000000000..e2725ea190915795465a99961d1288e7d488e9b2 --- /dev/null +++ b/crates/osu_fetcher/src/api.rs @@ -0,0 +1,241 @@ +//! High-level osu! API v2 client. +//! +//! `api.rs` used to own auth state directly; that lives in [`crate::auth`] +//! now (it grew enough complexity — refresh tokens, 2FA, persistence, +//! lazer-impersonation password grant — to deserve its own module). What +//! remains here is the thin part: a typed [`OsuApi`] that bundles the +//! shared [`OsuAuth`] handle with a per-process [`RateLimited`] and exposes +//! the search-paginate helper used by `enumerate`. +//! +//! Other modules wanting authenticated /api/v2 access (notably the +//! [`crate::mirrors::osuapi::OsuApiMirror`]) build their own requests +//! against [`OsuApi::client`] / [`OsuApi::current_token`] — sharing one +//! token + one rate limiter across everything keeps the upstream's view +//! consistent regardless of which subcommand or mirror initiated the call. + +use std::sync::Arc; + +use anyhow::{anyhow, bail, Context, Result}; +use reqwest::{header::AUTHORIZATION, StatusCode}; +use serde::Deserialize; + +use crate::auth::OsuAuth; +use crate::ratelimit::RateLimited; +use crate::RankedStatus; + +/// One page of beatmapsets returned by `search`. +/// +/// `cursor_string` is `None` once the server has nothing left to send; that +/// is also our enumeration's stop condition. +#[derive(Clone, Debug, Deserialize)] +pub struct SearchResponse { + #[serde(default)] + pub beatmapsets: Vec, + #[serde(default)] + pub cursor_string: Option, + #[serde(default)] + pub total: Option, +} + +/// Slim subset of the API beatmapset shape — just the fields we persist into +/// `sets`. Everything else is left unparsed; we don't want a schema evolution +/// upstream to break enumeration. +#[derive(Clone, Debug, Deserialize)] +pub struct BeatmapsetEntry { + pub id: u64, + #[serde(default)] + pub artist: Option, + #[serde(default)] + pub title: Option, + #[serde(default)] + pub creator: Option, + #[serde(default)] + pub status: Option, + #[serde(default)] + pub last_updated: Option, + /// Per-difficulty list — used downstream to filter sets that lack any + /// osu! standard difficulty. Optional; older API responses may omit it. + #[serde(default)] + pub beatmaps: Option>, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct BeatmapEntry { + #[serde(default)] + pub mode_int: Option, + #[serde(default)] + pub mode: Option, +} + +const OSU_BASE: &str = "https://osu.ppy.sh"; + +pub struct OsuApi { + auth: Arc, + rl: RateLimited, +} + +impl OsuApi { + pub fn new(auth: Arc, rl: RateLimited) -> Arc { + Arc::new(Self { auth, rl }) + } + + /// Reqwest client used for all osu! API requests. Exposed so other + /// callers (the `osuapi` download mirror) can issue authenticated + /// requests without spinning up a second client; the auth-mode-specific + /// User-Agent (`osu!` for lazer mode, `osu_fetcher/...` otherwise) is + /// already baked in. + pub fn client(&self) -> &reqwest::Client { + self.auth.client() + } + + /// Yield a usable bearer token, minting / refreshing / verifying as + /// needed. Delegated to [`OsuAuth`] — see that module for the full + /// state machine. + pub async fn current_token(&self) -> Result { + self.auth.current_token().await + } + + /// Force the next `current_token` call to mint a fresh token. Use this + /// after a 401 so the retry doesn't hand back the same dead token from + /// cache. + pub async fn invalidate_token(&self) { + self.auth.invalidate().await + } + + /// Pinned `x-api-version` header value. Lazer-equivalent: this is what + /// the lazer client sends on every authenticated /api/v2 request. + pub fn api_version_header(&self) -> &'static str { + self.auth.api_version() + } + + /// Underlying auth handle — exposed for callers that want auth-mode + /// metadata (e.g., logging) without going through the high-level + /// `OsuApi` accessors. + pub fn auth(&self) -> &Arc { + &self.auth + } + + /// One page of `/api/v2/beatmapsets/search`. The caller drives the loop + /// with the returned `cursor_string`. + /// + /// `sort` is an osu! API sort token (e.g. `"updated_desc"`, + /// `"ranked_desc"`). Passing `None` defers to the API default. Pagination + /// is sort-aware — within a single paginated session, every call must use + /// the same sort, otherwise the cursor returns inconsistent rows. + pub async fn search_beatmapsets( + &self, + status: RankedStatus, + mode: u8, + cursor: Option<&str>, + sort: Option<&str>, + ) -> Result { + // Per-call rate limit. A retry on 401 reuses the same slot — the + // upstream's actual concern is request volume, not whether the token + // happened to be stale. + self.rl.acquire().await; + + let token = self.current_token().await?; + let resp = self + .build_search_request(&token, status, mode, cursor, sort) + .send() + .await + .context("GET /api/v2/beatmapsets/search")?; + if resp.status() == StatusCode::UNAUTHORIZED { + // Token may have been invalidated server-side; force-refresh once. + tracing::debug!("/search returned 401, forcing token refresh"); + self.invalidate_token().await; + let token = self.current_token().await?; + let resp = self + .build_search_request(&token, status, mode, cursor, sort) + .send() + .await + .context("GET /api/v2/beatmapsets/search (after token refresh)")?; + if !resp.status().is_success() { + let status = resp.status(); + let body = resp.text().await.unwrap_or_default(); + bail!("search failed after token refresh: {status} {body}"); + } + return resp + .json() + .await + .map_err(|e| anyhow!("decoding search JSON: {e}")); + } + if !resp.status().is_success() { + let status = resp.status(); + let body = resp.text().await.unwrap_or_default(); + bail!("search returned {status}: {body}"); + } + resp.json::() + .await + .map_err(|e| anyhow!("decoding search JSON: {e}")) + } + + fn build_search_request( + &self, + token: &str, + status: RankedStatus, + mode: u8, + cursor: Option<&str>, + sort: Option<&str>, + ) -> reqwest::RequestBuilder { + let mut req = self + .client() + .get(format!("{OSU_BASE}/api/v2/beatmapsets/search")) + .header(AUTHORIZATION, format!("Bearer {token}")) + .header("x-api-version", self.api_version_header()) + .query(&[ + ("m", mode.to_string()), + ("s", status.as_api_str().to_string()), + ]); + if let Some(s) = sort { + req = req.query(&[("sort", s)]); + } + if let Some(c) = cursor { + req = req.query(&[("cursor_string", c)]); + } + req + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn search_response_deserializes_minimal() { + let body = r#"{ + "beatmapsets": [ + {"id": 123, "artist": "a", "title": "t", "creator": "c", + "status": "ranked", "last_updated": "2026-01-01T00:00:00Z"} + ], + "cursor_string": "abc", + "total": 9999 + }"#; + let r: SearchResponse = serde_json::from_str(body).unwrap(); + assert_eq!(r.beatmapsets.len(), 1); + assert_eq!(r.beatmapsets[0].id, 123); + assert_eq!(r.cursor_string.as_deref(), Some("abc")); + } + + #[test] + fn search_response_handles_terminal_page() { + // Last page: server returns null cursor and may omit beatmapsets. + let body = r#"{"beatmapsets": [], "cursor_string": null}"#; + let r: SearchResponse = serde_json::from_str(body).unwrap(); + assert!(r.beatmapsets.is_empty()); + assert!(r.cursor_string.is_none()); + } + + #[test] + fn search_response_tolerates_extra_fields() { + // Schema evolution: the API may add fields. We must not break. + let body = r#"{ + "beatmapsets": [], + "cursor_string": null, + "future_field": {"nested": [1,2,3]}, + "search": {"sort": "ranked_desc"} + }"#; + let r: SearchResponse = serde_json::from_str(body).unwrap(); + assert!(r.cursor_string.is_none()); + } +} diff --git a/crates/osu_fetcher/src/auth.rs b/crates/osu_fetcher/src/auth.rs new file mode 100644 index 0000000000000000000000000000000000000000..effd1dada767207976085f65b6e12f82958dbaf9 --- /dev/null +++ b/crates/osu_fetcher/src/auth.rs @@ -0,0 +1,894 @@ +//! OAuth handshake + token cache for the official osu! API. +//! +//! Two auth modes coexist behind a single [`OsuAuth`] handle: +//! +//! 1. [`OsuAuthMode::ClientCredentials`] — the standard OAuth app flow you +//! register at . Tokens have +//! `public` scope: enough for `/api/v2/beatmapsets/search` (used by +//! `enumerate`), but **not** enough for `/api/v2/beatmapsets/{id}/download` +//! — that endpoint returns 403 for any client_credentials token. +//! +//! 2. [`OsuAuthMode::LazerPassword`] — replicates the public osu!lazer +//! desktop client byte-for-byte. We POST to `/oauth/token` with the +//! well-known hardcoded `client_id=5` and matching secret straight out +//! of `osu/osu.Game/Online/ProductionEndpointConfiguration.cs`, plus +//! `grant_type=password`, `scope=*`, and the user's own osu! login. +//! The response is a *user-scoped* bearer that's authorised to download +//! sets — same token type the real lazer client uses. +//! +//! After a fresh password grant, lazer probes `/api/v2/me` to see whether +//! the account requires session verification (TOTP or email). When it does, +//! lazer pops a UI dialog asking for the 6-digit code; we read the code +//! from stderr/stdin instead. The successful POST to `/api/v2/session/verify` +//! "unlocks" the existing token — no new token is issued. +//! +//! Tokens are persisted as JSON to a sidecar file (default: +//! `.osu_token.json`) so login + 2FA happen once per machine, not +//! once per CLI invocation. On Unix the file is created with mode 0600; +//! Windows uses default ACLs (treat the file as sensitive — it grants full +//! access to the linked osu! account until the refresh chain breaks). +//! +//! Refresh-on-expiry uses lazer's same 30-second pre-expiry margin +//! (`OAuthToken.IsValid` in the lazer source). On a 401 from a sensitive +//! endpoint, callers should `invalidate()` so the next request re-mints. + +use std::path::{Path, PathBuf}; +use std::sync::Arc; +use std::time::Duration; + +use anyhow::{bail, Context, Result}; +use reqwest::{header::AUTHORIZATION, Client}; +use serde::{Deserialize, Serialize}; +use tokio::sync::Mutex; +use tracing::{debug, info, warn}; + +/// Lazer's hardcoded production `client_id`. MIT-licensed and embedded in +/// every released lazer binary, so quoting it here is fine; treating it as +/// secret would be theatre. Source: +/// `osu.Game/Online/ProductionEndpointConfiguration.cs:12`. +pub const LAZER_CLIENT_ID: &str = "5"; +/// Matching `client_secret`. Same source, line 11. +pub const LAZER_CLIENT_SECRET: &str = "FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk"; +/// Scope lazer always requests on `/oauth/token` (`OAuth.cs:210`). +pub const LAZER_SCOPE: &str = "*"; +/// Exact User-Agent lazer sends on every HTTP call (`OsuJsonWebRequest.cs:19`, +/// `OsuWebRequest.cs:19`). Literally the four bytes "osu!". +pub const LAZER_USER_AGENT: &str = "osu!"; +/// `x-api-version` header value. Lazer release builds compute this from +/// the assembly version (`AssemblyVersion.Major*10000 + Minor`, +/// `APIAccess.cs:81`). The exact integer isn't load-bearing — the server +/// supports a wide compat window — so we pin to a stable date so a future +/// schema rev doesn't change response shapes underneath us. +pub const LAZER_API_VERSION: &str = "20240130"; + +const OSU_BASE: &str = "https://osu.ppy.sh"; + +/// Strategy for authenticating against the osu! API. +#[derive(Clone, Debug)] +pub enum OsuAuthMode { + /// Standard OAuth app credentials. `public` scope. Cannot download. + ClientCredentials { + client_id: String, + client_secret: String, + }, + /// Lazer impersonation. Uses the well-known lazer client_id/secret with + /// `grant_type=password` to obtain a user-scoped token that's allowed to + /// hit `/api/v2/beatmapsets/{id}/download`. + LazerPassword { username: String, password: String }, +} + +impl OsuAuthMode { + pub fn label(&self) -> &'static str { + match self { + OsuAuthMode::ClientCredentials { .. } => "client_credentials", + OsuAuthMode::LazerPassword { .. } => "lazer_password", + } + } + + fn is_lazer(&self) -> bool { + matches!(self, OsuAuthMode::LazerPassword { .. }) + } +} + +/// Persisted token state. Same shape lazer caches in +/// `osu.Game/Online/API/OAuthToken.cs` minus the unused `token_type`. +#[derive(Clone, Debug, Serialize, Deserialize)] +struct StoredToken { + access_token: String, + #[serde(default)] + refresh_token: Option, + /// Unix seconds since epoch — the absolute moment the access token + /// expires. Computed at issuance from `expires_in`. + expires_at: i64, + /// Tracks which auth mode minted this token, so we don't accidentally + /// reuse a client_credentials token under lazer mode (it'd 403 on + /// downloads despite looking valid by expiry). + #[serde(default)] + mode_label: Option, + /// True after `/api/v2/session/verify` succeeded (or wasn't needed). + /// A token whose session isn't verified can pass `/me` checks but + /// will still be denied at sensitive endpoints — track this so we + /// don't skip the verify step on a restored-from-disk token. + #[serde(default = "default_true")] + session_verified: bool, +} + +fn default_true() -> bool { + true +} + +impl StoredToken { + /// Same 30-second margin lazer uses (`OAuthToken.cs:28`). + fn is_valid(&self) -> bool { + let now = unix_now(); + !self.access_token.is_empty() && self.expires_at - now > 30 + } +} + +#[derive(Debug, Deserialize)] +struct TokenResponse { + access_token: String, + expires_in: u64, + /// Only present on password / refresh grants. client_credentials + /// tokens never carry one — the `Default` lets us deserialize either. + #[serde(default)] + refresh_token: Option, +} + +#[derive(Debug, Deserialize)] +struct ApiMeMinimal { + /// `null` (or absent) when the session is fully verified. Otherwise + /// `"totp"` or `"mail"` per `APIMe.cs:12`. + #[serde(default)] + session_verification_method: Option, +} + +/// Pluggable adapter for reading the 2FA code. Default behaviour (and what +/// `OsuAuth::new` installs) is an interactive stdin prompt; tests inject a +/// canned reader so they don't block on real I/O. +pub trait VerificationReader: Send + Sync { + fn read_code(&self, method_label: &str) -> Result; +} + +/// Stdin-based reader. Prints to stderr (so the dashboard's stdout stays +/// clean for piping) and reads one line. +pub struct StdinVerificationReader; + +impl VerificationReader for StdinVerificationReader { + fn read_code(&self, method_label: &str) -> Result { + use std::io::{BufRead, Write}; + eprintln!(); + eprintln!("osu! session verification required."); + eprintln!("Check your {method_label} for a 6-digit code from osu! and enter it below."); + eprint!("Code: "); + std::io::stderr().flush().ok(); + let mut buf = String::new(); + std::io::stdin() + .lock() + .read_line(&mut buf) + .context("reading verification code from stdin")?; + let trimmed = buf.trim(); + if trimmed.is_empty() { + bail!("no verification code entered"); + } + Ok(trimmed.to_string()) + } +} + +pub struct OsuAuth { + client: Client, + mode: OsuAuthMode, + token_file: Option, + /// Serializes token mutations so two concurrent `current_token` callers + /// don't both hit `/oauth/token` (matches lazer's + /// `access_token_retrieval_lock` in `OAuth.cs:121`). + token: Mutex>, + verification: Box, + /// Override base URL so tests can point at a wiremock server. + base_url: String, + api_v2_url: String, +} + +impl OsuAuth { + /// Build an auth handle. `token_file` (if `Some`) is used both to + /// restore a previous login on startup and to persist new tokens as + /// they're minted. Pass `None` for a memory-only client (tests, or + /// short-lived runs where you don't want a sidecar file on disk). + pub fn new(mode: OsuAuthMode, token_file: Option) -> Result> { + Self::new_with( + mode, + token_file, + Box::new(StdinVerificationReader), + OSU_BASE.to_string(), + ) + } + + /// Test-friendly constructor: lets the caller swap the verification + /// reader and point the base URL at a mock server. + pub fn new_with( + mode: OsuAuthMode, + token_file: Option, + verification: Box, + base_url: String, + ) -> Result> { + let user_agent = if mode.is_lazer() { + LAZER_USER_AGENT.to_string() + } else { + format!( + "osu_fetcher/{} (+https://github.com/lekdan/osu-everything)", + env!("CARGO_PKG_VERSION") + ) + }; + let client = Client::builder() + .user_agent(user_agent) + .timeout(Duration::from_secs(60)) + .gzip(true) + .brotli(true) + .build() + .context("building reqwest client")?; + let restored = match &token_file { + Some(p) => Self::read_token_file(p, &mode), + None => None, + }; + let api_v2_url = format!("{}/api/v2", base_url.trim_end_matches('/')); + Ok(Arc::new(Self { + client, + mode, + token_file, + token: Mutex::new(restored), + verification, + base_url, + api_v2_url, + })) + } + + pub fn client(&self) -> &Client { + &self.client + } + + pub fn user_agent(&self) -> &'static str { + if self.mode.is_lazer() { + LAZER_USER_AGENT + } else { + "osu_fetcher" + } + } + + pub fn api_version(&self) -> &'static str { + LAZER_API_VERSION + } + + pub fn mode_label(&self) -> &'static str { + self.mode.label() + } + + /// Yield a usable bearer token. Steps: + /// + /// 1. If the cached token is non-expired (≥30s headroom), return it. + /// 2. Else if it has a refresh token, swap it in (one round-trip). + /// 3. Else (or on refresh failure), do a full re-authentication — + /// which for lazer mode includes the `/api/v2/me` probe and an + /// interactive 2FA prompt if the account requires it. + /// + /// Mutex-serialised so concurrent callers don't trigger redundant + /// `/oauth/token` POSTs. + pub async fn current_token(&self) -> Result { + let mut guard = self.token.lock().await; + if let Some(t) = guard.as_ref() { + if t.is_valid() && t.session_verified { + return Ok(t.access_token.clone()); + } + if t.is_valid() && !t.session_verified { + // Token works for /me probes but downloads will 401/403 + // until verify is completed. Run verification now. + let token = t.clone(); + drop(guard); + let verified = self.run_session_verification(token).await?; + let mut guard = self.token.lock().await; + *guard = Some(verified.clone()); + self.persist(&verified).await; + return Ok(verified.access_token); + } + if let Some(rt) = t.refresh_token.clone() { + match self.refresh(&rt).await { + Ok(mut refreshed) => { + // Carry verification state forward — refreshing + // doesn't reset the session (lazer treats refresh + // and password grants identically post-verify). + refreshed.session_verified = t.session_verified; + *guard = Some(refreshed.clone()); + self.persist(&refreshed).await; + return Ok(refreshed.access_token); + } + Err(e) => { + warn!(error = %e, "token refresh failed; re-authenticating"); + } + } + } + } + let fresh = self.full_authenticate().await?; + *guard = Some(fresh.clone()); + self.persist(&fresh).await; + Ok(fresh.access_token) + } + + /// Drop the cached token. Use after a 401: the next `current_token` + /// call will re-mint. The on-disk file is left alone — its + /// refresh_token may still be salvageable on the next attempt. + pub async fn invalidate(&self) { + *self.token.lock().await = None; + } + + async fn full_authenticate(&self) -> Result { + match &self.mode { + OsuAuthMode::ClientCredentials { + client_id, + client_secret, + } => { + let token = self + .token_request(&[ + ("grant_type", "client_credentials"), + ("client_id", client_id), + ("client_secret", client_secret), + ("scope", "public"), + ]) + .await?; + // No verification needed for app-scoped tokens. + Ok(StoredToken { + session_verified: true, + mode_label: Some("client_credentials".into()), + ..token + }) + } + OsuAuthMode::LazerPassword { username, password } => { + info!( + user_agent = LAZER_USER_AGENT, + "performing lazer-impersonation password grant" + ); + let raw = self + .token_request(&[ + ("grant_type", "password"), + ("client_id", LAZER_CLIENT_ID), + ("client_secret", LAZER_CLIENT_SECRET), + ("scope", LAZER_SCOPE), + ("username", username), + ("password", password), + ]) + .await + .context("lazer password grant")?; + let raw = StoredToken { + mode_label: Some("lazer_password".into()), + session_verified: false, + ..raw + }; + self.run_session_verification(raw).await + } + } + } + + async fn refresh(&self, refresh_token: &str) -> Result { + let (id, secret, scope, label) = match &self.mode { + OsuAuthMode::LazerPassword { .. } => ( + LAZER_CLIENT_ID, + LAZER_CLIENT_SECRET, + LAZER_SCOPE, + "lazer_password", + ), + OsuAuthMode::ClientCredentials { + client_id, + client_secret, + } => ( + client_id.as_str(), + client_secret.as_str(), + "public", + "client_credentials", + ), + }; + debug!(mode = label, "refreshing access token"); + let token = self + .token_request(&[ + ("grant_type", "refresh_token"), + ("client_id", id), + ("client_secret", secret), + ("scope", scope), + ("refresh_token", refresh_token), + ]) + .await?; + Ok(StoredToken { + mode_label: Some(label.into()), + session_verified: true, + ..token + }) + } + + async fn token_request(&self, form: &[(&str, &str)]) -> Result { + let issued_at_unix = unix_now(); + let resp = self + .client + .post(format!( + "{}/oauth/token", + self.base_url.trim_end_matches('/') + )) + .form(form) + .send() + .await + .context("POST /oauth/token")?; + let status = resp.status(); + if !status.is_success() { + let body = resp.text().await.unwrap_or_default(); + let snippet: String = body.chars().take(400).collect(); + bail!("/oauth/token returned {status}: {snippet}"); + } + let tr: TokenResponse = resp.json().await.context("decoding /oauth/token JSON")?; + Ok(StoredToken { + access_token: tr.access_token, + refresh_token: tr.refresh_token, + expires_at: issued_at_unix + tr.expires_in as i64, + mode_label: None, + session_verified: false, + }) + } + + /// Probe `/api/v2/me`. If the response carries + /// `session_verification_method`, prompt the user and POST + /// `/api/v2/session/verify` with the code. On success the *same* + /// access token becomes usable at sensitive endpoints — no new token + /// is issued by the server. + async fn run_session_verification(&self, mut token: StoredToken) -> Result { + let me = self.fetch_me(&token.access_token).await?; + let Some(method) = me.session_verification_method.as_deref() else { + token.session_verified = true; + return Ok(token); + }; + let label = match method { + "totp" => "TOTP authenticator app", + "mail" => "email inbox", + other => other, + }; + info!(method = method, "osu! session verification required"); + let code = self.verification.read_code(label)?; + let resp = self + .client + .post(format!("{}/session/verify", self.api_v2_url)) + .header(AUTHORIZATION, format!("Bearer {}", token.access_token)) + .header("x-api-version", LAZER_API_VERSION) + .form(&[("verification_key", code.as_str())]) + .send() + .await + .context("POST /api/v2/session/verify")?; + if resp.status().is_success() { + info!("osu! session verified"); + token.session_verified = true; + return Ok(token); + } + let status = resp.status(); + let body = resp.text().await.unwrap_or_default(); + let snippet: String = body.chars().take(300).collect(); + bail!("session verification failed: {status} {snippet}"); + } + + async fn fetch_me(&self, token: &str) -> Result { + let resp = self + .client + .get(format!("{}/me", self.api_v2_url)) + .header(AUTHORIZATION, format!("Bearer {token}")) + .header("x-api-version", LAZER_API_VERSION) + .send() + .await + .context("GET /api/v2/me")?; + if !resp.status().is_success() { + let status = resp.status(); + let body = resp.text().await.unwrap_or_default(); + let snippet: String = body.chars().take(300).collect(); + bail!("/api/v2/me returned {status}: {snippet}"); + } + resp.json().await.context("decoding /api/v2/me JSON") + } + + async fn persist(&self, token: &StoredToken) { + let Some(path) = self.token_file.as_ref() else { + return; + }; + let payload = match serde_json::to_vec_pretty(token) { + Ok(b) => b, + Err(e) => { + warn!(error = %e, "could not serialize token; skipping persistence"); + return; + } + }; + if let Err(e) = write_secure(path, &payload).await { + warn!( + error = %e, + path = %path.display(), + "could not persist osu! token to disk; in-memory token still works for this run" + ); + } + } + + fn read_token_file(path: &Path, mode: &OsuAuthMode) -> Option { + if !path.exists() { + return None; + } + let raw = match std::fs::read(path) { + Ok(b) => b, + Err(e) => { + warn!(error = %e, path = %path.display(), "could not read token file"); + return None; + } + }; + let token: StoredToken = match serde_json::from_slice(&raw) { + Ok(t) => t, + Err(e) => { + warn!(error = %e, "token file unparseable; ignoring and re-authenticating"); + return None; + } + }; + // Refuse to reuse a token minted under a different auth mode — + // a client_credentials token will fail downloads regardless of + // its expiry, and a lazer token may carry scopes we don't want + // to use under client_credentials mode. + let expected = mode.label(); + let actual = token.mode_label.as_deref().unwrap_or("client_credentials"); + if actual != expected { + info!( + actual, + expected, "ignoring cached token from different auth mode" + ); + return None; + } + Some(token) + } +} + +#[cfg(unix)] +async fn write_secure(path: &Path, data: &[u8]) -> Result<()> { + use std::io::Write; + use std::os::unix::fs::OpenOptionsExt; + if let Some(parent) = path.parent() { + if !parent.as_os_str().is_empty() { + tokio::fs::create_dir_all(parent).await.ok(); + } + } + let mut opts = std::fs::OpenOptions::new(); + opts.write(true).create(true).truncate(true).mode(0o600); + let mut f = opts + .open(path) + .with_context(|| format!("opening token file {} for writing", path.display()))?; + f.write_all(data)?; + Ok(()) +} + +#[cfg(not(unix))] +async fn write_secure(path: &Path, data: &[u8]) -> Result<()> { + if let Some(parent) = path.parent() { + if !parent.as_os_str().is_empty() { + tokio::fs::create_dir_all(parent).await.ok(); + } + } + tokio::fs::write(path, data).await?; + Ok(()) +} + +fn unix_now() -> i64 { + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|d| d.as_secs() as i64) + .unwrap_or(0) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::Arc; + use wiremock::matchers::{body_string_contains, header, method, path}; + use wiremock::{Mock, MockServer, ResponseTemplate}; + + struct CannedReader(String); + impl VerificationReader for CannedReader { + fn read_code(&self, _: &str) -> Result { + Ok(self.0.clone()) + } + } + + struct CountingReader { + code: String, + calls: Arc, + } + impl VerificationReader for CountingReader { + fn read_code(&self, _: &str) -> Result { + self.calls.fetch_add(1, Ordering::Relaxed); + Ok(self.code.clone()) + } + } + + fn lazer_mode() -> OsuAuthMode { + OsuAuthMode::LazerPassword { + username: "lekdan".into(), + password: "hunter2".into(), + } + } + + #[tokio::test] + async fn lazer_password_grant_sends_lazer_creds_and_user_login() { + // Verify the form body contains the literal hardcoded creds + user + // login + scope=*. We check by `body_string_contains` because the + // form encoding order isn't guaranteed; presence is what matters. + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .and(body_string_contains("grant_type=password")) + .and(body_string_contains("client_id=5")) + .and(body_string_contains( + "client_secret=FGc9GAtyHzeQDshWP5Ah7dega8hJACAJpQtw6OXk", + )) + .and(body_string_contains("scope=*")) // WHATWG form-urlencoded leaves `*` literal + .and(body_string_contains("username=lekdan")) + .and(body_string_contains("password=hunter2")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-abc", + "refresh_token": "ref-abc", + "expires_in": 86400, + }))) + .expect(1) + .mount(&server) + .await; + // /api/v2/me with no verification required. + Mock::given(method("GET")) + .and(path("/api/v2/me")) + .and(header(AUTHORIZATION, "Bearer tok-abc")) + .and(header("x-api-version", LAZER_API_VERSION)) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "session_verification_method": null, + }))) + .expect(1) + .mount(&server) + .await; + + let auth = OsuAuth::new_with( + lazer_mode(), + None, + Box::new(CannedReader("000000".into())), + server.uri(), + ) + .unwrap(); + let token = auth.current_token().await.unwrap(); + assert_eq!(token, "tok-abc"); + assert_eq!(auth.user_agent(), LAZER_USER_AGENT); + } + + #[tokio::test] + async fn lazer_password_grant_runs_session_verify_when_required() { + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-needs-verify", + "refresh_token": "ref-x", + "expires_in": 3600, + }))) + .expect(1) + .mount(&server) + .await; + Mock::given(method("GET")) + .and(path("/api/v2/me")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "session_verification_method": "mail", + }))) + .expect(1) + .mount(&server) + .await; + // The verify endpoint must receive the exact form param + // verification_key=. + Mock::given(method("POST")) + .and(path("/api/v2/session/verify")) + .and(body_string_contains("verification_key=123456")) + .and(header(AUTHORIZATION, "Bearer tok-needs-verify")) + .respond_with(ResponseTemplate::new(200)) + .expect(1) + .mount(&server) + .await; + + let calls = Arc::new(AtomicUsize::new(0)); + let reader = CountingReader { + code: "123456".into(), + calls: calls.clone(), + }; + let auth = OsuAuth::new_with(lazer_mode(), None, Box::new(reader), server.uri()).unwrap(); + let token = auth.current_token().await.unwrap(); + assert_eq!(token, "tok-needs-verify"); + assert_eq!(calls.load(Ordering::Relaxed), 1); + } + + #[tokio::test] + async fn current_token_short_circuits_when_cached_valid() { + // Mount only ONE expected /oauth/token hit; calling current_token + // a second time must reuse the cached value, not refetch. + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-once", + "refresh_token": "ref-once", + "expires_in": 86400, + }))) + .expect(1) + .mount(&server) + .await; + Mock::given(method("GET")) + .and(path("/api/v2/me")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "session_verification_method": null, + }))) + .expect(1) + .mount(&server) + .await; + + let auth = OsuAuth::new_with( + lazer_mode(), + None, + Box::new(CannedReader("0".into())), + server.uri(), + ) + .unwrap(); + assert_eq!(auth.current_token().await.unwrap(), "tok-once"); + assert_eq!(auth.current_token().await.unwrap(), "tok-once"); + } + + #[tokio::test] + async fn invalidate_forces_refetch_on_next_call() { + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-A", + "refresh_token": "ref-A", + "expires_in": 86400, + }))) + .up_to_n_times(1) + .mount(&server) + .await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-B", + "refresh_token": "ref-B", + "expires_in": 86400, + }))) + .mount(&server) + .await; + Mock::given(method("GET")) + .and(path("/api/v2/me")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "session_verification_method": null, + }))) + .mount(&server) + .await; + let auth = OsuAuth::new_with( + lazer_mode(), + None, + Box::new(CannedReader("0".into())), + server.uri(), + ) + .unwrap(); + assert_eq!(auth.current_token().await.unwrap(), "tok-A"); + auth.invalidate().await; + assert_eq!(auth.current_token().await.unwrap(), "tok-B"); + } + + #[tokio::test] + async fn client_credentials_mode_uses_app_scope_and_no_user_creds() { + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .and(body_string_contains("grant_type=client_credentials")) + .and(body_string_contains("client_id=12345")) + .and(body_string_contains("scope=public")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-cc", + "expires_in": 86400, + }))) + .expect(1) + .mount(&server) + .await; + let auth = OsuAuth::new_with( + OsuAuthMode::ClientCredentials { + client_id: "12345".into(), + client_secret: "ccsecret".into(), + }, + None, + Box::new(CannedReader("0".into())), + server.uri(), + ) + .unwrap(); + assert_eq!(auth.current_token().await.unwrap(), "tok-cc"); + // client_credentials never triggers /api/v2/me. + assert!(auth.user_agent().starts_with("osu_fetcher")); + } + + #[tokio::test] + async fn token_persists_to_disk_and_reloads() { + let dir = tempfile::tempdir().unwrap(); + let token_path = dir.path().join("osu_token.json"); + let server = MockServer::start().await; + Mock::given(method("POST")) + .and(path("/oauth/token")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-persist", + "refresh_token": "ref-persist", + "expires_in": 86400, + }))) + .expect(1) + .mount(&server) + .await; + Mock::given(method("GET")) + .and(path("/api/v2/me")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "session_verification_method": null, + }))) + .expect(1) + .mount(&server) + .await; + + { + let auth = OsuAuth::new_with( + lazer_mode(), + Some(token_path.clone()), + Box::new(CannedReader("0".into())), + server.uri(), + ) + .unwrap(); + assert_eq!(auth.current_token().await.unwrap(), "tok-persist"); + } + // Second instance must read the file and not hit the wire. + let auth = OsuAuth::new_with( + lazer_mode(), + Some(token_path.clone()), + Box::new(CannedReader("0".into())), + server.uri(), + ) + .unwrap(); + assert_eq!(auth.current_token().await.unwrap(), "tok-persist"); + } + + #[tokio::test] + async fn refresh_grant_carries_session_verified_forward() { + let server = MockServer::start().await; + // Seed an expired-but-refreshable token on disk so the cached path + // fires the refresh branch instead of the full re-auth branch. + let dir = tempfile::tempdir().unwrap(); + let token_path = dir.path().join("osu_token.json"); + let stale = StoredToken { + access_token: "stale".into(), + refresh_token: Some("ref-keep".into()), + expires_at: 0, + mode_label: Some("lazer_password".into()), + session_verified: true, + }; + std::fs::write(&token_path, serde_json::to_vec(&stale).unwrap()).unwrap(); + + Mock::given(method("POST")) + .and(path("/oauth/token")) + .and(body_string_contains("grant_type=refresh_token")) + .and(body_string_contains("refresh_token=ref-keep")) + .respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({ + "access_token": "tok-refreshed", + "refresh_token": "ref-new", + "expires_in": 86400, + }))) + .expect(1) + .mount(&server) + .await; + // No /api/v2/me on a refresh flow — verification carries forward + // from the seeded token. + + let auth = OsuAuth::new_with( + lazer_mode(), + Some(token_path.clone()), + Box::new(CannedReader("0".into())), + server.uri(), + ) + .unwrap(); + assert_eq!(auth.current_token().await.unwrap(), "tok-refreshed"); + } +} diff --git a/crates/osu_fetcher/src/config.rs b/crates/osu_fetcher/src/config.rs new file mode 100644 index 0000000000000000000000000000000000000000..e61df618cec16e1398ac9be5c45799a7f9790857 --- /dev/null +++ b/crates/osu_fetcher/src/config.rs @@ -0,0 +1,231 @@ +//! Config-file loading. +//! +//! Defaults to `/osu_fetcher.toml`. The file is **not** committed +//! (`.gitignore` excludes it); a `osu_fetcher.toml.example` template is +//! committed so a fresh clone can be configured by `cp` + edit. +//! +//! Resolution order for each credential: +//! +//! 1. Environment variable, if set and non-empty (lets CI/CD override +//! without touching the file). +//! 2. Value from the loaded config file. +//! 3. `None` — the caller decides whether the missing value is fatal +//! (osu! API requires both id+secret; beatconnect can be skipped). +//! +//! The TOML schema is conservative: every section is optional, every key is +//! optional, and unknown keys are accepted (we set +//! `serde(default)` everywhere so adding fields later doesn't break older +//! configs). + +use std::path::{Path, PathBuf}; + +use anyhow::{Context, Result}; +use serde::Deserialize; + +/// Filename relative to the working directory (or `--config `). +pub const DEFAULT_CONFIG_FILENAME: &str = "osu_fetcher.toml"; + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Config { + #[serde(default)] + pub osu_api: OsuApiConfig, + #[serde(default)] + pub mirrors: MirrorsConfig, +} + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct OsuApiConfig { + /// Numeric client_id from . + /// Stored as a string in the file (TOML doesn't care; the API accepts + /// either form). Used only by the legacy client_credentials path — + /// when `username` + `password` are also set the lazer-impersonation + /// flow takes precedence and these are ignored. + #[serde(default)] + pub client_id: Option, + + #[serde(default)] + pub client_secret: Option, + + /// osu! account username for the lazer-impersonation password grant. + /// Pair with `password` to upgrade to user-scoped tokens that work for + /// the `/api/v2/beatmapsets/{id}/download` endpoint. Storing your + /// password in TOML is sensitive — prefer the `OSU_USERNAME` / + /// `OSU_PASSWORD` env vars. + #[serde(default)] + pub username: Option, + + #[serde(default)] + pub password: Option, +} + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct MirrorsConfig { + #[serde(default)] + pub beatconnect: BeatconnectConfig, +} + +#[derive(Clone, Debug, Default, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct BeatconnectConfig { + /// API token from . Optional — without + /// it, beatconnect is skipped from the mirror pool. + #[serde(default)] + pub api_key: Option, +} + +impl Config { + /// Load from `path` if it exists; otherwise return an empty config. + /// Missing-file is **not** an error so the binary still works in CI/CD + /// where credentials live in env vars only. + pub fn load_or_empty(path: &Path) -> Result { + if !path.exists() { + return Ok(Self::default()); + } + let raw = std::fs::read_to_string(path) + .with_context(|| format!("reading config file {}", path.display()))?; + let cfg: Self = toml::from_str(&raw) + .with_context(|| format!("parsing config file {}", path.display()))?; + Ok(cfg) + } + + /// Resolve the OAuth credentials by combining env vars (winning) with + /// values from this config file (fallback). Callers decide which auth + /// mode applies (lazer password grant vs client_credentials) based on + /// which fields came back populated. + pub fn osu_credentials(&self) -> ResolvedOsuCreds { + ResolvedOsuCreds { + client_id: env_then_cfg("OSU_CLIENT_ID", self.osu_api.client_id.as_deref()), + client_secret: env_then_cfg("OSU_CLIENT_SECRET", self.osu_api.client_secret.as_deref()), + username: env_then_cfg("OSU_USERNAME", self.osu_api.username.as_deref()), + password: env_then_cfg("OSU_PASSWORD", self.osu_api.password.as_deref()), + } + } + + pub fn beatconnect_api_key(&self) -> Option { + env_then_cfg( + "BEATCONNECT_API_KEY", + self.mirrors.beatconnect.api_key.as_deref(), + ) + } +} + +/// Resolved credentials. Each field is `Some` if either the env var or the +/// config file supplied a non-empty value; `None` otherwise. The caller +/// inspects this struct to pick an auth mode: +/// * `username` + `password` set → lazer password grant +/// * else `client_id` + `client_secret` set → client_credentials +/// * else → no osu! API access (osuapi mirror skipped, enumerate fails) +#[derive(Clone, Debug, Default)] +pub struct ResolvedOsuCreds { + pub client_id: Option, + pub client_secret: Option, + pub username: Option, + pub password: Option, +} + +fn env_then_cfg(env_key: &str, cfg_value: Option<&str>) -> Option { + match std::env::var(env_key) { + Ok(v) if !v.trim().is_empty() => Some(v), + _ => cfg_value + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()), + } +} + +/// Resolve the config-file location with these precedence rules: +/// * `--config ` if the user passed one (returns the path verbatim). +/// * Otherwise, the default name relative to `cwd_or_archive_dir` — +/// in practice the directory the user is running from. +pub fn resolve_config_path(explicit: Option<&Path>) -> PathBuf { + if let Some(p) = explicit { + return p.to_path_buf(); + } + PathBuf::from(DEFAULT_CONFIG_FILENAME) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::io::Write; + use tempfile::NamedTempFile; + + #[test] + fn load_or_empty_returns_default_when_file_missing() { + let p = std::path::Path::new("/definitely/not/here.toml"); + let cfg = Config::load_or_empty(p).unwrap(); + assert!(cfg.osu_api.client_id.is_none()); + assert!(cfg.mirrors.beatconnect.api_key.is_none()); + } + + #[test] + fn full_config_round_trips() { + let mut tmp = NamedTempFile::new().unwrap(); + writeln!( + tmp, + r#" +[osu_api] +client_id = "47060" +client_secret = "secret_value" + +[mirrors.beatconnect] +api_key = "abcdef" +"# + ) + .unwrap(); + let cfg = Config::load_or_empty(tmp.path()).unwrap(); + assert_eq!(cfg.osu_api.client_id.as_deref(), Some("47060")); + assert_eq!(cfg.osu_api.client_secret.as_deref(), Some("secret_value")); + assert_eq!(cfg.mirrors.beatconnect.api_key.as_deref(), Some("abcdef")); + } + + #[test] + fn missing_section_does_not_fail() { + let mut tmp = NamedTempFile::new().unwrap(); + writeln!(tmp, "[osu_api]\nclient_id = \"x\"").unwrap(); + let cfg = Config::load_or_empty(tmp.path()).unwrap(); + assert_eq!(cfg.osu_api.client_id.as_deref(), Some("x")); + assert!(cfg.mirrors.beatconnect.api_key.is_none()); + } + + #[test] + fn unknown_keys_are_rejected() { + let mut tmp = NamedTempFile::new().unwrap(); + writeln!(tmp, "[osu_api]\nclient_id = \"x\"\nbogus = 1").unwrap(); + let err = Config::load_or_empty(tmp.path()).expect_err("expected schema error"); + // toml's "unknown field" message wording varies; just assert it + // surfaced as an error rather than silently dropping the field. + let msg = err.to_string(); + assert!( + msg.contains("config file") || msg.contains("unknown") || msg.contains("bogus"), + "unexpected error: {msg}" + ); + } + + #[test] + fn env_var_wins_over_config() { + // Setting env vars in tests is per-process. Use a unique name so we + // don't trample the real OSU_CLIENT_ID. We test the helper directly + // because that's what `osu_credentials` calls underneath. + std::env::set_var("OSU_FETCHER_TEST_KEY_A", "from_env"); + let resolved = env_then_cfg("OSU_FETCHER_TEST_KEY_A", Some("from_cfg")); + assert_eq!(resolved.as_deref(), Some("from_env")); + std::env::remove_var("OSU_FETCHER_TEST_KEY_A"); + } + + #[test] + fn empty_env_falls_back_to_config() { + std::env::set_var("OSU_FETCHER_TEST_KEY_B", " "); + let resolved = env_then_cfg("OSU_FETCHER_TEST_KEY_B", Some("from_cfg")); + assert_eq!(resolved.as_deref(), Some("from_cfg")); + std::env::remove_var("OSU_FETCHER_TEST_KEY_B"); + } + + #[test] + fn no_env_no_cfg_returns_none() { + std::env::remove_var("OSU_FETCHER_TEST_KEY_C"); + assert!(env_then_cfg("OSU_FETCHER_TEST_KEY_C", None).is_none()); + } +} diff --git a/crates/osu_fetcher/src/discover/mod.rs b/crates/osu_fetcher/src/discover/mod.rs new file mode 100644 index 0000000000000000000000000000000000000000..cfbef1ea046b2f6f5620f2febdb5cf2d027a2558 --- /dev/null +++ b/crates/osu_fetcher/src/discover/mod.rs @@ -0,0 +1,813 @@ +//! Cross-mirror discovery: find ranked / approved / loved / qualified +//! beatmapsets the official osu! API may have dropped but mirrors still know +//! about, then cross-verify by counting independent mirrors that agree. +//! +//! ## Why this exists +//! +//! `enumerate.rs` only walks `osu.ppy.sh/api/v2/beatmapsets/search`. A set that +//! was once ranked but later removed from the API (DMCA, deleted creator, etc.) +//! never appears, even though several mirrors still cache it. Mirrors are +//! *complementary forensic sources*: they remember sets that have rotated off +//! the upstream catalog. +//! +//! Our policy is "trust by quorum": a set absent from the official API is +//! promoted to `wanted` only when *N independent mirrors agree* on its +//! identity (status in our target set + at least one osu! standard +//! difficulty). The default N is 2 — enough that a single mirror's stale +//! cache or buggy parse doesn't pollute the catalog, low enough to actually +//! recover sets the public mirrors keep alive. +//! +//! ## Mirrors used +//! +//! Per the project's mirror docs (April 2026), the *discovery* surface is: +//! +//! | Mirror | Status filter | Paging | Notes | +//! |-------------|---------------|----------------------------|----------------------| +//! | nerinyan | text + numeric| cursor_string + page+limit | rich response | +//! | osu.direct | numeric | offset + amount | `last_checked` field | +//! | sayobot | unreliable | offset + limit | client-side filter | +//! | nekoha | none on list | per-set lookup only | verifier, not lister | +//! | osudl | n/a | HTML only | download-only here | +//! | nzbasic | n/a | none | download-only here | +//! | catboy | down | - | skipped | +//! +//! `download-only` mirrors stay in `crates::mirrors`; they're not part of the +//! discovery loop. + +use std::collections::HashMap; +use std::sync::Arc; +use std::time::Duration; + +use anyhow::{Context, Result}; +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; +use serde::Deserialize; +use thiserror::Error; +use tokio::time::sleep; +use tracing::{debug, info, warn}; + +use crate::progress::CounterSpinner; +use crate::ratelimit::RateLimited; +use crate::state::StateDb; +use crate::RankedStatus; + +pub mod nekoha; +pub mod nerinyan; +pub mod osudirect; +pub mod sayobot; + +/// One beatmapset entry as a mirror reports it. Field names use the *mirror's* +/// claim — the aggregator does its own truth-by-quorum reconciliation. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct DiscoveryEntry { + pub set_id: u64, + pub claimed_status: RankedStatus, + /// True iff the entry has at least one beatmap with `mode_int == 0`. + /// Mirrors with no per-difficulty info should set this to `true` only when + /// the catalog-level mode field includes osu! standard. + pub has_osu_std: bool, + /// The mirror's stored `last_updated` (ISO 8601 or unix sec converted). + pub mirror_last_updated: Option, +} + +/// Opaque pagination token. Each mirror variant carries the bytes it needs +/// for its own pagination scheme; callers don't read it. +#[derive(Clone, Debug)] +pub enum PageCursor { + /// Cursor-based: opaque server token (Nerinyan). + Opaque(String), + /// Offset-based: skip-N integer (osu.direct, Sayobot). + Offset(u64), +} + +/// One page of search results from a mirror. +#[derive(Clone, Debug, Default)] +pub struct SearchPage { + pub entries: Vec, + pub next_cursor: Option, +} + +#[derive(Debug, Error)] +pub enum MirrorSearchError { + #[error("{mirror} returned HTTP {status}: {body_snippet}")] + HttpError { + mirror: String, + status: u16, + body_snippet: String, + }, + + #[error("{mirror} rate limited")] + RateLimited { mirror: String }, + + #[error("{mirror} network error: {source}")] + Network { + mirror: String, + #[source] + source: reqwest::Error, + }, + + #[error("{mirror} response decode failed: {reason}")] + DecodeError { mirror: String, reason: String }, +} + +impl MirrorSearchError { + pub fn mirror(&self) -> &str { + match self { + MirrorSearchError::HttpError { mirror, .. } + | MirrorSearchError::RateLimited { mirror } + | MirrorSearchError::Network { mirror, .. } + | MirrorSearchError::DecodeError { mirror, .. } => mirror, + } + } +} + +/// Async iterator-shaped trait for "list me one page at a time". +/// +/// Mirrors that *can* filter status server-side accept a `Some(status)` and +/// only return matching sets. Mirrors that can't (Sayobot's `R` param is +/// inconsistent) ignore it and rely on the aggregator filtering by +/// `claimed_status`. +#[async_trait] +pub trait MirrorSearch: Send + Sync { + fn name(&self) -> &str; + + /// True if this mirror filters by ranked status server-side. False means + /// the caller will receive all statuses and must drop unwanted ones. + fn supports_status_filter(&self) -> bool; + + /// Fetch one page. `status` is the desired filter (only honored when + /// `supports_status_filter()`); `mode` is the standard mode_int (0 for + /// osu! standard). + async fn search_page( + &self, + status: Option, + mode: u8, + cursor: Option<&PageCursor>, + ) -> Result; +} + +/// Per-set verifier: given a set ID, ask the mirror what it knows. Used to +/// double-check a candidate before promoting it to `wanted`. +#[async_trait] +pub trait MirrorVerify: Send + Sync { + fn name(&self) -> &str; + + /// `Ok(Some(...))` when the mirror has the set, `Ok(None)` when the + /// mirror reports 404 (definitive absence), `Err(...)` for any other + /// failure (transient — retry later). + async fn verify_set(&self, set_id: u64) -> Result, MirrorSearchError>; +} + +/// Knobs for `discover_all`. +#[derive(Clone, Copy, Debug)] +pub struct DiscoverOptions { + pub mode: u8, + /// Hard cap on pages per (mirror, status). `None` = exhaust pagination. + pub max_pages_per_mirror_status: Option, + /// Whether to walk every status on every mirror. Useful to limit reads + /// on first run; default = walk Ranked + Approved + Loved + Qualified. + pub statuses: &'static [RankedStatus], + /// Promote sets to `wanted` once at least this many distinct mirrors have + /// reported them with `has_osu_std = true`. The official API counts as + /// one mirror; if the set is already on the API, it's already wanted. + pub min_quorum: u32, + /// How many consecutive zero-record pages to tolerate before we stop a + /// walk. Sayobot's `T=4` newest-first list eventually grinds into + /// pending/graveyard rows that all filter out — without a fuse we + /// paginate forever. Tuned to 10: at 100 raw rows/page that's 1000 + /// rows in a row with no qualifying matches, well past statistical + /// noise. Set to 0 to disable. + pub consecutive_empty_break_pages: u32, + /// Per-page retry budget for transient errors (RateLimited / Network / + /// 5xx). Each retry waits exponentially: 2s, 4s, 8s. Set to 0 to + /// disable retries entirely (every transient blip becomes a hard + /// failure for the walk). + pub retry_attempts: u32, +} + +impl Default for DiscoverOptions { + fn default() -> Self { + Self { + mode: 0, + max_pages_per_mirror_status: None, + statuses: RankedStatus::all_with_leaderboard(), + min_quorum: 2, + consecutive_empty_break_pages: 10, + retry_attempts: 3, + } + } +} + +#[derive(Clone, Debug, Default)] +pub struct DiscoverStats { + /// Pages fetched, summed across mirrors and statuses. + pub pages: u64, + /// Distinct (mirror, set_id) reports recorded. + pub reports_recorded: u64, + /// Distinct sets reported by at least one mirror. + pub sets_seen: u64, + /// Sets newly promoted from "mirror-only sighting" to `wanted` because + /// the quorum threshold was met. Excludes sets already wanted from the + /// official API run. + pub promoted_to_wanted: u64, + /// Sets the mirror catalog claims exist but the official API doesn't — + /// not yet meeting quorum. Useful to surface to a human reviewer. + pub sub_quorum_candidates: u64, +} + +/// Walk every mirror's discovery surface for every requested status, write +/// each report to `mirror_discoveries`, then aggregate to find sets that +/// meet `opts.min_quorum` independent-mirror agreement. +/// +/// The aggregator does NOT re-check the official API; if the caller wants +/// "sets the API doesn't know about", run `enumerate` first and let +/// `record_discovery` upsert against the existing `sets` table. +/// +/// `progress_enabled` controls the live one-line spinners. It must be `false` +/// in CI / log-redirect / tests; the caller usually computes +/// `!cli.no_progress && progress::stderr_is_terminal()`. When `false`, every +/// status update becomes a no-op and there's no terminal painting at all. +pub async fn discover_all( + state: Arc, + mirrors: &[Arc], + verifiers: &[Arc], + opts: DiscoverOptions, + progress_enabled: bool, +) -> Result { + let mut stats = DiscoverStats::default(); + + for mirror in mirrors { + if mirror.supports_status_filter() { + // Once a mirror's first status walk fails after retries, the + // mirror is in some sticky bad state (rate-banned for the day, + // upstream cache outage, etc.). Skip its remaining statuses + // rather than burn the retry budget on each — the next + // discover run will retry from scratch. + let mut mirror_unhealthy = false; + for &status in opts.statuses { + let label = format!("{} {}", mirror.name(), status.as_api_str()); + let spinner = CounterSpinner::new(&label, progress_enabled); + if mirror_unhealthy { + spinner.finish(String::from("skipped (earlier walk failed)")); + continue; + } + let walk = walk_mirror( + state.clone(), + mirror.as_ref(), + Some(status), + opts, + Some(&spinner), + ) + .await; + if walk.is_err() { + mirror_unhealthy = true; + } + accumulate_walk(&mut stats, &spinner, &label, walk); + } + } else { + // No server-side status filter → one walk covers every status + // the catalog can yield. The aggregator filters by claimed + // status against `opts.statuses` so unwanted ones are dropped + // before they hit `mirror_discoveries`. + let label = format!("{} (all-status)", mirror.name()); + let spinner = CounterSpinner::new(&label, progress_enabled); + let walk = + walk_mirror(state.clone(), mirror.as_ref(), None, opts, Some(&spinner)).await; + accumulate_walk(&mut stats, &spinner, &label, walk); + } + } + + // Verifier pass: for sets seen on exactly `min_quorum - 1` mirrors, + // ping the verifiers. This trades an extra HTTP call for a second + // independent confirmation, often enough to push a 1-mirror sighting + // over the quorum line. Walked here rather than inside the per-mirror + // loop so the verifier set is built from *every* mirror's contribution, + // not just the first. + if !verifiers.is_empty() { + let singleton_ids = state.list_singleton_discoveries(opts.min_quorum)?; + let total = singleton_ids.len(); + debug!(count = total, "running verifier pass on singletons"); + let label = format!("verify ({} candidates)", total); + let spinner = CounterSpinner::new(&label, progress_enabled); + let mut confirmed: u64 = 0; + let mut absent: u64 = 0; + let mut errors: u64 = 0; + for (i, id) in singleton_ids.iter().enumerate() { + for v in verifiers { + match v.verify_set(*id).await { + Ok(Some(entry)) => { + state.record_discovery(v.name(), &entry)?; + stats.reports_recorded += 1; + confirmed += 1; + } + Ok(None) => { + absent += 1; + } + Err(e) => { + errors += 1; + warn!(verifier = v.name(), set_id = id, error = %e, + "verifier transient failure; will retry next run"); + } + } + } + // Repaint every 5 candidates (or on the last one). Per-set + // updates would flicker badly when verifiers reply quickly. + if (i + 1) % 5 == 0 || i + 1 == total { + spinner.set_message(format!( + "{}/{} · confirmed {} · absent {} · errors {}", + i + 1, + total, + confirmed, + absent, + errors + )); + } + } + spinner.finish(format!( + "done · confirmed {} · absent {} · errors {}", + confirmed, absent, errors + )); + } + + // Aggregate + promote — fast (single SQL pass), but worth its own + // spinner so the operator sees the whole pipeline reach completion + // even when the walks dominate wallclock. + let agg_spinner = CounterSpinner::new("aggregate", progress_enabled); + agg_spinner.set_message("computing quorum across discoveries…"); + let agg = state.aggregate_discoveries(opts.min_quorum)?; + stats.sets_seen = agg.distinct_sets; + stats.promoted_to_wanted = state.promote_quorum_to_wanted(opts.min_quorum)?; + stats.sub_quorum_candidates = agg.sub_quorum; + agg_spinner.finish(format!( + "done · sets_seen {} · promoted {} · sub_quorum {}", + stats.sets_seen, stats.promoted_to_wanted, stats.sub_quorum_candidates + )); + + info!( + pages = stats.pages, + reports = stats.reports_recorded, + sets_seen = stats.sets_seen, + promoted = stats.promoted_to_wanted, + sub_quorum = stats.sub_quorum_candidates, + "discover complete" + ); + Ok(stats) +} + +/// Roll one mirror walk's outcome into the aggregate `DiscoverStats` and +/// finish its spinner with a status-aware summary line. A failed walk +/// updates the spinner with the error so a transient mirror outage is +/// visually obvious without burying it in the trace log. +fn accumulate_walk( + stats: &mut DiscoverStats, + spinner: &CounterSpinner, + label: &str, + walk: Result, +) { + match walk { + Ok(p) => { + stats.pages += p.pages; + stats.reports_recorded += p.reports; + spinner.finish(format!( + "done · pages {} · entries {} · recorded {}", + p.pages, p.entries_seen, p.reports + )); + } + Err(e) => { + // Don't `?`-bubble: one mirror's outage shouldn't kill a + // multi-mirror discover run. Surface it on the spinner line + // and continue with the rest. `{e:#}` includes the full + // anyhow chain so the underlying HTTP status / decode + // error is visible (the outermost context alone is just + // `search_page mirror=osudirect status=Some(Ranked)`, + // which is useless for diagnosing a 429 vs 500 vs decode bug). + warn!(mirror_label = label, error = %format!("{e:#}"), + "mirror walk failed; continuing with the rest"); + spinner.finish(format!("FAILED · {e:#}")); + } + } +} + +/// Walk one (mirror, status) pair across pages, persisting each entry as a +/// `mirror_discoveries` row. Returns counters for stats aggregation. +/// +/// `status` is `Some(s)` when the mirror filters server-side (one walk per +/// requested status), `None` for mirrors that can't filter (one walk total, +/// client-side filter against `opts.statuses`). +/// +/// `progress`, when supplied, is updated after every page so the operator +/// sees the walk advance in real time. Updates use raw entry counts (what +/// the mirror returned) and recorded counts (what survived our filters) +/// to make a stuck-but-paginating page chain distinguishable from one +/// that's just turning over inapplicable entries. +async fn walk_mirror( + state: Arc, + mirror: &dyn MirrorSearch, + status: Option, + opts: DiscoverOptions, + progress: Option<&CounterSpinner>, +) -> Result { + let mut walk = MirrorWalkStats::default(); + let mut cursor: Option = None; + let mut consecutive_empty: u32 = 0; + + loop { + let page = fetch_page_with_retry(mirror, status, opts, cursor.as_ref(), progress) + .await + .with_context(|| format!("search_page mirror={} status={:?}", mirror.name(), status))?; + walk.pages += 1; + walk.entries_seen += page.entries.len() as u64; + + let mut recorded_this_page: u64 = 0; + for entry in &page.entries { + // Mirrors with server-side filter return only matches; we + // record what they say. Mirrors without filter (sayobot) hand + // back every status — drop entries outside our target set + // before they pollute `mirror_discoveries`. + let want = status.is_some() || opts.statuses.contains(&entry.claimed_status); + if !want { + continue; + } + if !entry.has_osu_std { + continue; + } + state + .record_discovery(mirror.name(), entry) + .with_context(|| { + format!( + "recording discovery set_id={} mirror={}", + entry.set_id, + mirror.name() + ) + })?; + walk.reports += 1; + recorded_this_page += 1; + } + if recorded_this_page == 0 { + consecutive_empty += 1; + } else { + consecutive_empty = 0; + } + + if let Some(p) = progress { + p.set_message(format!( + "pages {} · entries {} · recorded {} · {}", + walk.pages, + walk.entries_seen, + walk.reports, + cursor_hint(&page.next_cursor), + )); + } + + let cap = opts.max_pages_per_mirror_status.unwrap_or(u32::MAX) as u64; + if walk.pages >= cap { + debug!( + mirror = mirror.name(), + status = ?status, + "stopping at max_pages cap" + ); + break; + } + // Consecutive-empty fuse: a long run of pages where every entry + // got filtered out (status outside our target set, or no osu!std + // difficulty) means we've walked past the useful section of the + // mirror's catalog. Sayobot is the canonical case — `T=4` newest- + // first eventually grinds into pending/graveyard rows that all + // drop. Without this, the walk runs until offset overflow. + if opts.consecutive_empty_break_pages > 0 + && consecutive_empty >= opts.consecutive_empty_break_pages + { + debug!( + mirror = mirror.name(), + status = ?status, + consecutive_empty, + "stopping at consecutive-empty fuse" + ); + if let Some(p) = progress { + p.set_message(format!( + "pages {} · entries {} · recorded {} · fuse: {} empty pages", + walk.pages, walk.entries_seen, walk.reports, consecutive_empty + )); + } + break; + } + cursor = match page.next_cursor { + Some(c) => Some(c), + None => break, + }; + } + Ok(walk) +} + +/// Wrap one `mirror.search_page` call in a retry loop with exponential +/// backoff. Only retries *transient* errors (RateLimited, Network, 5xx +/// HttpError). Permanent-looking errors (4xx other than 429, decode +/// failures) bail immediately so a malformed schema doesn't waste 14 +/// seconds of backoff before erroring out. +/// +/// Backoff schedule for `retry_attempts = 3`: wait 2s → try → wait 4s → +/// try → wait 8s → try → fail. Total worst-case latency: ~14s. Picked to +/// be long enough that a 429 from a strict mirror can settle, but short +/// enough that a hung mirror doesn't drag the whole run. +async fn fetch_page_with_retry( + mirror: &dyn MirrorSearch, + status: Option, + opts: DiscoverOptions, + cursor: Option<&PageCursor>, + progress: Option<&CounterSpinner>, +) -> Result { + let mut attempt: u32 = 0; + loop { + match mirror.search_page(status, opts.mode, cursor).await { + Ok(page) => return Ok(page), + Err(e) => { + if attempt >= opts.retry_attempts || !is_transient(&e) { + return Err(e); + } + let backoff_secs = 1u64 << (attempt + 1); // 2, 4, 8, 16… + if let Some(p) = progress { + p.set_message(format!( + "retry {}/{} in {}s · {e}", + attempt + 1, + opts.retry_attempts, + backoff_secs + )); + } + debug!( + mirror = mirror.name(), + attempt = attempt + 1, + backoff_secs, + error = %e, + "transient mirror error; backing off" + ); + sleep(Duration::from_secs(backoff_secs)).await; + attempt += 1; + } + } + } +} + +/// Classify a `MirrorSearchError` as worth retrying or not. +/// +/// * RateLimited (429): worth retrying — the limiter expects pacing, +/// but a peer-side burst can still spike past it. +/// * Network: transient by definition — DNS hiccup, TCP RST, peer +/// timeout. Retrying is the entire point. +/// * HttpError 5xx: server side; usually clears in a few seconds. +/// * HttpError 4xx (other than 429): malformed request or auth issue; +/// retrying just sends the same broken thing again. +/// * DecodeError: schema drift; retrying won't make the JSON parse. +fn is_transient(e: &MirrorSearchError) -> bool { + match e { + MirrorSearchError::RateLimited { .. } => true, + MirrorSearchError::Network { .. } => true, + MirrorSearchError::HttpError { status, .. } => *status >= 500, + MirrorSearchError::DecodeError { .. } => false, + } +} + +#[derive(Default, Debug)] +struct MirrorWalkStats { + pages: u64, + /// Raw entries returned by the mirror across all pages — useful as a + /// sanity check against `reports` when most of a page is filtered out + /// (e.g., sayobot returning many graveyard sets we don't care about). + entries_seen: u64, + /// Entries we actually recorded into `mirror_discoveries`. + reports: u64, +} + +/// One-line cursor summary for the spinner: `cursor done` once pagination +/// is exhausted, or a short token preview otherwise. Mirrors the +/// human-readable shape `enumerate.rs` uses. +fn cursor_hint(c: &Option) -> String { + match c { + None => "cursor done".into(), + Some(PageCursor::Opaque(s)) => { + if s.len() <= 12 { + format!("cursor {s}") + } else { + format!("cursor …{}", &s[s.len().saturating_sub(8)..]) + } + } + Some(PageCursor::Offset(n)) => format!("offset {n}"), + } +} + +/// Result of aggregating `mirror_discoveries` rows for a given quorum. +#[derive(Clone, Debug, Default)] +pub struct DiscoveryAggregate { + /// Distinct set_ids that appear in `mirror_discoveries`. + pub distinct_sets: u64, + /// Sets short of `min_quorum` mirrors. These are surfaced to the human + /// for manual review but not auto-promoted. + pub sub_quorum: u64, +} + +/// Build a `reqwest::Client` configured for discovery I/O. Identical knobs +/// to `mirrors::build_client` so the same User-Agent surfaces upstream. We +/// keep a separate factory so future tweaks (different timeout, different +/// UA) don't bleed across modules. +pub fn build_client() -> Result { + Client::builder() + .user_agent(crate::mirrors::user_agent()) + .timeout(Duration::from_secs(45)) + .pool_idle_timeout(Duration::from_secs(60)) + .gzip(true) + .brotli(true) + .build() +} + +/// Common helper: take a finished `reqwest::Response` and return its body as +/// JSON-decodable bytes. Centralizes status → MirrorSearchError mapping so +/// every mirror impl handles 404/429/5xx/decode-error consistently. +pub(crate) async fn response_bytes( + mirror: &str, + resp: reqwest::Response, +) -> Result { + let status = resp.status(); + if status.is_success() { + return resp.bytes().await.map_err(|e| MirrorSearchError::Network { + mirror: mirror.into(), + source: e, + }); + } + if status == reqwest::StatusCode::TOO_MANY_REQUESTS { + return Err(MirrorSearchError::RateLimited { + mirror: mirror.into(), + }); + } + let body = resp.text().await.unwrap_or_default(); + Err(MirrorSearchError::HttpError { + mirror: mirror.into(), + status: status.as_u16(), + body_snippet: body.chars().take(200).collect(), + }) +} + +/// Decode JSON into `T`. Wraps `serde_json` errors as +/// `MirrorSearchError::DecodeError` so a schema drift on one mirror doesn't +/// take down the whole `discover_all` run. +pub(crate) fn decode_json Deserialize<'de>>( + mirror: &str, + bytes: &[u8], +) -> Result { + serde_json::from_slice::(bytes).map_err(|e| MirrorSearchError::DecodeError { + mirror: mirror.into(), + reason: e.to_string(), + }) +} + +/// Construction inputs every search impl takes. Avoids the same +/// `(client, rate_limiter)` pair leaking through every constructor signature. +#[derive(Clone)] +pub struct DiscoverContext { + pub client: Client, + pub limiters: DiscoverLimiters, +} + +/// Per-mirror rate-limit handles for the *discovery* path. Kept separate +/// from `MirrorLimiters` because download and search hit different upstream +/// endpoints — a single shared limiter would force search to compete with +/// download for the budget, which we don't want. +#[derive(Clone)] +pub struct DiscoverLimiters { + pub nerinyan: RateLimited, + pub osudirect: RateLimited, + pub sayobot: RateLimited, + pub nekoha: RateLimited, +} + +/// Map status counts back to the fmt-friendly form for logging. +pub fn quorum_summary(rows: &[(u64, u32, RankedStatus)]) -> String { + let mut by_status: HashMap<&'static str, u32> = HashMap::new(); + for (_id, _count, st) in rows { + *by_status.entry(st.as_api_str()).or_default() += 1; + } + let mut parts: Vec<_> = by_status.into_iter().collect(); + parts.sort_by_key(|(k, _)| *k); + parts + .into_iter() + .map(|(k, v)| format!("{k}={v}")) + .collect::>() + .join(" ") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn discover_options_default_walks_all_leaderboard_statuses() { + let opts = DiscoverOptions::default(); + assert_eq!(opts.statuses.len(), 4); + assert!(opts.statuses.contains(&RankedStatus::Ranked)); + assert!(opts.statuses.contains(&RankedStatus::Loved)); + assert!(opts.statuses.contains(&RankedStatus::Qualified)); + assert!(opts.statuses.contains(&RankedStatus::Approved)); + assert_eq!(opts.min_quorum, 2); + } + + #[test] + fn discovery_entry_round_trips_for_known_status() { + // Construction smoke test: the struct should hold values the + // sayobot/osu.direct/nerinyan parsers all hand back. + let e = DiscoveryEntry { + set_id: 12345, + claimed_status: RankedStatus::Loved, + has_osu_std: true, + mirror_last_updated: Some("2026-01-01T00:00:00Z".into()), + }; + assert_eq!(e.set_id, 12345); + assert_eq!(e.claimed_status, RankedStatus::Loved); + assert!(e.has_osu_std); + } + + #[test] + fn cursor_hint_displays_done_when_no_next_cursor() { + assert_eq!(cursor_hint(&None), "cursor done"); + } + + #[test] + fn cursor_hint_truncates_long_opaque_tokens() { + // Nerinyan tokens can be 40+ chars (e.g. `[1776262922000]`-style + // arrays or alphanumeric blobs). The spinner line has a fixed + // width budget; the hint must collapse long tokens to a tail. + let short = cursor_hint(&Some(PageCursor::Opaque("abc".into()))); + assert_eq!(short, "cursor abc"); + let long = cursor_hint(&Some(PageCursor::Opaque( + "abcdefghijklmnopqrstuvwxyz".into(), + ))); + assert!(long.starts_with("cursor …")); + assert!(long.len() < 20); + } + + #[test] + fn is_transient_classifies_known_cases() { + // 429: rate limit — definitely retry-worthy. + assert!(is_transient(&MirrorSearchError::RateLimited { + mirror: "x".into() + })); + // 503: upstream gateway hiccup — retry. + assert!(is_transient(&MirrorSearchError::HttpError { + mirror: "x".into(), + status: 503, + body_snippet: "".into() + })); + // 500: same — retry. + assert!(is_transient(&MirrorSearchError::HttpError { + mirror: "x".into(), + status: 500, + body_snippet: "".into() + })); + // 403: client-side rejection (osu.direct returns this for type + // errors). Don't retry — the request is malformed. + assert!(!is_transient(&MirrorSearchError::HttpError { + mirror: "x".into(), + status: 403, + body_snippet: "".into() + })); + // 404: not found. Don't retry. + assert!(!is_transient(&MirrorSearchError::HttpError { + mirror: "x".into(), + status: 404, + body_snippet: "".into() + })); + // Decode failure: schema drift, retry won't fix the JSON. + assert!(!is_transient(&MirrorSearchError::DecodeError { + mirror: "x".into(), + reason: "bad".into() + })); + } + + #[test] + fn discover_options_default_has_retry_and_fuse() { + let opts = DiscoverOptions::default(); + assert!( + opts.retry_attempts >= 1, + "retries must be enabled by default" + ); + assert!( + opts.consecutive_empty_break_pages >= 1, + "fuse must be enabled by default" + ); + } + + #[test] + fn cursor_hint_renders_offset_as_plain_int() { + assert_eq!(cursor_hint(&Some(PageCursor::Offset(42))), "offset 42"); + } + + #[test] + fn quorum_summary_formats_grouped_counts() { + let rows = vec![ + (1, 2, RankedStatus::Ranked), + (2, 3, RankedStatus::Ranked), + (3, 2, RankedStatus::Loved), + ]; + let s = quorum_summary(&rows); + assert!(s.contains("ranked=2")); + assert!(s.contains("loved=1")); + } +} diff --git a/crates/osu_fetcher/src/discover/nekoha.rs b/crates/osu_fetcher/src/discover/nekoha.rs new file mode 100644 index 0000000000000000000000000000000000000000..2224ccf6a9e6dec4f0a2dfe4440d906d1d689e75 --- /dev/null +++ b/crates/osu_fetcher/src/discover/nekoha.rs @@ -0,0 +1,203 @@ +//! nekoha.moe — per-set verifier. +//! +//! nekoha's `/api4/search` only supports text search (`q`, `page`, +//! `sort`, `order`) — no status filter, no listing-by-status. That makes +//! it useless as a *discovery* source for our use case (we'd have to walk +//! the entire catalog blindly and post-filter, burning a million requests +//! for a small recovery). +//! +//! What it *is* useful for: per-set verification. `GET /api4/beatmapsetFull/:id` +//! returns a beatmapset with a `beatmaps[]` array including `mode_int` and +//! `status`. If we have a candidate set ID with a 1-mirror sighting, asking +//! nekoha is a cheap second opinion that often pushes the candidate over the +//! quorum line. + +use async_trait::async_trait; +use reqwest::Client; +use serde::Deserialize; + +use super::{ + decode_json, response_bytes, DiscoverContext, DiscoveryEntry, MirrorSearchError, MirrorVerify, +}; +use crate::ratelimit::RateLimited; +use crate::RankedStatus; + +pub const NAME: &str = "nekoha"; +const BASE: &str = "https://mirror.nekoha.moe/api4/beatmapsetFull"; + +/// Nekoha encodes integers as JSON strings ("12345" not 12345). The +/// `serde-aux` style fix is to deserialize to a string and parse it; we +/// use a small helper instead so we don't pull a dep in for one field. +#[derive(Clone, Debug, Deserialize)] +struct NekohaSet { + #[serde(default)] + id: serde_json::Value, + #[serde(default)] + status: Option, + #[serde(default)] + last_updated: Option, + #[serde(default)] + beatmaps: Vec, +} + +#[derive(Clone, Debug, Deserialize)] +struct NekohaBeatmap { + #[serde(default)] + mode_int: serde_json::Value, + #[serde(default)] + mode: Option, +} + +pub struct NekohaVerify { + client: Client, + limiter: RateLimited, +} + +impl NekohaVerify { + pub fn new(ctx: &DiscoverContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.nekoha.clone(), + } + } +} + +#[async_trait] +impl MirrorVerify for NekohaVerify { + fn name(&self) -> &str { + NAME + } + + async fn verify_set(&self, set_id: u64) -> Result, MirrorSearchError> { + self.limiter.acquire().await; + let url = format!("{BASE}/{set_id}"); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorSearchError::Network { + mirror: NAME.into(), + source: e, + })?; + if resp.status() == reqwest::StatusCode::NOT_FOUND { + return Ok(None); + } + let bytes = response_bytes(NAME, resp).await?; + let parsed: NekohaSet = decode_json(NAME, &bytes)?; + Ok(parse_entry(set_id, &parsed)) + } +} + +fn parse_entry(set_id: u64, raw: &NekohaSet) -> Option { + let status = match raw.status.as_deref()? { + "ranked" => RankedStatus::Ranked, + "approved" => RankedStatus::Approved, + "loved" => RankedStatus::Loved, + "qualified" => RankedStatus::Qualified, + _ => return None, + }; + // Confirm the response actually corresponds to the requested ID. If + // nekoha ever returns a different set (cache miss, redirect), we want + // to drop the row rather than crosslink unrelated set IDs. + if !id_matches(&raw.id, set_id) { + return None; + } + let has_osu_std = raw.beatmaps.iter().any(|b| { + if let Some(m) = b.mode.as_deref() { + if m == "osu" { + return true; + } + } + json_to_u8(&b.mode_int).map(|m| m == 0).unwrap_or(false) + }); + if !has_osu_std { + return None; + } + Some(DiscoveryEntry { + set_id, + claimed_status: status, + has_osu_std, + mirror_last_updated: raw.last_updated.clone(), + }) +} + +/// Compare the response's `id` (which nekoha may serialize as a JSON string +/// or number) to the requested `set_id`. +fn id_matches(value: &serde_json::Value, expected: u64) -> bool { + match value { + serde_json::Value::Number(n) => n.as_u64().map(|v| v == expected).unwrap_or(false), + serde_json::Value::String(s) => s.parse::().map(|v| v == expected).unwrap_or(false), + _ => false, + } +} + +fn json_to_u8(value: &serde_json::Value) -> Option { + match value { + serde_json::Value::Number(n) => n.as_u64().and_then(|v| u8::try_from(v).ok()), + serde_json::Value::String(s) => s.parse::().ok(), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_response_with_string_ids() { + // nekoha serializes IDs as strings (`"id":"218851"`). The parser + // must still recognize them. + let body = r#"{ + "id":"218851","status":"loved","last_updated":"2026-04-15T16:51:26Z", + "beatmaps":[{"mode_int":"0","mode":"osu"}] + }"#; + let parsed: NekohaSet = serde_json::from_str(body).unwrap(); + let e = parse_entry(218851, &parsed).unwrap(); + assert_eq!(e.set_id, 218851); + assert_eq!(e.claimed_status, RankedStatus::Loved); + assert!(e.has_osu_std); + } + + #[test] + fn parses_response_with_numeric_ids() { + let body = r#"{ + "id":42,"status":"ranked","last_updated":"2026-01-01T00:00:00Z", + "beatmaps":[{"mode_int":0,"mode":"osu"}] + }"#; + let parsed: NekohaSet = serde_json::from_str(body).unwrap(); + let e = parse_entry(42, &parsed).unwrap(); + assert_eq!(e.claimed_status, RankedStatus::Ranked); + } + + #[test] + fn drops_when_response_id_disagrees_with_requested() { + let body = r#"{ + "id":"999","status":"ranked", + "beatmaps":[{"mode_int":"0","mode":"osu"}] + }"#; + let parsed: NekohaSet = serde_json::from_str(body).unwrap(); + // Asked for 42, mirror handed back 999 — must not record. + assert!(parse_entry(42, &parsed).is_none()); + } + + #[test] + fn drops_when_no_osu_difficulty_present() { + let body = r#"{ + "id":"1","status":"ranked", + "beatmaps":[{"mode_int":"1","mode":"taiko"}] + }"#; + let parsed: NekohaSet = serde_json::from_str(body).unwrap(); + assert!(parse_entry(1, &parsed).is_none()); + } + + #[test] + fn drops_unwanted_status_text() { + let body = r#"{ + "id":"1","status":"graveyard", + "beatmaps":[{"mode_int":"0","mode":"osu"}] + }"#; + let parsed: NekohaSet = serde_json::from_str(body).unwrap(); + assert!(parse_entry(1, &parsed).is_none()); + } +} diff --git a/crates/osu_fetcher/src/discover/nerinyan.rs b/crates/osu_fetcher/src/discover/nerinyan.rs new file mode 100644 index 0000000000000000000000000000000000000000..512ee0fbedcb63b23ffa0853abb1015b34f00f97 --- /dev/null +++ b/crates/osu_fetcher/src/discover/nerinyan.rs @@ -0,0 +1,316 @@ +//! Nerinyan v2 search — discovery surface. +//! +//! Endpoint: `GET https://api.nerinyan.moe/v2/search` +//! +//! Why v2 and not v1? v2 is the modern path, advertises a `cursor` object +//! for pagination, and returns the rich `beatmaps[]` array with `mode_int` +//! per difficulty so we can verify osu! standard presence without a follow-up +//! request. v1's flat shape would force us to call `/v1/get_beatmapsets/{id}` +//! once per row to find the mode set — wasteful at our scale. +//! +//! Pagination: the response carries `cursor.cursor_string`. Pass it back as +//! `cursor_string=` on the next request. When the server omits the +//! cursor (or returns an empty `beatmapsets`), pagination is exhausted. +//! +//! Rate limit: response headers expose `RateLimit-Limit: 120` and +//! `RateLimit-Remaining` / `RateLimit-Reset` (seconds). The CLI default is +//! currently 480 rpm for update speed; lower it if this endpoint starts +//! returning 429s. + +use async_trait::async_trait; +use reqwest::Client; +use serde::Deserialize; +use tracing::debug; + +use super::{ + decode_json, response_bytes, DiscoverContext, DiscoveryEntry, MirrorSearch, MirrorSearchError, + PageCursor, SearchPage, +}; +use crate::ratelimit::RateLimited; +use crate::RankedStatus; + +pub const NAME: &str = "nerinyan"; +const BASE: &str = "https://api.nerinyan.moe/v2/search"; +/// Page cap for one HTTP call. The endpoint allows up to 100; we use the +/// full ceiling so we shave round-trips on a multi-thousand-page walk. +const PAGE_LIMIT: u32 = 100; + +#[derive(Clone, Debug, Deserialize)] +struct NerinyanSearchResp { + #[serde(default)] + beatmapsets: Vec, + #[serde(default)] + cursor: Option, +} + +#[derive(Clone, Debug, Deserialize)] +struct NerinyanCursor { + /// Opaque token. Pass back verbatim as the `cursor_string` query param. + /// Some Nerinyan responses use a stringified array (e.g. `"[1776262922000]"`), + /// some use an alphanumeric token; we treat the field as opaque either way. + #[serde(default)] + cursor_string: Option, +} + +#[derive(Clone, Debug, Deserialize)] +struct NerinyanSet { + id: u64, + /// Status as text: `"ranked" | "approved" | "loved" | "qualified" | "graveyard" | ...`. + #[serde(default)] + status: Option, + /// Numeric status: `-2 .. 4`. Used as a fallback if `status` is missing. + #[serde(default)] + ranked: Option, + #[serde(default)] + last_updated: Option, + #[serde(default)] + beatmaps: Option>, +} + +#[derive(Clone, Debug, Deserialize)] +struct NerinyanBeatmap { + #[serde(default)] + mode_int: Option, + #[serde(default)] + mode: Option, +} + +pub struct NerinyanSearch { + client: Client, + limiter: RateLimited, +} + +impl NerinyanSearch { + pub fn new(ctx: &DiscoverContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.nerinyan.clone(), + } + } +} + +#[async_trait] +impl MirrorSearch for NerinyanSearch { + fn name(&self) -> &str { + NAME + } + + fn supports_status_filter(&self) -> bool { + true + } + + async fn search_page( + &self, + status: Option, + mode: u8, + cursor: Option<&PageCursor>, + ) -> Result { + self.limiter.acquire().await; + + let mut req = self.client.get(BASE).query(&[ + ("mode", mode.to_string()), + ("limit", PAGE_LIMIT.to_string()), + ("sort", "ranked_date".to_string()), + ("order", "desc".to_string()), + ]); + if let Some(s) = status { + req = req.query(&[("status", s.as_api_str())]); + } + if let Some(PageCursor::Opaque(c)) = cursor { + req = req.query(&[("cursor_string", c.as_str())]); + } + + let resp = req.send().await.map_err(|e| MirrorSearchError::Network { + mirror: NAME.into(), + source: e, + })?; + let bytes = response_bytes(NAME, resp).await?; + let parsed: NerinyanSearchResp = decode_json(NAME, &bytes)?; + + let mut entries = Vec::with_capacity(parsed.beatmapsets.len()); + for raw in &parsed.beatmapsets { + if let Some(e) = parse_entry(raw, status) { + entries.push(e); + } + } + let next = parsed + .cursor + .and_then(|c| c.cursor_string) + .filter(|s| !s.is_empty()) + .map(PageCursor::Opaque); + debug!( + mirror = NAME, + entries = entries.len(), + cursor_present = next.is_some(), + "nerinyan page parsed" + ); + Ok(SearchPage { + entries, + next_cursor: next, + }) + } +} + +/// Project a raw Nerinyan record into our `DiscoveryEntry`. Drops entries we +/// can't classify (no status, status not in our wanted set) — the aggregator +/// only deals with sets that *could* be promoted. +fn parse_entry(raw: &NerinyanSet, expected: Option) -> Option { + let status = derive_status(raw)?; + // Defense in depth: the request asked for `expected`, but the server + // sometimes returns a slightly different status due to a recent rerank. + // We accept whatever the mirror reports; the aggregator filters again. + let _ = expected; + let has_osu_std = match &raw.beatmaps { + Some(diffs) => diffs.iter().any(|d| { + d.mode_int.map(|m| m == 0).unwrap_or(false) + || d.mode.as_deref().map(|s| s == "osu").unwrap_or(false) + }), + // No per-difficulty info: we can't prove osu! standard, so skip. + // The shape will almost always include `beatmaps`; a missing value + // means an old or partial cache row we don't trust. + None => return None, + }; + if !has_osu_std { + // Taiko / catch / mania-only sets are real beatmapsets but not part + // of the osu! standard dataset. Returning None here keeps the + // `mirror_discoveries` table free of rows that would never meet + // quorum on `has_osu_std = 1`. + return None; + } + Some(DiscoveryEntry { + set_id: raw.id, + claimed_status: status, + has_osu_std, + mirror_last_updated: raw.last_updated.clone(), + }) +} + +/// Convert Nerinyan's status fields to our internal `RankedStatus`. Prefers +/// the text field, falls back to the numeric `ranked`. Returns `None` for +/// statuses we don't track (graveyard / wip / pending — those don't have +/// leaderboards and aren't part of the dataset). +fn derive_status(raw: &NerinyanSet) -> Option { + if let Some(text) = raw.status.as_deref() { + return match text { + "ranked" => Some(RankedStatus::Ranked), + "approved" => Some(RankedStatus::Approved), + "loved" => Some(RankedStatus::Loved), + "qualified" => Some(RankedStatus::Qualified), + _ => None, + }; + } + match raw.ranked { + Some(1) => Some(RankedStatus::Ranked), + Some(2) => Some(RankedStatus::Approved), + Some(3) => Some(RankedStatus::Qualified), + Some(4) => Some(RankedStatus::Loved), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_typical_v2_response() { + let body = r#"{ + "beatmapsets":[ + {"id":2504431,"status":"ranked","ranked":1, + "last_updated":"2026-04-24T08:38:16Z", + "beatmaps":[{"id":1,"mode":"osu","mode_int":0}]}, + {"id":1366006,"status":"loved","ranked":4, + "last_updated":"2026-04-15T16:51:26Z", + "beatmaps":[{"id":2,"mode":"osu","mode_int":0}]} + ], + "cursor":{"approved_date":"...","id":1366006,"cursor_string":"[1776262922000]"}, + "total":1183 + }"#; + let parsed: NerinyanSearchResp = serde_json::from_str(body).unwrap(); + assert_eq!(parsed.beatmapsets.len(), 2); + let e0 = parse_entry(&parsed.beatmapsets[0], None).unwrap(); + assert_eq!(e0.set_id, 2504431); + assert_eq!(e0.claimed_status, RankedStatus::Ranked); + assert!(e0.has_osu_std); + let e1 = parse_entry(&parsed.beatmapsets[1], None).unwrap(); + assert_eq!(e1.claimed_status, RankedStatus::Loved); + assert_eq!( + parsed.cursor.unwrap().cursor_string.unwrap(), + "[1776262922000]" + ); + } + + #[test] + fn drops_sets_without_osu_standard_difficulty() { + let body = r#"{ + "beatmapsets":[ + {"id":1,"status":"ranked","ranked":1, + "beatmaps":[{"mode":"taiko","mode_int":1}]} + ], + "cursor":null + }"#; + let parsed: NerinyanSearchResp = serde_json::from_str(body).unwrap(); + assert!( + parse_entry(&parsed.beatmapsets[0], None).is_none(), + "set with only taiko diffs must be filtered out" + ); + } + + #[test] + fn drops_sets_with_unwanted_status() { + // graveyard and pending are not tracked; we don't want to record + // discoveries for them, otherwise the aggregator would see ghost + // sets every time a mirror returns recent submissions. + let body = r#"{ + "beatmapsets":[ + {"id":1,"status":"graveyard","ranked":-2, + "beatmaps":[{"mode":"osu","mode_int":0}]}, + {"id":2,"status":"pending","ranked":0, + "beatmaps":[{"mode":"osu","mode_int":0}]} + ], + "cursor":null + }"#; + let parsed: NerinyanSearchResp = serde_json::from_str(body).unwrap(); + assert!(parse_entry(&parsed.beatmapsets[0], None).is_none()); + assert!(parse_entry(&parsed.beatmapsets[1], None).is_none()); + } + + #[test] + fn falls_back_to_numeric_status_when_text_missing() { + let body = r#"{ + "beatmapsets":[ + {"id":42,"ranked":4, + "beatmaps":[{"mode_int":0}]} + ], + "cursor":null + }"#; + let parsed: NerinyanSearchResp = serde_json::from_str(body).unwrap(); + let e = parse_entry(&parsed.beatmapsets[0], None).unwrap(); + assert_eq!(e.claimed_status, RankedStatus::Loved); + } + + #[test] + fn no_cursor_in_response_means_pagination_done() { + let body = r#"{"beatmapsets":[],"cursor":null}"#; + let parsed: NerinyanSearchResp = serde_json::from_str(body).unwrap(); + let cur = parsed + .cursor + .and_then(|c| c.cursor_string) + .filter(|s| !s.is_empty()); + assert!(cur.is_none()); + } + + #[test] + fn empty_cursor_string_is_treated_as_done() { + // Some Nerinyan responses include `"cursor":{"cursor_string":""}` + // at the end of pagination. Our walker must treat that as exhausted, + // not loop forever on the empty string. + let body = r#"{"beatmapsets":[],"cursor":{"cursor_string":""}}"#; + let parsed: NerinyanSearchResp = serde_json::from_str(body).unwrap(); + let cur = parsed + .cursor + .and_then(|c| c.cursor_string) + .filter(|s| !s.is_empty()); + assert!(cur.is_none()); + } +} diff --git a/crates/osu_fetcher/src/discover/osudirect.rs b/crates/osu_fetcher/src/discover/osudirect.rs new file mode 100644 index 0000000000000000000000000000000000000000..a1f8bd3dde03be89519a1d90d3297e88de0c9b9e --- /dev/null +++ b/crates/osu_fetcher/src/discover/osudirect.rs @@ -0,0 +1,303 @@ +//! osu.direct v2 search — discovery surface. +//! +//! Endpoint: `GET https://osu.direct/api/v2/search` +//! +//! Live spec (April 2026, confirmed against the running service): +//! * `status` — **numeric**: 1=ranked, 2=approved, 3=qualified, 4=loved +//! (matches osu! API integer mapping). Text values are rejected with +//! `403 status is not a valid number`. +//! * `mode` — **numeric**: 0=osu, 1=taiko, 2=catch, 3=mania. +//! * `amount` — page size (max 100 in practice). +//! * `offset` — skip-N pagination. +//! +//! Response is a bare JSON array (not wrapped in an envelope), each entry a +//! beatmapset with `id`, `status`, `ranked`, `last_updated`, `last_checked` +//! (when osu.direct last verified the set against the official API), and a +//! `beatmaps[]` with `mode_int`. The `last_checked` field is unique among +//! mirrors and lets us reason about staleness — old `last_checked` values +//! mean the mirror's view may be out of date. +//! +//! Rate limit: response carries `RateLimit-Limit: 120` (Cloudflare). The CLI +//! default is currently 480 rpm for update speed; lower it if this endpoint +//! starts returning 429s. + +use async_trait::async_trait; +use reqwest::Client; +use serde::Deserialize; +use tracing::debug; + +use super::{ + decode_json, response_bytes, DiscoverContext, DiscoveryEntry, MirrorSearch, MirrorSearchError, + MirrorVerify, PageCursor, SearchPage, +}; +use crate::ratelimit::RateLimited; +use crate::RankedStatus; + +pub const NAME: &str = "osudirect"; +const SEARCH_BASE: &str = "https://osu.direct/api/v2/search"; +const SET_BASE: &str = "https://osu.direct/api/v2/s"; +const PAGE_AMOUNT: u32 = 100; + +#[derive(Clone, Debug, Deserialize)] +struct OsuDirectSet { + id: u64, + #[serde(default)] + status: Option, + #[serde(default)] + ranked: Option, + #[serde(default)] + last_updated: Option, + #[serde(default)] + beatmaps: Option>, +} + +#[derive(Clone, Debug, Deserialize)] +struct OsuDirectBeatmap { + #[serde(default)] + mode_int: Option, + #[serde(default)] + mode: Option, +} + +pub struct OsuDirectSearch { + client: Client, + limiter: RateLimited, +} + +impl OsuDirectSearch { + pub fn new(ctx: &DiscoverContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.osudirect.clone(), + } + } + + /// Numeric status param expected by `/api/v2/search`. The mirror returns + /// 403 for any non-integer, so we map our enum directly to its osu! API + /// integer. + fn status_int(s: RankedStatus) -> u8 { + match s { + RankedStatus::Ranked => 1, + RankedStatus::Approved => 2, + RankedStatus::Qualified => 3, + RankedStatus::Loved => 4, + } + } +} + +#[async_trait] +impl MirrorSearch for OsuDirectSearch { + fn name(&self) -> &str { + NAME + } + + fn supports_status_filter(&self) -> bool { + true + } + + async fn search_page( + &self, + status: Option, + mode: u8, + cursor: Option<&PageCursor>, + ) -> Result { + self.limiter.acquire().await; + + let offset = match cursor { + Some(PageCursor::Offset(n)) => *n, + Some(PageCursor::Opaque(_)) => 0, // wrong cursor variant; restart + None => 0, + }; + + // osu.direct rejects text statuses with HTTP 403 — always send the + // integer. When `status` is None the mirror returns "all", which is + // fine for callers that don't care. + let status_int = status.map(Self::status_int); + let mut req = self.client.get(SEARCH_BASE).query(&[ + ("mode", mode.to_string()), + ("amount", PAGE_AMOUNT.to_string()), + ("offset", offset.to_string()), + ]); + if let Some(s) = status_int { + req = req.query(&[("status", s.to_string())]); + } + + let resp = req.send().await.map_err(|e| MirrorSearchError::Network { + mirror: NAME.into(), + source: e, + })?; + let bytes = response_bytes(NAME, resp).await?; + let parsed: Vec = decode_json(NAME, &bytes)?; + + let count = parsed.len() as u32; + let entries: Vec<_> = parsed.iter().filter_map(parse_entry).collect(); + + // Offset-based pagination is exhausted when a page returns fewer + // rows than the page size we asked for. Adding one more would just + // return [] and waste a round-trip. + let next_cursor = if count >= PAGE_AMOUNT { + Some(PageCursor::Offset(offset + PAGE_AMOUNT as u64)) + } else { + None + }; + debug!( + mirror = NAME, + offset, + entries = entries.len(), + raw = count, + "osudirect page parsed" + ); + Ok(SearchPage { + entries, + next_cursor, + }) + } +} + +pub struct OsuDirectVerify { + client: Client, + limiter: RateLimited, +} + +impl OsuDirectVerify { + pub fn new(ctx: &DiscoverContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.osudirect.clone(), + } + } +} + +#[async_trait] +impl MirrorVerify for OsuDirectVerify { + fn name(&self) -> &str { + NAME + } + + async fn verify_set(&self, set_id: u64) -> Result, MirrorSearchError> { + self.limiter.acquire().await; + let url = format!("{SET_BASE}/{set_id}"); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorSearchError::Network { + mirror: NAME.into(), + source: e, + })?; + if resp.status() == reqwest::StatusCode::NOT_FOUND { + // Definitive absence — caller treats this as a vote *against*. + return Ok(None); + } + let bytes = response_bytes(NAME, resp).await?; + let parsed: OsuDirectSet = decode_json(NAME, &bytes)?; + Ok(parse_entry(&parsed)) + } +} + +fn parse_entry(raw: &OsuDirectSet) -> Option { + let status = derive_status(raw)?; + let has_osu_std = match &raw.beatmaps { + Some(diffs) => diffs.iter().any(|d| { + d.mode_int.map(|m| m == 0).unwrap_or(false) + || d.mode.as_deref().map(|s| s == "osu").unwrap_or(false) + }), + None => return None, + }; + if !has_osu_std { + return None; + } + Some(DiscoveryEntry { + set_id: raw.id, + claimed_status: status, + has_osu_std, + mirror_last_updated: raw.last_updated.clone(), + }) +} + +fn derive_status(raw: &OsuDirectSet) -> Option { + if let Some(text) = raw.status.as_deref() { + return match text { + "ranked" => Some(RankedStatus::Ranked), + "approved" => Some(RankedStatus::Approved), + "loved" => Some(RankedStatus::Loved), + "qualified" => Some(RankedStatus::Qualified), + _ => None, + }; + } + match raw.ranked { + Some(1) => Some(RankedStatus::Ranked), + Some(2) => Some(RankedStatus::Approved), + Some(3) => Some(RankedStatus::Qualified), + Some(4) => Some(RankedStatus::Loved), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn status_int_matches_osu_api_integers() { + assert_eq!(OsuDirectSearch::status_int(RankedStatus::Ranked), 1); + assert_eq!(OsuDirectSearch::status_int(RankedStatus::Approved), 2); + assert_eq!(OsuDirectSearch::status_int(RankedStatus::Qualified), 3); + assert_eq!(OsuDirectSearch::status_int(RankedStatus::Loved), 4); + } + + #[test] + fn parses_array_response() { + // The endpoint returns a bare array (no envelope). + let body = r#"[ + {"id":2303912,"status":"ranked","ranked":1, + "last_updated":"2026-04-20T08:16:27Z", + "beatmaps":[{"mode":"osu","mode_int":0}]} + ]"#; + let parsed: Vec = serde_json::from_str(body).unwrap(); + let e = parse_entry(&parsed[0]).unwrap(); + assert_eq!(e.set_id, 2303912); + assert_eq!(e.claimed_status, RankedStatus::Ranked); + assert!(e.has_osu_std); + } + + #[test] + fn drops_taiko_only_set() { + let body = r#"[ + {"id":1,"status":"ranked","ranked":1, + "beatmaps":[{"mode":"taiko","mode_int":1}]} + ]"#; + let parsed: Vec = serde_json::from_str(body).unwrap(); + assert!(parse_entry(&parsed[0]).is_none()); + } + + #[test] + fn cursor_advances_by_page_size_until_short_page() { + // Simulate the boundary the search loop would hit. A page of + // PAGE_AMOUNT entries means "ask for the next slice"; a page below + // that means "we've reached the end". + let full = (0..PAGE_AMOUNT).count() as u32; + assert!(full >= PAGE_AMOUNT); + let partial = (0..50).count() as u32; + assert!(partial < PAGE_AMOUNT); + } + + #[test] + fn unknown_status_text_does_not_panic() { + let raw = OsuDirectSet { + id: 1, + status: Some("some-future-status".into()), + ranked: None, + last_updated: None, + beatmaps: Some(vec![OsuDirectBeatmap { + mode_int: Some(0), + mode: None, + }]), + }; + assert!( + parse_entry(&raw).is_none(), + "unknown status text should drop the entry gracefully" + ); + } +} diff --git a/crates/osu_fetcher/src/discover/sayobot.rs b/crates/osu_fetcher/src/discover/sayobot.rs new file mode 100644 index 0000000000000000000000000000000000000000..e83ccdc905275e0df57d226acb24addc12598387 --- /dev/null +++ b/crates/osu_fetcher/src/discover/sayobot.rs @@ -0,0 +1,448 @@ +//! Sayobot beatmaplist — discovery surface. +//! +//! Endpoint: `GET https://api.sayobot.cn/beatmaplist` +//! +//! Live behaviour (April 2026): +//! * `T` — list type. `T=4` is "newest by ranked_date desc" — the most +//! useful for catching recently added ranked/loved sets. +//! * `L` — page limit (max ~100 in practice). +//! * `O` — offset. +//! * `M` — mode bitmask: `1=osu`, `2=taiko`, `4=catch`, `8=mania`, +//! bitwise-OR for combinations. `M=1` returns sets that include osu! +//! standard. +//! * `R` — *advertised* status mask, but probing shows the server returns +//! identical results for `R=1..32`. We treat status filtering as +//! **client-side** and rely on each row's `approved` field. +//! +//! Response: +//! ```json +//! {"data":[{"sid":,"approved":<-2..4>,"modes":, +//! "lastupdate":, ...}], "endid":, "status":0} +//! ``` +//! `endid` is a server-side cursor that we don't fully understand (a small +//! integer like 26, not a row id). We use plain `O=offset` pagination +//! instead — predictable and cursor-format independent. +//! +//! Per-set verifier endpoint: `/v2/beatmapinfo?K=&T=1` returns full +//! difficulty info (incl. mode per beatmap). + +use async_trait::async_trait; +use reqwest::Client; +use serde::Deserialize; +use tracing::debug; + +use super::{ + decode_json, response_bytes, DiscoverContext, DiscoveryEntry, MirrorSearch, MirrorSearchError, + MirrorVerify, PageCursor, SearchPage, +}; +use crate::ratelimit::RateLimited; +use crate::RankedStatus; + +pub const NAME: &str = "sayobot"; +const LIST_BASE: &str = "https://api.sayobot.cn/beatmaplist"; +const INFO_BASE: &str = "https://api.sayobot.cn/v2/beatmapinfo"; +const PAGE_LIMIT: u32 = 100; +/// Mode bit for osu! standard — bit 0. +const MODE_BIT_STD: u32 = 1; + +#[derive(Clone, Debug, Deserialize)] +struct SayobotListResp { + #[serde(default)] + data: Vec, + /// Server-reported error code: `0` is OK, `-1` (and others) indicate + /// the server rejected something (e.g. wrong mode bitmask). We log it + /// and return an empty page rather than raise — Sayobot does this for + /// arguably-valid queries and we don't want a single mirror's quirk to + /// poison `discover_all`. + #[serde(default)] + status: i32, +} + +#[derive(Clone, Debug, Deserialize)] +struct SayobotListEntry { + sid: u64, + /// osu!-API-style approved code: -2=graveyard, -1=wip, 0=pending, + /// 1=ranked, 2=approved, 3=qualified, 4=loved. + approved: i32, + /// Bitmask of modes the set contains. Bit 0 = osu!std. + #[serde(default)] + modes: u32, + /// Unix seconds. Converted to ISO 8601 for storage. + #[serde(default)] + lastupdate: Option, +} + +#[derive(Clone, Debug, Deserialize)] +struct SayobotInfoResp { + #[serde(default)] + data: Option, + #[serde(default)] + status: i32, +} + +#[derive(Clone, Debug, Deserialize)] +struct SayobotInfo { + #[serde(default)] + approved: i32, + #[serde(default)] + last_update: Option, + /// Per-difficulty array; each entry has a `mode` (0..3) integer. + #[serde(default)] + bid_data: Vec, +} + +#[derive(Clone, Debug, Deserialize)] +struct SayobotInfoBid { + #[serde(default)] + mode: u8, +} + +pub struct SayobotSearch { + client: Client, + limiter: RateLimited, +} + +impl SayobotSearch { + pub fn new(ctx: &DiscoverContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.sayobot.clone(), + } + } +} + +#[async_trait] +impl MirrorSearch for SayobotSearch { + fn name(&self) -> &str { + NAME + } + + fn supports_status_filter(&self) -> bool { + // Server-side `R` mask is unreliable on the public endpoint — + // every value we tested returned the same result. We filter by + // `approved` client-side instead. + false + } + + async fn search_page( + &self, + _status: Option, + mode: u8, + cursor: Option<&PageCursor>, + ) -> Result { + self.limiter.acquire().await; + + let offset = match cursor { + Some(PageCursor::Offset(n)) => *n, + Some(PageCursor::Opaque(_)) => 0, + None => 0, + }; + // Build mode bitmask from the integer mode_int. Out-of-range modes + // fall back to "osu! standard included" so we still get a page. + let mode_mask = mode_int_to_bitmask(mode); + + let req = self.client.get(LIST_BASE).query(&[ + ("T", 4u32.to_string()), // newest by ranked_date desc + ("L", PAGE_LIMIT.to_string()), + ("O", offset.to_string()), + ("M", mode_mask.to_string()), + ]); + let resp = req.send().await.map_err(|e| MirrorSearchError::Network { + mirror: NAME.into(), + source: e, + })?; + let bytes = response_bytes(NAME, resp).await?; + let parsed: SayobotListResp = decode_json(NAME, &bytes)?; + + if parsed.status != 0 { + // Server rejected the query. Don't panic: log and return empty + // so the higher-level walk treats it as exhausted for this + // status. The aggregator will rely on the other mirrors. + debug!( + mirror = NAME, + server_status = parsed.status, + "sayobot returned non-zero status; treating as empty page" + ); + return Ok(SearchPage::default()); + } + + let raw_count = parsed.data.len() as u32; + let entries: Vec<_> = parsed.data.iter().filter_map(parse_entry).collect(); + + let next_cursor = if raw_count >= PAGE_LIMIT { + Some(PageCursor::Offset(offset + PAGE_LIMIT as u64)) + } else { + None + }; + debug!( + mirror = NAME, + offset, + raw = raw_count, + entries = entries.len(), + "sayobot page parsed" + ); + Ok(SearchPage { + entries, + next_cursor, + }) + } +} + +pub struct SayobotVerify { + client: Client, + limiter: RateLimited, +} + +impl SayobotVerify { + pub fn new(ctx: &DiscoverContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.sayobot.clone(), + } + } +} + +#[async_trait] +impl MirrorVerify for SayobotVerify { + fn name(&self) -> &str { + NAME + } + + async fn verify_set(&self, set_id: u64) -> Result, MirrorSearchError> { + self.limiter.acquire().await; + let req = self + .client + .get(INFO_BASE) + .query(&[("K", set_id.to_string()), ("T", 1u32.to_string())]); + let resp = req.send().await.map_err(|e| MirrorSearchError::Network { + mirror: NAME.into(), + source: e, + })?; + let bytes = response_bytes(NAME, resp).await?; + let parsed: SayobotInfoResp = decode_json(NAME, &bytes)?; + + if parsed.status != 0 { + // Sayobot reports `-1` for non-existent sets (no separate 404). + return Ok(None); + } + let info = match parsed.data { + Some(d) => d, + None => return Ok(None), + }; + let status = match info.approved { + 1 => RankedStatus::Ranked, + 2 => RankedStatus::Approved, + 3 => RankedStatus::Qualified, + 4 => RankedStatus::Loved, + _ => return Ok(None), + }; + let has_osu_std = info.bid_data.iter().any(|b| b.mode == 0); + if !has_osu_std { + return Ok(None); + } + Ok(Some(DiscoveryEntry { + set_id, + claimed_status: status, + has_osu_std, + mirror_last_updated: info.last_update.map(unix_sec_to_iso), + })) + } +} + +fn parse_entry(raw: &SayobotListEntry) -> Option { + let status = match raw.approved { + 1 => RankedStatus::Ranked, + 2 => RankedStatus::Approved, + 3 => RankedStatus::Qualified, + 4 => RankedStatus::Loved, + _ => return None, + }; + if raw.modes & MODE_BIT_STD == 0 { + return None; + } + Some(DiscoveryEntry { + set_id: raw.sid, + claimed_status: status, + has_osu_std: true, + mirror_last_updated: raw.lastupdate.map(unix_sec_to_iso), + }) +} + +/// Map an osu! API-style mode integer to Sayobot's mode bitmask. Sayobot +/// expects exactly one of the bits set when filtering by a specific mode; +/// out-of-range inputs fall back to "include osu! std" so we still return +/// rows the aggregator can use. +fn mode_int_to_bitmask(mode_int: u8) -> u32 { + match mode_int { + 0 => 1, // osu! + 1 => 2, // taiko + 2 => 4, // catch + 3 => 8, // mania + _ => MODE_BIT_STD, + } +} + +/// Convert unix seconds to RFC3339 / ISO 8601 (`YYYY-MM-DDThh:mm:ssZ`). +/// Sayobot stores epoch seconds; every other source stores ISO. We +/// normalize on write so the `mirror_discoveries` table holds one format +/// for human inspection and lex-comparable ordering. +/// +/// Date arithmetic uses Hinnant's "days since civil epoch" algorithm +/// (public domain) — handles negative inputs and any year up to ~9999 +/// correctly without pulling chrono / time as a dependency. +fn unix_sec_to_iso(secs: i64) -> String { + let day_seconds: i64 = 86400; + let mut days = secs.div_euclid(day_seconds); + let mut rem = secs.rem_euclid(day_seconds); + if rem < 0 { + rem += day_seconds; + days -= 1; + } + let h = rem / 3600; + let m = (rem % 3600) / 60; + let s = rem % 60; + let (y, mo, d) = days_to_ymd(days); + format!("{y:04}-{mo:02}-{d:02}T{h:02}:{m:02}:{s:02}Z") +} + +/// Days since Unix epoch (1970-01-01) → (year, month, day). Howard +/// Hinnant's `civil_from_days` algorithm; valid for the entire signed +/// 64-bit range we'd ever see. +fn days_to_ymd(days: i64) -> (i64, u32, u32) { + let z = days + 719468; + let era = z.div_euclid(146097); + let doe = z.rem_euclid(146097) as u64; + let yoe = (doe - doe / 1460 + doe / 36524 - doe / 146096) / 365; + let y = yoe as i64 + era * 400; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let d = (doy - (153 * mp + 2) / 5 + 1) as u32; + let m = if mp < 10 { mp + 3 } else { mp - 9 } as u32; + let y = if m <= 2 { y + 1 } else { y }; + (y, m, d) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn parses_typical_list_response() { + let body = r#"{ + "data":[ + {"sid":2540534,"approved":1,"modes":1,"lastupdate":1776440408, + "title":"x","artist":"y","creator":"z","favourite_count":15,"play_count":1,"order":0,"titleU":"","artistU":""}, + {"sid":2542796,"approved":3,"modes":1,"lastupdate":1777195153, + "title":"x","artist":"y","creator":"z","favourite_count":1,"play_count":1,"order":0,"titleU":"","artistU":""} + ], + "endid":4, + "status":0 + }"#; + let parsed: SayobotListResp = serde_json::from_str(body).unwrap(); + assert_eq!(parsed.status, 0); + let e0 = parse_entry(&parsed.data[0]).unwrap(); + assert_eq!(e0.set_id, 2540534); + assert_eq!(e0.claimed_status, RankedStatus::Ranked); + assert!(e0.has_osu_std); + let e1 = parse_entry(&parsed.data[1]).unwrap(); + assert_eq!(e1.claimed_status, RankedStatus::Qualified); + } + + #[test] + fn drops_taiko_only_set_via_modes_bitmask() { + let raw = SayobotListEntry { + sid: 1, + approved: 1, + modes: 2, // taiko bit, no osu! + lastupdate: None, + }; + assert!(parse_entry(&raw).is_none()); + } + + #[test] + fn keeps_set_with_multiple_modes_when_osu_bit_is_set() { + let raw = SayobotListEntry { + sid: 99, + approved: 4, + modes: 1 | 2 | 8, // osu+taiko+mania + lastupdate: Some(1700000000), + }; + let e = parse_entry(&raw).unwrap(); + assert_eq!(e.claimed_status, RankedStatus::Loved); + assert!(e.has_osu_std); + } + + #[test] + fn drops_graveyard_pending_wip() { + for code in [-2, -1, 0] { + let raw = SayobotListEntry { + sid: 1, + approved: code, + modes: 1, + lastupdate: None, + }; + assert!(parse_entry(&raw).is_none(), "code {code} should be dropped"); + } + } + + #[test] + fn server_status_nonzero_returns_empty_page_in_decode() { + // The walker calls search_page; if the JSON shape parsed but the + // server returned status=-1, we expect the parser to expose that. + let body = r#"{"data":[],"endid":0,"status":-1}"#; + let parsed: SayobotListResp = serde_json::from_str(body).unwrap(); + assert_eq!(parsed.status, -1); + assert!(parsed.data.is_empty()); + } + + #[test] + fn mode_int_to_bitmask_covers_known_modes() { + assert_eq!(mode_int_to_bitmask(0), 1); + assert_eq!(mode_int_to_bitmask(1), 2); + assert_eq!(mode_int_to_bitmask(2), 4); + assert_eq!(mode_int_to_bitmask(3), 8); + // Out-of-range falls back to osu!std so we still get rows. + assert_eq!(mode_int_to_bitmask(99), 1); + } + + #[test] + fn unix_sec_to_iso_known_values() { + // Cross-checked with `date -u -d @`. Pinned here so future + // edits to `days_to_ymd` can't silently drift. + assert_eq!(unix_sec_to_iso(0), "1970-01-01T00:00:00Z"); + assert_eq!(unix_sec_to_iso(86400), "1970-01-02T00:00:00Z"); + assert_eq!(unix_sec_to_iso(1700000000), "2023-11-14T22:13:20Z"); + // 2026-04-15T14:51:26Z = epoch 1776264686 (sayobot's `lastupdate` + // for one of the loved sets we sampled during the integration probe). + assert_eq!(unix_sec_to_iso(1776264686), "2026-04-15T14:51:26Z"); + // Cross-month boundary: 2024-12-31T23:59:59Z → 1735689599. + assert_eq!(unix_sec_to_iso(1735689599), "2024-12-31T23:59:59Z"); + // Leap-year day: 2024-02-29T00:00:00Z → 1709164800. + assert_eq!(unix_sec_to_iso(1709164800), "2024-02-29T00:00:00Z"); + } + + #[test] + fn unix_sec_to_iso_handles_negative_input_without_panic() { + // Very early unix timestamps shouldn't crash the formatter — Sayobot + // returns -1 for "no value", which is what triggers this path. + let s = unix_sec_to_iso(-1); + assert!(s.starts_with("1969-12-31T23:59:59")); + } + + #[test] + fn beatmapinfo_response_decodes_for_existing_set() { + // Excerpt from the live response for set 2303912 (graveyard, but + // with osu! difficulties present). The verifier should mark it None + // because graveyard isn't a tracked status. + let body = r#"{ + "data":{"approved":-2,"approved_date":-1, + "bid_data":[{"mode":0,"bid":1,"length":1,"AR":9.4,"CS":4,"HP":4,"OD":9,"audio":"","bg":"","circles":1,"hit300window":0,"img":"0","maxcombo":1,"passcount":1,"playcount":1,"pp":0,"pp_acc":0,"pp_aim":0,"pp_speed":0,"sliders":1,"speed":0,"spinners":0,"star":1,"strain_aim":"","strain_speed":"","version":"x","aim":0}], + "last_update":1700000000, + "title":"","artist":"","artistU":"","titleU":"","creator":"","source":"","tags":""}, + "status":0 + }"#; + let parsed: SayobotInfoResp = serde_json::from_str(body).unwrap(); + assert_eq!(parsed.status, 0); + assert_eq!(parsed.data.unwrap().approved, -2); + } +} diff --git a/crates/osu_fetcher/src/download.rs b/crates/osu_fetcher/src/download.rs new file mode 100644 index 0000000000000000000000000000000000000000..ad0f01d98e3db35609340572a827902cad0f4e18 --- /dev/null +++ b/crates/osu_fetcher/src/download.rs @@ -0,0 +1,530 @@ +//! `download` subcommand — bounded-concurrency worker pool. +//! +//! The orchestration is deliberately small: we spin up a fixed number of +//! workers (`concurrency` argument), each in a `select!` loop of "claim → +//! fetch → verify → write → update state". The state DB is the only +//! synchronization primitive; workers never talk to each other directly. +//! +//! Why per-worker `select!` against a shutdown signal: if Ctrl-C arrives +//! while a worker is mid-HTTP, we let the in-flight request finish (its +//! result still gets recorded), then bail out before claiming the next set. +//! That keeps the state DB tidy — no abandoned `in_progress` rows on graceful +//! shutdown. +//! +//! Atomicity on writes: each `.osz` is written to `.osz.partial`, fsynced, +//! and renamed in place. A crash mid-write leaves a `.partial` file that +//! `scan` will ignore (it filters on the `.osz` extension). The `.partial` +//! cleanup is best-effort on the next `download` run via the +//! [`cleanup_orphan_partials`] helper. + +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::Arc; + +use anyhow::{Context, Result}; +use sha2::{Digest, Sha256}; +use tokio::fs; +use tokio::io::AsyncWriteExt; +use tokio::task::JoinSet; +use tokio_util::sync::CancellationToken; +use tracing::{debug, error, info, warn}; + +use crate::mirrors::{AttemptObserver, MirrorError, MirrorPool, NoOpObserver}; +use crate::progress::DownloadDashboard; +use crate::state::{AttemptOutcome as StateOutcome, DownloadFailure, DownloadSuccess, StateDb}; +use crate::Flavor; + +#[derive(Clone, Copy, Debug, Default)] +pub struct DownloadStats { + pub attempted: u64, + pub success: u64, + pub failed: u64, + pub missing: u64, + pub aborted: u64, +} + +#[derive(Clone, Debug)] +pub struct DownloadOptions { + pub archives_dir: PathBuf, + pub flavor: Flavor, + pub concurrency: usize, + /// Cap total *attempted* downloads in this run (None = drain queue). + pub limit: Option, +} + +impl Default for DownloadOptions { + fn default() -> Self { + Self { + archives_dir: PathBuf::from("osu_archives"), + flavor: Flavor::Full, + concurrency: 8, + limit: None, + } + } +} + +pub async fn run( + state: Arc, + pool: Arc, + opts: DownloadOptions, + shutdown: CancellationToken, + dashboard: Option>, +) -> Result { + if pool.is_empty() { + anyhow::bail!("mirror pool is empty — nothing can be downloaded"); + } + fs::create_dir_all(&opts.archives_dir) + .await + .with_context(|| format!("creating {}", opts.archives_dir.display()))?; + + // Re-queue any rows from a prior crashed run. + let requeued = state.requeue_in_progress()?; + if requeued > 0 { + info!(rows = requeued, "requeued in_progress rows from prior run"); + } + cleanup_orphan_partials(&opts.archives_dir).await; + + let worker_count = opts.concurrency.max(1); + let budget = Arc::new(AttemptBudget::new(opts.limit)); + let mut tasks: JoinSet = JoinSet::new(); + let mut stats = DownloadStats::default(); + + for worker_id in 0..worker_count { + tasks.spawn(download_worker( + worker_id, + opts.flavor, + opts.archives_dir.clone(), + pool.clone(), + state.clone(), + shutdown.clone(), + dashboard.clone(), + budget.clone(), + )); + } + + while let Some(joined) = tasks.join_next().await { + match joined { + Ok(worker_stats) => stats.add(worker_stats), + Err(e) => { + error!(err = %e, "download worker task panicked"); + stats.failed += 1; + if let Some(d) = dashboard.as_deref() { + d.record_failed(); + } + } + } + } + + Ok(stats) +} + +impl DownloadStats { + fn add(&mut self, other: DownloadStats) { + self.attempted += other.attempted; + self.success += other.success; + self.failed += other.failed; + self.missing += other.missing; + self.aborted += other.aborted; + } +} + +#[derive(Debug)] +struct AttemptBudget { + limit: Option, + claimed: AtomicU64, +} + +impl AttemptBudget { + fn new(limit: Option) -> Self { + Self { + limit, + claimed: AtomicU64::new(0), + } + } + + fn try_reserve(&self) -> bool { + let Some(limit) = self.limit else { + return true; + }; + loop { + let current = self.claimed.load(Ordering::Relaxed); + if current >= limit { + return false; + } + if self + .claimed + .compare_exchange_weak(current, current + 1, Ordering::AcqRel, Ordering::Relaxed) + .is_ok() + { + return true; + } + } + } + + fn release_unused(&self) { + if self.limit.is_some() { + self.claimed.fetch_sub(1, Ordering::AcqRel); + } + } +} + +async fn download_worker( + worker_id: usize, + flavor: Flavor, + archives_dir: PathBuf, + pool: Arc, + state: Arc, + shutdown: CancellationToken, + dashboard: Option>, + budget: Arc, +) -> DownloadStats { + let mut stats = DownloadStats::default(); + + loop { + if shutdown.is_cancelled() { + debug!(worker_id, "download worker stopping after shutdown"); + break; + } + if !budget.try_reserve() { + debug!(worker_id, "download worker reached attempt limit"); + break; + } + + let set_id = match state.claim_next_pending() { + Ok(Some(set_id)) => set_id, + Ok(None) => { + budget.release_unused(); + debug!(worker_id, "download worker found empty queue"); + break; + } + Err(e) => { + budget.release_unused(); + error!(worker_id, err = %e, "claim_next_pending failed; worker exiting"); + break; + } + }; + + stats.attempted += 1; + if let Some(d) = &dashboard { + d.worker_inflight_inc(); + } + let outcome = run_one( + set_id, + flavor, + &archives_dir, + pool.clone(), + state.clone(), + shutdown.clone(), + dashboard.clone(), + ) + .await; + if let Some(d) = &dashboard { + d.worker_inflight_dec(); + } + match outcome { + WorkerOutcome::Success => stats.success += 1, + WorkerOutcome::Failed => stats.failed += 1, + WorkerOutcome::Missing => stats.missing += 1, + WorkerOutcome::Aborted => stats.aborted += 1, + } + } + + stats +} + +#[derive(Debug)] +enum WorkerOutcome { + Success, + Failed, + Missing, + Aborted, +} + +async fn run_one( + set_id: u64, + flavor: Flavor, + archives_dir: &Path, + pool: Arc, + state: Arc, + shutdown: CancellationToken, + dashboard: Option>, +) -> WorkerOutcome { + if shutdown.is_cancelled() { + if let Err(e) = state.release_claim(set_id) { + warn!(set_id, err = %e, "release_claim after shutdown"); + } + if let Some(d) = &dashboard { + d.record_aborted(); + } + return WorkerOutcome::Aborted; + } + + // Race the in-flight HTTP against the shutdown token so a Ctrl-C while + // a worker is mid-download (especially big videos: 100+ MB / 30+ s) + // aborts the request rather than waiting for it to finish. + let noop = NoOpObserver; + let observer: &dyn AttemptObserver = match dashboard.as_deref() { + Some(d) => d, + None => &noop, + }; + let download_fut = pool.download_with_observer(set_id, flavor, observer); + let (result, attempts) = tokio::select! { + biased; + _ = shutdown.cancelled() => { + if let Err(e) = state.release_claim(set_id) { + warn!(set_id, err = %e, "release_claim after mid-flight shutdown"); + } + if let Some(d) = &dashboard { + d.record_aborted(); + } + return WorkerOutcome::Aborted; + } + out = download_fut => out, + }; + // Persist every attempt regardless of overall outcome. + for a in &attempts { + let outcome = match a.outcome { + crate::mirrors::AttemptOutcome::Success => StateOutcome::Success, + crate::mirrors::AttemptOutcome::NotFound => StateOutcome::NotFound, + crate::mirrors::AttemptOutcome::HttpError => StateOutcome::HttpError, + crate::mirrors::AttemptOutcome::RateLimited => StateOutcome::RateLimited, + crate::mirrors::AttemptOutcome::Network => StateOutcome::Network, + crate::mirrors::AttemptOutcome::InvalidArchive => StateOutcome::InvalidArchive, + crate::mirrors::AttemptOutcome::Timeout => StateOutcome::Timeout, + crate::mirrors::AttemptOutcome::UnsupportedFlavor => continue, + }; + if let Err(e) = state.record_attempt( + set_id, + &a.mirror, + outcome, + a.http_status, + a.bytes, + Some(a.duration.as_millis() as u64), + a.error.as_deref(), + ) { + warn!(set_id, mirror = %a.mirror, err = %e, "record_attempt failed"); + } + if let Some(d) = &dashboard { + d.record_attempt(&a.mirror, a.outcome, a.duration, a.bytes); + } + } + + match result { + Ok((mirror, bytes)) => { + // Pool's classify_response already deep-verified (zip + at least + // one .osu) before returning, so we trust the bytes here. + let sha = sha256_hex(&bytes); + let final_path = archives_dir.join(format!("{set_id}.osz")); + if let Err(e) = atomic_write(&final_path, archives_dir, &bytes).await { + let msg = format!("atomic_write: {e}"); + error!(set_id, mirror = %mirror, err = %msg); + let _ = state.finish_failed(&DownloadFailure { + set_id, + mirror: &mirror, + error: &msg, + }); + if let Some(d) = &dashboard { + d.record_failed(); + } + return WorkerOutcome::Failed; + } + let saved_path = final_path.to_string_lossy(); + // If the DB write fails, we have an orphan .osz on disk. Surface + // this as a Failed outcome so the run stats reflect reality — + // the next run will requeue (in_progress -> pending), re-fetch, + // and atomic_write will overwrite the existing file with the + // same (or newer) bytes. No data corruption, no lost work. + if let Err(e) = state.finish_success(&DownloadSuccess { + set_id, + mirror: &mirror, + bytes: bytes.len() as u64, + sha256: &sha, + flavor: flavor.as_str(), + saved_path: &saved_path, + }) { + let msg = format!("finish_success DB write: {e}"); + error!(set_id, mirror = %mirror, err = %msg); + let _ = state.finish_failed(&DownloadFailure { + set_id, + mirror: &mirror, + error: &msg, + }); + if let Some(d) = &dashboard { + d.record_failed(); + } + return WorkerOutcome::Failed; + } + // Per-set INFO is at debug! so the dashboard isn't clobbered; + // promote with --verbose / RUST_LOG when investigating. + debug!( + set_id, + mirror = %mirror, + bytes = bytes.len(), + "download ok" + ); + if let Some(d) = &dashboard { + d.record_success(bytes.len() as u64); + } + WorkerOutcome::Success + } + Err(MirrorError::NotFound { mirror }) => { + // Promoted by the pool: every mirror returned 404. + let tried = attempt_summary(&attempts); + let msg = format!("not found on any mirror (last={mirror}; tried={tried})"); + warn!(set_id, attempts = attempts.len(), mirrors = %tried, %msg); + let _ = state.finish_missing(&DownloadFailure { + set_id, + mirror: &mirror, + error: &msg, + }); + if let Some(d) = &dashboard { + d.record_missing(); + } + WorkerOutcome::Missing + } + Err(MirrorError::Aborted) => { + if let Err(e) = state.release_claim(set_id) { + warn!(set_id, err = %e, "release_claim after Aborted"); + } + if let Some(d) = &dashboard { + d.record_aborted(); + } + WorkerOutcome::Aborted + } + Err(other) => { + let mirror = other.mirror_name().to_string(); + let msg = other.to_string(); + let tried = attempt_summary(&attempts); + warn!( + set_id, + %mirror, + attempts = attempts.len(), + mirrors = %tried, + err = %msg, + "download failed after trying mirror chain" + ); + let _ = state.finish_failed(&DownloadFailure { + set_id, + mirror: &mirror, + error: &msg, + }); + if let Some(d) = &dashboard { + d.record_failed(); + } + WorkerOutcome::Failed + } + } +} + +fn attempt_summary(attempts: &[crate::mirrors::AttemptRecord]) -> String { + attempts + .iter() + .map(|a| format!("{}:{:?}", a.mirror, a.outcome)) + .collect::>() + .join(",") +} + +/// Crash-safe write: bytes hit a `.partial` file, are fsynced, then renamed +/// in place. After the rename we also fsync the parent directory so the +/// rename's metadata is durable on power-off — without that step, some +/// filesystems can lose the directory entry while the file's contents are +/// safe, leaving us with bytes on disk that nothing references and a state +/// row that thinks the file is there. +/// +/// On Windows the directory-fsync call is a noop at the FS level (NTFS +/// orders metadata more strictly than ext4) but we issue it unconditionally +/// because fs4-style portable code is cheaper than another platform branch. +async fn atomic_write(final_path: &Path, parent_dir: &Path, bytes: &[u8]) -> std::io::Result<()> { + let tmp = final_path.with_extension("osz.partial"); + let mut f = fs::File::create(&tmp).await?; + f.write_all(bytes).await?; + f.flush().await?; + f.sync_all().await?; + drop(f); + fs::rename(&tmp, final_path).await?; + // Fsync the directory so the rename is durable. Errors here are not + // fatal — the file is already on disk — but they're worth logging. + let dir = parent_dir.to_path_buf(); + if let Err(e) = + tokio::task::spawn_blocking(move || std::fs::File::open(&dir).and_then(|f| f.sync_all())) + .await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))? + { + tracing::debug!( + path = %parent_dir.display(), + err = %e, + "dir fsync after rename failed (non-fatal)" + ); + } + Ok(()) +} + +fn sha256_hex(bytes: &[u8]) -> String { + let mut h = Sha256::new(); + h.update(bytes); + hex::encode(h.finalize()) +} + +/// Best-effort cleanup of `.partial` files left behind by a crashed worker. +/// Failures here are logged at debug level — they don't block downloads. +pub async fn cleanup_orphan_partials(archives_dir: &Path) { + let Ok(mut entries) = fs::read_dir(archives_dir).await else { + return; + }; + while let Ok(Some(entry)) = entries.next_entry().await { + let path = entry.path(); + if path + .extension() + .and_then(|e| e.to_str()) + .map(|e| e.eq_ignore_ascii_case("partial")) + .unwrap_or(false) + { + if let Err(e) = fs::remove_file(&path).await { + debug!(path = %path.display(), err = %e, "couldn't remove orphan partial"); + } else { + debug!(path = %path.display(), "cleaned orphan partial"); + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + use tempfile::TempDir; + + #[tokio::test] + async fn atomic_write_creates_final_file_and_removes_tmp() { + let dir = TempDir::new().unwrap(); + let final_path = dir.path().join("123.osz"); + atomic_write(&final_path, dir.path(), b"PK\x03\x04hello") + .await + .unwrap(); + assert!(final_path.exists()); + assert!(!dir.path().join("123.osz.partial").exists()); + let read = fs::read(&final_path).await.unwrap(); + assert_eq!(read, b"PK\x03\x04hello"); + } + + #[tokio::test] + async fn cleanup_removes_only_partials() { + let dir = TempDir::new().unwrap(); + fs::write(dir.path().join("123.osz.partial"), b"x") + .await + .unwrap(); + fs::write(dir.path().join("456.osz"), b"y").await.unwrap(); + cleanup_orphan_partials(dir.path()).await; + assert!(!dir.path().join("123.osz.partial").exists()); + assert!(dir.path().join("456.osz").exists()); + } + + #[test] + fn sha256_hex_matches_known_vector() { + // Known SHA-256 of "hello" (lowercase hex) is + // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824. + assert_eq!( + sha256_hex(b"hello"), + "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" + ); + } +} diff --git a/crates/osu_fetcher/src/enumerate.rs b/crates/osu_fetcher/src/enumerate.rs new file mode 100644 index 0000000000000000000000000000000000000000..a7aeb77a409c9f3bfbb5751e67f146de52f1248a --- /dev/null +++ b/crates/osu_fetcher/src/enumerate.rs @@ -0,0 +1,356 @@ +//! `enumerate` subcommand — populate the wanted side of the `sets` table by +//! paginating the official osu! API search endpoint. +//! +//! Pagination is cursor-based: each successful response carries a +//! `cursor_string` to feed back into the next request, or `None` when the +//! server has nothing left. We persist the cursor into `meta` after every +//! successful page so a crash mid-enumerate resumes from the next unscanned +//! page. +//! +//! ## Incremental mode +//! +//! Each successful enumerate stores a per-status `last_updated` "high-water +//! mark" — the most recent `last_updated` value across every set seen in +//! that run. Subsequent runs query the API with `sort=updated_desc`, walking +//! pages newest-first, and stop pagination once they hit a set whose +//! `last_updated <= watermark` (i.e., already known and unchanged). This +//! cuts a steady-state daily enumerate from ~700 pages down to the number +//! of *new or updated* pages — usually 1–5. +//! +//! Set `EnumerateOptions::full_rescan = true` (or `--full-rescan` on the +//! CLI) to ignore the watermark and re-paginate everything; useful when +//! you're worried the watermark drifted or when bootstrapping a fresh DB. + +use std::sync::Arc; + +use anyhow::{Context, Result}; +use tracing::{debug, info}; + +use crate::api::OsuApi; +use crate::progress::CounterSpinner; +use crate::state::{StateDb, WantedRow}; +use crate::RankedStatus; + +#[derive(Clone, Copy, Debug, Default)] +pub struct EnumerateStats { + pub pages: u64, + pub seen: u64, + pub upserted: u64, + pub skipped_no_osu_mode: u64, + /// True when pagination stopped because we hit the saved watermark + /// (the incremental fast-path), rather than exhausting the cursor. + pub stopped_at_watermark: bool, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum SearchSort { + UpdatedDesc, + RankedDesc, +} + +impl SearchSort { + pub fn as_api_str(self) -> &'static str { + match self { + SearchSort::UpdatedDesc => "updated_desc", + SearchSort::RankedDesc => "ranked_desc", + } + } +} + +#[derive(Clone, Copy, Debug)] +pub struct EnumerateOptions { + /// Mode integer (0 = osu! standard). + pub mode: u8, + /// Hard cap on pages per status (None = exhaust the cursor). + pub max_pages: Option, + /// If true, only persist sets that have at least one beatmap whose + /// `mode_int` matches `mode`. The API search filter already returns sets + /// that *contain* such a difficulty, but the field lets us be paranoid. + pub require_matching_mode_difficulty: bool, + /// Ignore the saved high-water mark and walk every page. Use this for + /// bootstrap runs or when you suspect the watermark is stale. + pub full_rescan: bool, + /// Search ordering to request from osu! API. + pub sort: SearchSort, + /// Do not read or persist cursor/high-water metadata. Use this for + /// bounded front scans such as `ranked_desc` recent-rank checks. + pub stateless: bool, +} + +impl Default for EnumerateOptions { + fn default() -> Self { + Self { + mode: 0, + max_pages: None, + require_matching_mode_difficulty: true, + full_rescan: false, + sort: SearchSort::UpdatedDesc, + stateless: false, + } + } +} + +/// Enumerate one (status, mode) combination through cursor pagination. +/// +/// `progress`, when supplied, has its message updated after every page so +/// the spinner reflects live page/seen/upserted counts. +pub async fn enumerate_status( + api: Arc, + state: Arc, + status: RankedStatus, + opts: EnumerateOptions, + progress: Option<&CounterSpinner>, +) -> Result { + let mut stats = EnumerateStats::default(); + + // Resume any in-flight cursor from a crashed prior run. If a cursor is + // present it dominates the watermark — we have to drain the page chain + // we were on before we can trust a fresh `updated_desc` walk. + let mut cursor = if opts.stateless { + None + } else { + state + .get_enumerate_cursor(status) + .with_context(|| format!("loading saved cursor for {}", status.as_api_str()))? + }; + + let watermark = if opts.full_rescan || opts.stateless || opts.sort != SearchSort::UpdatedDesc { + None + } else { + state + .get_enumerate_high_water(status) + .with_context(|| format!("loading high-water mark for {}", status.as_api_str()))? + }; + let mid_run_resume = cursor.is_some(); + + if let Some(c) = cursor.as_deref() { + info!( + status = status.as_api_str(), + cursor = c, + "resuming enumerate from saved cursor" + ); + } else if let Some(w) = watermark.as_deref() { + info!( + status = status.as_api_str(), + watermark = w, + "incremental enumerate; will stop at watermark" + ); + } else if opts.stateless { + info!( + status = status.as_api_str(), + sort = opts.sort.as_api_str(), + "stateless front-scan enumerate" + ); + } else { + info!( + status = status.as_api_str(), + "full enumerate (no watermark)" + ); + } + + let mut max_seen: Option = None; + loop { + // Fresh runs (and resumed runs without a cursor) sort by + // updated_desc so the watermark check terminates fast. If we're + // resuming a saved cursor, we must NOT change the sort — the + // server-issued cursor is sort-aware. + let sort = if mid_run_resume { + None + } else { + Some(opts.sort.as_api_str()) + }; + + let resp = api + .search_beatmapsets(status, opts.mode, cursor.as_deref(), sort) + .await + .with_context(|| { + format!( + "search beatmapsets m={} s={} cursor={:?}", + opts.mode, + status.as_api_str(), + cursor.as_deref() + ) + })?; + stats.pages += 1; + let page_size = resp.beatmapsets.len() as u64; + stats.seen += page_size; + debug!( + status = status.as_api_str(), + page = stats.pages, + count = page_size, + total = ?resp.total, + cursor = ?resp.cursor_string, + "/search page" + ); + + let mut hit_watermark = false; + for entry in &resp.beatmapsets { + // Track the freshest `last_updated` we've seen so we can save + // it as the next watermark. + if let Some(lu) = entry.last_updated.as_deref() { + if max_seen.as_deref().map(|m| lu > m).unwrap_or(true) { + max_seen = Some(lu.to_string()); + } + // Watermark check: in updated_desc order, hitting + // `last_updated <= watermark` means the rest of the catalog + // is already known. Finish the page (cheap) then break. + if opts.sort == SearchSort::UpdatedDesc && !mid_run_resume { + if let Some(w) = watermark.as_deref() { + if lu <= w { + hit_watermark = true; + } + } + } + } + + if opts.require_matching_mode_difficulty { + let any_match = match &entry.beatmaps { + Some(diffs) => diffs.iter().any(|d| { + d.mode_int.map(|m| m == opts.mode).unwrap_or(false) + || d.mode + .as_deref() + .map(|s| api_mode_int(s) == Some(opts.mode)) + .unwrap_or(false) + }), + // Older API responses without `beatmaps` — trust the + // upstream `s=` filter and accept the row. + None => true, + }; + if !any_match { + stats.skipped_no_osu_mode += 1; + continue; + } + } + + state.upsert_wanted(&WantedRow { + set_id: entry.id, + ranked_status: status, + artist: entry.artist.as_deref(), + title: entry.title.as_deref(), + creator: entry.creator.as_deref(), + api_last_updated: entry.last_updated.as_deref(), + })?; + stats.upserted += 1; + } + + // Save cursor *after* persisting the page so a crash never loses rows + // (we'd just re-upsert idempotently on resume). + cursor = resp.cursor_string.clone(); + if !opts.stateless { + state + .set_enumerate_cursor(status, cursor.as_deref()) + .context("persisting cursor")?; + } + + if let Some(p) = progress { + let cursor_hint = cursor + .as_deref() + .map(short_cursor) + .unwrap_or_else(|| "done".into()); + p.set_message(format!( + "pages {} · seen {} · upserted {} · skipped {} · cursor {}", + stats.pages, stats.seen, stats.upserted, stats.skipped_no_osu_mode, cursor_hint, + )); + } + + if hit_watermark { + stats.stopped_at_watermark = true; + info!( + status = status.as_api_str(), + pages = stats.pages, + "stopped at watermark; remaining catalog already known" + ); + break; + } + if cursor.is_none() { + break; + } + if let Some(max) = opts.max_pages { + if stats.pages >= max { + info!( + status = status.as_api_str(), + pages = stats.pages, + "stopping early at --max-pages" + ); + break; + } + } + } + + // Clean exit means either we hit the watermark or the cursor was + // exhausted. In both cases, the cursor is no longer useful — wipe it + // and bump the watermark. + let cursor_exhausted = cursor.is_none(); + if !opts.stateless + && (stats.stopped_at_watermark || cursor_exhausted) + && !mid_run_resume + && opts.sort == SearchSort::UpdatedDesc + { + // Wipe the cursor (we're done; next run starts fresh). + state + .set_enumerate_cursor(status, None) + .context("clearing cursor at clean exit")?; + // New watermark = max(prev, this run's max_seen). If this run saw + // nothing newer than the watermark (an empty incremental), don't + // regress. + let new_watermark = match (watermark.as_deref(), max_seen.as_deref()) { + (Some(prev), Some(now)) if now > prev => Some(now), + (Some(prev), _) => Some(prev), + (None, Some(now)) => Some(now), + (None, None) => None, + }; + if new_watermark.is_some() { + state + .set_enumerate_high_water(status, new_watermark) + .context("persisting new high-water mark")?; + } + } + // If `mid_run_resume` was true, leave the watermark alone — we just + // walked an old cursor under whatever sort the previous run started + // with, and the result isn't comparable to an `updated_desc` watermark. + + Ok(stats) +} + +/// Last 8 chars of an opaque cursor string — enough for the user to see +/// it advance, short enough to fit in the spinner template. +fn short_cursor(c: &str) -> String { + if c.len() <= 10 { + c.to_string() + } else { + format!("…{}", &c[c.len() - 8..]) + } +} + +/// Convert an API mode string (`"osu" | "taiko" | "catch" | "mania"`) to its +/// integer. +fn api_mode_int(s: &str) -> Option { + match s { + "osu" => Some(0), + "taiko" => Some(1), + "fruits" | "catch" => Some(2), + "mania" => Some(3), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn api_mode_int_recognizes_known_modes() { + assert_eq!(api_mode_int("osu"), Some(0)); + assert_eq!(api_mode_int("taiko"), Some(1)); + assert_eq!(api_mode_int("fruits"), Some(2)); + assert_eq!(api_mode_int("catch"), Some(2)); + assert_eq!(api_mode_int("mania"), Some(3)); + assert_eq!(api_mode_int("???"), None); + } + + #[test] + fn search_sort_tokens_match_osu_api() { + assert_eq!(SearchSort::UpdatedDesc.as_api_str(), "updated_desc"); + assert_eq!(SearchSort::RankedDesc.as_api_str(), "ranked_desc"); + } +} diff --git a/crates/osu_fetcher/src/lib.rs b/crates/osu_fetcher/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..9bfb5117736ee984a9e634b31a635476234a6005 --- /dev/null +++ b/crates/osu_fetcher/src/lib.rs @@ -0,0 +1,113 @@ +//! osu_fetcher library — discover and download missing osu! beatmapsets. +//! +//! The CLI in `main.rs` is a thin shim over these modules so that integration +//! tests can drive each phase directly without forking a process. +//! +//! Five stateful tables in SQLite (see `state` module) carry the work: +//! +//! * `sets` — the merged "wanted + acquired" record per beatmapset. A row is +//! created either by `enumerate` (API said this set exists with a +//! leaderboard) or by `scan` (we found a `.osz` on disk). Both sides +//! can later be filled in. +//! * `mirror_attempts` — append-only log of every download attempt across +//! mirrors. Used to weight mirror health and for forensics. +//! * `meta` — small key/value store for cursor checkpoints and schema +//! version. +//! +//! State transitions are deliberately narrow: +//! +//! `pending -> in_progress -> { success | failed | missing }` +//! +//! `in_progress` is reset to `pending` on startup so a crashed worker doesn't +//! block forever. + +pub mod api; +pub mod auth; +pub mod config; +pub mod discover; +pub mod download; +pub mod enumerate; +pub mod mirrors; +pub mod progress; +pub mod ratelimit; +pub mod runlock; +pub mod scan; +pub mod state; +pub mod verify; + +/// Archive flavor preference passed through the mirror pool. +#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum Flavor { + /// Original archive with all assets (audio + video + storyboard + skin). + Full, + /// Hitsound archive without video. Smaller; some mirrors only serve this. + NoVideo, +} + +impl Flavor { + pub fn as_str(self) -> &'static str { + match self { + Flavor::Full => "full", + Flavor::NoVideo => "novideo", + } + } +} + +impl std::str::FromStr for Flavor { + type Err = String; + fn from_str(s: &str) -> Result { + match s { + "full" => Ok(Flavor::Full), + "novideo" | "no-video" | "no_video" => Ok(Flavor::NoVideo), + other => Err(format!( + "unknown flavor `{other}` (expected: full | novideo)" + )), + } + } +} + +/// Beatmapset ranked statuses we care about (osu! standard with leaderboards). +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum RankedStatus { + Ranked, + Approved, + Loved, + Qualified, +} + +impl RankedStatus { + pub fn as_api_str(self) -> &'static str { + match self { + RankedStatus::Ranked => "ranked", + RankedStatus::Approved => "approved", + RankedStatus::Loved => "loved", + RankedStatus::Qualified => "qualified", + } + } + + pub fn all_with_leaderboard() -> &'static [RankedStatus] { + &[ + RankedStatus::Ranked, + RankedStatus::Approved, + RankedStatus::Loved, + RankedStatus::Qualified, + ] + } +} + +impl std::str::FromStr for RankedStatus { + type Err = String; + fn from_str(s: &str) -> Result { + match s.to_ascii_lowercase().as_str() { + "ranked" => Ok(RankedStatus::Ranked), + "approved" => Ok(RankedStatus::Approved), + "loved" => Ok(RankedStatus::Loved), + "qualified" => Ok(RankedStatus::Qualified), + other => Err(format!( + "unknown ranked status `{other}` (expected: ranked | approved | loved | qualified)" + )), + } + } +} diff --git a/crates/osu_fetcher/src/main.rs b/crates/osu_fetcher/src/main.rs new file mode 100644 index 0000000000000000000000000000000000000000..6d28362de0bc39cb2e4897c44be5e5abf9de8d04 --- /dev/null +++ b/crates/osu_fetcher/src/main.rs @@ -0,0 +1,887 @@ +//! `osu_fetcher` CLI. +//! +//! Subcommands map 1:1 to library modules so each phase is independently +//! testable. Global flags configure the state DB path, archive directory, and +//! per-target rate limits; everything else is subcommand-specific. + +use std::path::PathBuf; +use std::sync::Arc; + +use anyhow::{anyhow, Context, Result}; +use clap::{Parser, Subcommand, ValueEnum}; +use tokio_util::sync::CancellationToken; +use tracing::{info, warn}; + +use osu_fetcher::api::OsuApi; +use osu_fetcher::auth::{OsuAuth, OsuAuthMode}; +use osu_fetcher::config::{self, Config, ResolvedOsuCreds}; +use osu_fetcher::discover::{ + self, + nekoha::NekohaVerify, + nerinyan::NerinyanSearch, + osudirect::{OsuDirectSearch, OsuDirectVerify}, + sayobot::{SayobotSearch, SayobotVerify}, + DiscoverContext, DiscoverLimiters, DiscoverOptions, MirrorSearch, MirrorVerify, +}; +use osu_fetcher::download::{self, DownloadOptions}; +use osu_fetcher::enumerate::{self, EnumerateOptions, EnumerateStats, SearchSort}; +use osu_fetcher::mirrors::{ + beatconnect::BeatconnectMirror, build_client, catboy::CatboyMirror, nekoha::NekohaMirror, + nerinyan::NerinyanMirror, nzbasic::NzbasicMirror, osuapi::OsuApiMirror, + osudirect::OsuDirectMirror, osudl::OsudlMirror, sayobot::SayobotMirror, Mirror, MirrorContext, + MirrorLimiters, MirrorPool, +}; +use osu_fetcher::progress::{self, CounterSpinner, DownloadDashboard, ProgressTarget}; +use osu_fetcher::ratelimit::RateLimited; +use osu_fetcher::runlock::DownloadLock; +use osu_fetcher::scan; +use osu_fetcher::state::StateDb; +use osu_fetcher::verify::{self, AdaptiveVerifyOptions}; +use osu_fetcher::{Flavor, RankedStatus}; + +const DEFAULT_RATE_LIMIT_RPM: u32 = 480; + +#[derive(Parser, Debug)] +#[command( + name = "osu_fetcher", + version, + about = "Discover and download missing osu! beatmapsets via the official API + multiple mirrors." +)] +struct Cli { + /// Path to the TOML config file holding API credentials. Optional: if + /// missing, env vars (OSU_CLIENT_ID / OSU_CLIENT_SECRET / BEATCONNECT_API_KEY) + /// are used. Env vars override file values when both are set. + #[arg(long, global = true)] + config: Option, + + /// SQLite state DB path. Created on first use. + #[arg(long, global = true, default_value = ".fetcher.state.db")] + state_db: PathBuf, + + /// Directory where finished `.osz` archives live. Same dir is read by the + /// rest of the dataset pipeline (`python/ingest_osz.py`). + #[arg(long, global = true, default_value = "osu_archives")] + archives_dir: PathBuf, + + /// Official osu! API rate limit (requests per minute). + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + osu_rpm: u32, + + /// Where to persist the osu! OAuth token between runs. The file holds + /// access_token + refresh_token + expiry; treat it like a credential. + /// On Unix it's created with mode 0600. Default: `.osu_token.json`. + #[arg(long, global = true)] + osu_token_file: Option, + + /// Per-mirror rate limits (requests per minute). Defaults are + /// tuned for the update worker and can be lowered if a mirror asks us + /// to back off. + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + nerinyan_rpm: u32, + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + catboy_rpm: u32, + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + sayobot_rpm: u32, + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + nekoha_rpm: u32, + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + beatconnect_rpm: u32, + /// osu.direct's documented rate limit is lower than this default in + /// some older notes; lower this flag if the mirror asks us to back off. + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + osudirect_rpm: u32, + /// direct.nzbasic.com — same endpoint nzbasic's batch-beatmap-downloader + /// uses. No documented rate limit; can be overridden if needed. + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + nzbasic_rpm: u32, + /// osudl.org — short-link mirror (`/s/{set_id}`). No documented rate + /// limit; can be overridden if needed. + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + osudl_rpm: u32, + /// Official osu! API download endpoint (`/api/v2/beatmapsets/{id}/download`). + /// Shares the same upstream as `--osu-rpm` (which paces enumeration); + /// `download` and `enumerate` aren't run concurrently in normal use, + /// so a separate bucket here is fine. Default matches the other + /// mirrors. + #[arg(long, global = true, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + osuapi_rpm: u32, + + /// Disable a mirror by name. Repeatable: `--disable nerinyan --disable catboy`. + #[arg(long, global = true)] + disable: Vec, + + /// Per-attempt wallclock deadline, in seconds. If a single mirror call + /// (DNS → TLS → headers → body) doesn't complete in this many seconds, + /// the pool aborts it, scores the mirror as a hard failure, and tries + /// the next mirror. Belt-and-suspenders against hung connections that + /// would otherwise hold a worker for the reqwest client's 120s ceiling. + /// Set to 0 to disable (rely only on the reqwest timeout). + #[arg(long, global = true, default_value_t = 60)] + mirror_timeout_secs: u64, + + /// Disable the live terminal dashboard. Use this for CI or when + /// redirecting stderr to a file. Default is to enable when stderr is + /// a TTY. + #[arg(long, global = true)] + no_progress: bool, + + /// Force live download progress through /dev/tty even when stderr is not + /// detected as a terminal. Useful for wrapper scripts that tee logs while + /// still running interactively in tmux. + #[arg(long, global = true)] + force_progress: bool, + + /// Lower the tracing level threshold so per-set INFO lines (e.g. + /// "download ok") appear. Useful for debugging; will visually + /// interrupt the dashboard while events fly by. + #[arg(long, global = true)] + verbose: bool, + + #[command(subcommand)] + cmd: Cmd, +} + +#[derive(Subcommand, Debug)] +enum Cmd { + /// Query the official osu! API and populate the wanted side of the state DB. + Enumerate(EnumerateArgs), + + /// Walk archives_dir and record every `.osz` as already acquired. + Scan(ScanArgs), + + /// Download every pending wanted set in parallel, cycling mirrors. + Download(DownloadArgs), + + /// Print summary counts from the state DB. + Status, + + /// Validate every `.osz` in archives_dir; report corrupt files. + Verify(VerifyArgs), + + /// Reset failed/missing rows back to pending so the next download retries them. + Retry(RetryArgs), + + /// Walk every mirror's search surface and cross-verify candidates. + /// Useful for discovering ranked/loved/approved/qualified sets the + /// official API stopped serving but mirrors still cache. + Discover(DiscoverArgs), +} + +#[derive(clap::Args, Debug)] +struct EnumerateArgs { + /// Statuses to enumerate. Repeatable, comma-separated. + /// Defaults to ranked + approved + loved. + #[arg(long, value_delimiter = ',', default_values = ["ranked", "approved", "loved"])] + statuses: Vec, + + /// Game mode integer. 0 = osu! standard. + #[arg(long, default_value_t = 0)] + mode: u8, + + /// Stop after N pages per status. Useful for smoke testing. + #[arg(long)] + max_pages: Option, + + /// If set, accept beatmapsets even if their listed difficulties don't + /// match `mode`. By default we double-check via the per-difficulty + /// `mode_int` field. + #[arg(long)] + no_mode_filter: bool, + + /// Ignore the saved `last_updated` watermark and re-paginate every + /// page from the API. Use this on first run, after long pauses, or + /// when you suspect the watermark is stale. Default is incremental. + #[arg(long)] + full_rescan: bool, + + /// API sort order for fresh pages. + #[arg(long, value_enum, default_value_t = EnumerateSortArg::UpdatedDesc)] + sort: EnumerateSortArg, + + /// Do not read or persist enumerate cursor/high-water state. Intended + /// for bounded front scans, e.g. `--sort ranked-desc --max-pages 3`. + #[arg(long)] + stateless: bool, +} + +#[derive(Clone, Copy, Debug, ValueEnum)] +enum EnumerateSortArg { + UpdatedDesc, + RankedDesc, +} + +impl From for SearchSort { + fn from(value: EnumerateSortArg) -> Self { + match value { + EnumerateSortArg::UpdatedDesc => SearchSort::UpdatedDesc, + EnumerateSortArg::RankedDesc => SearchSort::RankedDesc, + } + } +} + +#[derive(clap::Args, Debug)] +struct ScanArgs { + /// Open every archive and walk its ZIP entries; corrupt archives are left + /// pending for re-download. Slower but catches bit-rot. + #[arg(long)] + verify: bool, +} + +#[derive(clap::Args, Debug)] +struct DownloadArgs { + /// Concurrent in-flight downloads. Total across all mirrors. + #[arg(long, default_value_t = 8)] + concurrency: usize, + + /// Cap total downloads attempted in this run. + #[arg(long)] + limit: Option, +} + +#[derive(clap::Args, Debug)] +struct VerifyArgs { + /// On corruption, mark the row in the state DB as needing re-download. + /// The next `download` run will overwrite the bad `.osz` on disk. + #[arg(long)] + fix: bool, + + /// Pin the worker pool to this many threads, disabling auto-tuning. + /// Use this when you know the right number for your disk; otherwise + /// the controller hill-climbs between `--min-workers` and `--max-workers` + /// to find the I/O sweet spot (best for HDDs, where 1–3 is typical). + #[arg(long, conflicts_with_all = ["min_workers", "max_workers"])] + workers: Option, + + /// Lower bound for the adaptive worker pool. + #[arg(long, default_value_t = 1)] + min_workers: usize, + + /// Upper bound for the adaptive worker pool. + #[arg(long, default_value_t = 8)] + max_workers: usize, +} + +#[derive(clap::Args, Debug)] +struct RetryArgs {} + +#[derive(clap::Args, Debug)] +struct DiscoverArgs { + /// Statuses to walk on each mirror. Repeatable, comma-separated. + /// Defaults to ranked + approved + loved + qualified (the dataset's + /// full leaderboard target). Mirrors that don't filter server-side + /// only walk once and the aggregator filters by status post-hoc. + #[arg(long, value_delimiter = ',', + default_values = ["ranked", "approved", "loved", "qualified"])] + statuses: Vec, + + /// Game mode integer. 0 = osu! standard. + #[arg(long, default_value_t = 0)] + mode: u8, + + /// Cap pages-per-(mirror,status). Useful for smoke runs. + #[arg(long)] + max_pages: Option, + + /// Minimum number of *independent* mirrors that must agree on a set + /// before it's auto-promoted to `wanted`. The default of 2 protects + /// against a single mirror's stale cache promoting ghost set IDs. + /// Set to 1 to accept any single-mirror sighting (use with caution). + #[arg(long, default_value_t = 2)] + min_quorum: u32, + + /// Per-mirror discovery rate limit. Search endpoints are typically + /// faster than download endpoints, so we keep these separate. + #[arg(long, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + nerinyan_search_rpm: u32, + #[arg(long, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + osudirect_search_rpm: u32, + #[arg(long, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + sayobot_search_rpm: u32, + #[arg(long, default_value_t = DEFAULT_RATE_LIMIT_RPM)] + nekoha_search_rpm: u32, + + /// Disable a discovery source by name. Repeatable. Recognized values: + /// `nerinyan`, `osudirect`, `sayobot`, `nekoha`. + #[arg(long)] + disable: Vec, + + /// Skip the verifier pass. By default, after every list walk we run + /// per-set verifiers on candidates one mirror short of quorum to try + /// to push them over the line. Disabling saves HTTP calls at the + /// cost of leaving more sub-quorum candidates unresolved. + #[arg(long)] + no_verify: bool, + + /// Stop a per-mirror walk after this many consecutive pages where + /// every entry got filtered out (status outside our target set, no + /// osu! standard difficulty). Without the fuse, sayobot's `T=4` + /// list eventually grinds into pending/graveyard rows that never + /// match. 0 disables the fuse (walk to true exhaustion). + #[arg(long, default_value_t = 10)] + consecutive_empty_break_pages: u32, + + /// Per-page retry budget for transient errors (rate-limited, + /// network, 5xx). Backoff doubles each attempt: 2s, 4s, 8s, … + /// 0 disables retries. + #[arg(long, default_value_t = 3)] + retry_attempts: u32, +} + +#[tokio::main] +async fn main() -> Result<()> { + let cli = Cli::parse(); + init_tracing(cli.verbose); + + let state = Arc::new(StateDb::open(&cli.state_db).context("opening state DB")?); + let config_path = config::resolve_config_path(cli.config.as_deref()); + let cfg = Config::load_or_empty(&config_path) + .with_context(|| format!("loading config from {}", config_path.display()))?; + if config_path.exists() { + info!(path = %config_path.display(), "loaded config file"); + } + + match &cli.cmd { + Cmd::Status => cmd_status(state), + Cmd::Retry(_) => cmd_retry(state), + Cmd::Verify(args) => { + cmd_verify(state, &cli.archives_dir, args, progress_enabled(&cli)).await + } + Cmd::Scan(args) => { + cmd_scan( + state, + &cli.archives_dir, + args.verify, + progress_enabled(&cli), + ) + .await + } + Cmd::Enumerate(args) => cmd_enumerate(state, &cli, args, &cfg).await, + Cmd::Download(args) => cmd_download(state, &cli, args, &cfg).await, + Cmd::Discover(args) => cmd_discover(state, &cli, args).await, + } +} + +fn progress_enabled(cli: &Cli) -> bool { + !cli.no_progress && (cli.force_progress || progress::stderr_is_terminal()) +} + +fn download_progress_target(cli: &Cli) -> ProgressTarget { + if cli.no_progress { + ProgressTarget::Hidden + } else if cli.force_progress { + ProgressTarget::Tty + } else if progress::stderr_is_terminal() { + ProgressTarget::Stderr + } else { + ProgressTarget::Hidden + } +} + +fn init_tracing(verbose: bool) { + use tracing_subscriber::{fmt, EnvFilter}; + // Default keeps INFO globally but suppresses per-set INFO from + // `download` so the live dashboard isn't repainted by every "download + // ok" line. RUST_LOG overrides everything; --verbose flips download + // back to INFO. + let default = if verbose { + "info,osu_fetcher=info" + } else { + "info,osu_fetcher=info,osu_fetcher::download=warn" + }; + let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(default)); + fmt() + .with_env_filter(filter) + .with_writer(std::io::stderr) + .init(); +} + +fn cmd_status(state: Arc) -> Result<()> { + let s = state.status_counts()?; + println!("wanted: {}", s.wanted); + println!("pending: {}", s.pending); + println!("in_progress: {}", s.in_progress); + println!("success: {}", s.success); + println!("failed: {}", s.failed); + println!("missing: {}", s.missing); + let queue = s.pending + s.in_progress; + println!("--"); + println!( + "queue (pending + in_progress): {queue} ({:.1}% of wanted)", + if s.wanted == 0 { + 0.0 + } else { + 100.0 * queue as f64 / s.wanted as f64 + } + ); + Ok(()) +} + +fn cmd_retry(state: Arc) -> Result<()> { + let n = state.reset_failed_to_pending()?; + println!("reset {n} failed/missing rows back to pending"); + Ok(()) +} + +async fn cmd_verify( + state: Arc, + archives_dir: &std::path::Path, + args: &VerifyArgs, + progress_enabled: bool, +) -> Result<()> { + let opts = AdaptiveVerifyOptions { + min_workers: args.min_workers.max(1), + max_workers: args.max_workers.max(args.min_workers.max(1)), + fixed_workers: args.workers, + fix: args.fix, + progress: progress_enabled, + }; + let stats = verify::run_adaptive(state, archives_dir, opts).await?; + if stats.aborted_remaining > 0 { + // Non-zero exit so scripts can detect a partial verify run. + std::process::exit(130); + } + Ok(()) +} + +async fn cmd_scan( + state: Arc, + archives_dir: &std::path::Path, + verify: bool, + progress_enabled: bool, +) -> Result<()> { + let spinner = CounterSpinner::new("scan", progress_enabled); + let stats = scan::scan_archives(state, archives_dir, verify, Some(&spinner)).await?; + spinner.finish(format!( + "done · seen {} · recorded {} · bad name {} · bad archive {}", + stats.seen, stats.recorded, stats.bad_name, stats.bad_archive + )); + println!( + "scan: seen={} recorded={} bad_name={} bad_archive={}", + stats.seen, stats.recorded, stats.bad_name, stats.bad_archive + ); + Ok(()) +} + +async fn cmd_enumerate( + state: Arc, + cli: &Cli, + args: &EnumerateArgs, + cfg: &Config, +) -> Result<()> { + let auth = build_osu_auth(cli, cfg)?; + info!(mode = auth.mode_label(), "osu! API auth configured"); + // Eager auth: do the password grant + any 2FA prompt up front so the + // dashboard doesn't render mid-prompt (and so missing creds fail fast). + let _ = auth + .current_token() + .await + .context("authenticating to osu! API")?; + let api = OsuApi::new(auth, RateLimited::per_minute("osu_api", cli.osu_rpm)); + + let progress_enabled = progress_enabled(cli); + let mut grand = EnumerateStats::default(); + for raw in &args.statuses { + let status: RankedStatus = raw + .parse() + .map_err(|e| anyhow!("--statuses {raw:?}: {e}"))?; + info!(status = status.as_api_str(), "enumerate begin"); + let spinner = CounterSpinner::new(status.as_api_str(), progress_enabled); + let stats = enumerate::enumerate_status( + api.clone(), + state.clone(), + status, + EnumerateOptions { + mode: args.mode, + max_pages: args.max_pages, + require_matching_mode_difficulty: !args.no_mode_filter, + full_rescan: args.full_rescan, + sort: args.sort.into(), + stateless: args.stateless, + }, + Some(&spinner), + ) + .await?; + spinner.finish(format!( + "done · pages {} · seen {} · upserted {} · skipped {}", + stats.pages, stats.seen, stats.upserted, stats.skipped_no_osu_mode, + )); + info!( + status = status.as_api_str(), + pages = stats.pages, + seen = stats.seen, + upserted = stats.upserted, + skipped = stats.skipped_no_osu_mode, + "enumerate done" + ); + grand.pages += stats.pages; + grand.seen += stats.seen; + grand.upserted += stats.upserted; + grand.skipped_no_osu_mode += stats.skipped_no_osu_mode; + } + println!( + "enumerate: pages={} seen={} upserted={} skipped_mode={}", + grand.pages, grand.seen, grand.upserted, grand.skipped_no_osu_mode + ); + Ok(()) +} + +async fn cmd_download( + state: Arc, + cli: &Cli, + args: &DownloadArgs, + cfg: &Config, +) -> Result<()> { + // Hold the run-lock for the lifetime of this download. OS releases it + // automatically on process exit (graceful, panic, SIGKILL, power-off) + // so a second `osu_fetcher download` started concurrently bails out + // cleanly instead of stomping on this run's claims. + let lock_path = lock_path_for(&cli.state_db); + let _lock = DownloadLock::acquire(&lock_path).context("acquiring download run lock")?; + info!(path = %lock_path.display(), "acquired download run lock"); + + // The dataset only ever wants the complete archive (video + storyboard + // + skin + hitsounds). The CLI used to expose a `--flavor` flag but + // it's gone now so a mid-run footgun can't pollute archives_dir with + // novideo variants. The `Flavor` enum stays in the library so mirror + // impls retain their flavor-aware URL builders for future use. + let flavor: Flavor = Flavor::Full; + // Build the osu! API client best-effort — the public mirrors don't + // need it, so missing credentials shouldn't fail `download`. If it + // builds, the `osuapi` mirror joins the pool; if not, it's skipped. + // We also eagerly mint a token here so any 2FA prompt happens *before* + // the dashboard takes over the screen — much friendlier than having + // a stdin prompt fight the live progress bar. + let osu_api = match build_osu_auth(cli, cfg) { + Ok(auth) => { + info!(mode = auth.mode_label(), "osu! API auth configured"); + match auth.current_token().await { + Ok(_) => Some(OsuApi::new( + auth, + RateLimited::per_minute("osu_api", cli.osu_rpm), + )), + Err(e) => { + warn!( + error = %e, + "osu! API authentication failed; osuapi mirror disabled for this run" + ); + None + } + } + } + Err(e) => { + warn!(error = %e, "osu! API credentials not configured; osuapi mirror disabled"); + None + } + }; + let pool = build_pool(cli, cfg, osu_api)?; + info!( + mirrors = ?pool.names(), + concurrency = args.concurrency, + flavor = flavor.as_str(), + "download begin" + ); + + let token = CancellationToken::new(); + let token_clone = token.clone(); + tokio::spawn(async move { + if tokio::signal::ctrl_c().await.is_ok() { + warn!("Ctrl-C received; signalling shutdown"); + token_clone.cancel(); + } + }); + + // Compute total *up front* so the bar has a real ceiling. We read the + // queue size after lock acquisition so it reflects what this run will + // actually attempt (including in_progress rows that requeue_in_progress + // will recover at the start of run()). + let total_pending = state + .count_pending_wanted() + .context("counting pending sets")?; + let total = match args.limit { + Some(lim) => lim.min(total_pending), + None => total_pending, + }; + let mirror_names = pool.names(); + let dashboard = DownloadDashboard::new( + total, + args.concurrency, + &mirror_names, + download_progress_target(cli), + ); + let tick_shutdown = CancellationToken::new(); + let tick_handle = progress::spawn_tick_task(dashboard.clone(), tick_shutdown.clone()); + + let stats = download::run( + state, + Arc::new(pool), + DownloadOptions { + archives_dir: cli.archives_dir.clone(), + flavor, + concurrency: args.concurrency, + limit: args.limit, + }, + token, + Some(dashboard.clone()), + ) + .await?; + + tick_shutdown.cancel(); + let _ = tick_handle.await; + dashboard.finalize(); + + println!( + "download: attempted={} success={} failed={} missing={} aborted={}", + stats.attempted, stats.success, stats.failed, stats.missing, stats.aborted + ); + Ok(()) +} + +async fn cmd_discover(state: Arc, cli: &Cli, args: &DiscoverArgs) -> Result<()> { + // Parse statuses up front so a typo in --statuses fails before we + // build the mirror pool and warm any HTTP connections. + let mut want_statuses: Vec = Vec::new(); + for raw in &args.statuses { + let s: RankedStatus = raw + .parse() + .map_err(|e| anyhow!("--statuses {raw:?}: {e}"))?; + if !want_statuses.contains(&s) { + want_statuses.push(s); + } + } + + let client = discover::build_client().context("build discover http client")?; + let limiters = DiscoverLimiters { + nerinyan: RateLimited::per_minute("nerinyan_search", args.nerinyan_search_rpm), + osudirect: RateLimited::per_minute("osudirect_search", args.osudirect_search_rpm), + sayobot: RateLimited::per_minute("sayobot_search", args.sayobot_search_rpm), + nekoha: RateLimited::per_minute("nekoha_search", args.nekoha_search_rpm), + }; + let ctx = DiscoverContext { client, limiters }; + + let disabled: Vec = args + .disable + .iter() + .map(|s| s.to_ascii_lowercase()) + .collect(); + let is_enabled = |name: &str| !disabled.iter().any(|d| d == &name.to_ascii_lowercase()); + + let mut search_sources: Vec> = Vec::new(); + if is_enabled("nerinyan") { + search_sources.push(Arc::new(NerinyanSearch::new(&ctx))); + } + if is_enabled("osudirect") { + search_sources.push(Arc::new(OsuDirectSearch::new(&ctx))); + } + if is_enabled("sayobot") { + search_sources.push(Arc::new(SayobotSearch::new(&ctx))); + } + + let mut verifiers: Vec> = Vec::new(); + if !args.no_verify { + if is_enabled("nekoha") { + verifiers.push(Arc::new(NekohaVerify::new(&ctx))); + } + if is_enabled("osudirect") { + verifiers.push(Arc::new(OsuDirectVerify::new(&ctx))); + } + if is_enabled("sayobot") { + verifiers.push(Arc::new(SayobotVerify::new(&ctx))); + } + } + + if search_sources.is_empty() { + anyhow::bail!("every discovery source is disabled; nothing to do"); + } + + let names: Vec<&str> = search_sources.iter().map(|m| m.name()).collect(); + info!(sources = ?names, statuses = ?args.statuses, quorum = args.min_quorum, + verifiers = verifiers.len(), "discover begin"); + + // We leak `want_statuses` only when we can't borrow it as a `&'static [RankedStatus]`. + // Since `DiscoverOptions::statuses` is `&'static`, build the slice from the + // default helper when the user passed exactly that set; otherwise box-and-leak. + let statuses_slice: &'static [RankedStatus] = leak_statuses(want_statuses); + + let opts = DiscoverOptions { + mode: args.mode, + max_pages_per_mirror_status: args.max_pages, + statuses: statuses_slice, + min_quorum: args.min_quorum, + consecutive_empty_break_pages: args.consecutive_empty_break_pages, + retry_attempts: args.retry_attempts, + }; + + // Same gating policy as the other long-running subcommands. When off, + // the spinners short-circuit to no-ops. + let progress_enabled = progress_enabled(cli); + + let stats = + discover::discover_all(state, &search_sources, &verifiers, opts, progress_enabled).await?; + println!( + "discover: pages={} reports={} sets_seen={} promoted={} sub_quorum={}", + stats.pages, + stats.reports_recorded, + stats.sets_seen, + stats.promoted_to_wanted, + stats.sub_quorum_candidates, + ); + Ok(()) +} + +/// Convert a runtime `Vec` into the `&'static [RankedStatus]` +/// `DiscoverOptions` expects. We deliberately leak — discover runs once +/// per process, and copying the small slice is cheaper than threading a +/// lifetime through the entire pipeline. +fn leak_statuses(s: Vec) -> &'static [RankedStatus] { + Box::leak(s.into_boxed_slice()) +} + +/// Lockfile lives next to the state DB so per-DB isolation is preserved +/// (a user running two distinct DBs on the same machine doesn't deadlock). +fn lock_path_for(state_db: &std::path::Path) -> PathBuf { + let mut p = state_db.to_path_buf(); + let new_name = match p.file_name().and_then(|s| s.to_str()) { + Some(n) => format!("{n}.run.lock"), + None => String::from(".fetcher.run.lock"), + }; + p.set_file_name(new_name); + p +} + +/// Pick an auth mode based on what credentials the user provided. +/// +/// Lazer mode (`username` + `password`) wins when both are present — +/// downloads only work with the user-scoped token it produces, and nothing +/// in the read-only enumeration path needs anything stricter than what +/// lazer-mode provides. We only fall back to client_credentials when the +/// user explicitly registered an OAuth app and *didn't* supply a login. +fn select_auth_mode(resolved: &ResolvedOsuCreds) -> Result { + if let (Some(u), Some(p)) = (resolved.username.as_deref(), resolved.password.as_deref()) { + return Ok(OsuAuthMode::LazerPassword { + username: u.to_string(), + password: p.to_string(), + }); + } + if let (Some(id), Some(secret)) = ( + resolved.client_id.as_deref(), + resolved.client_secret.as_deref(), + ) { + return Ok(OsuAuthMode::ClientCredentials { + client_id: id.to_string(), + client_secret: secret.to_string(), + }); + } + Err(anyhow!( + "no osu! API credentials configured. Provide either:\n \ + (a) [osu_api] username + password (or OSU_USERNAME / OSU_PASSWORD env vars) \ + — preferred; uses the lazer-impersonation flow and unlocks the \ + /api/v2/beatmapsets/{{id}}/download endpoint, or\n \ + (b) [osu_api] client_id + client_secret (or OSU_CLIENT_ID / OSU_CLIENT_SECRET) \ + — registered at https://osu.ppy.sh/home/account/edit#oauth; sufficient for \ + enumerate but not for the osuapi download mirror.\n\ + Config file expected at {}.", + config::DEFAULT_CONFIG_FILENAME + )) +} + +/// Default token-cache path: `.osu_token.json` next to the DB. +/// Kept beside the state DB so swapping `--state-db` between projects also +/// swaps the token file (different state DB = different "session"). +fn default_token_path(state_db: &std::path::Path) -> PathBuf { + let mut p = state_db.to_path_buf(); + let new_name = match p.file_name().and_then(|s| s.to_str()) { + Some(n) => format!("{n}.osu_token.json"), + None => String::from(".fetcher.osu_token.json"), + }; + p.set_file_name(new_name); + p +} + +fn build_osu_auth(cli: &Cli, cfg: &Config) -> Result> { + let resolved = cfg.osu_credentials(); + let mode = select_auth_mode(&resolved)?; + let token_file = Some( + cli.osu_token_file + .clone() + .unwrap_or_else(|| default_token_path(&cli.state_db)), + ); + OsuAuth::new(mode, token_file) +} + +fn build_pool(cli: &Cli, cfg: &Config, osu_api: Option>) -> Result { + let client = build_client().context("build reqwest client")?; + let limiters = MirrorLimiters { + nerinyan: RateLimited::per_minute("nerinyan", cli.nerinyan_rpm), + catboy: RateLimited::per_minute("catboy", cli.catboy_rpm), + sayobot: RateLimited::per_minute("sayobot", cli.sayobot_rpm), + nekoha: RateLimited::per_minute("nekoha", cli.nekoha_rpm), + beatconnect: RateLimited::per_minute("beatconnect", cli.beatconnect_rpm), + osudirect: RateLimited::per_minute("osudirect", cli.osudirect_rpm), + nzbasic: RateLimited::per_minute("nzbasic", cli.nzbasic_rpm), + osudl: RateLimited::per_minute("osudl", cli.osudl_rpm), + osuapi: RateLimited::per_minute("osuapi", cli.osuapi_rpm), + }; + let ctx = MirrorContext { + client, + limiters, + osu_api, + }; + + let disabled = cli + .disable + .iter() + .map(|s| s.to_ascii_lowercase()) + .collect::>(); + let is_enabled = |name: &str| !disabled.iter().any(|d| d == &name.to_ascii_lowercase()); + + let mut mirrors: Vec> = Vec::new(); + if is_enabled("nerinyan") { + mirrors.push(Arc::new(NerinyanMirror::new(&ctx))); + } + if is_enabled("catboy") { + mirrors.push(Arc::new(CatboyMirror::new(&ctx))); + } + if is_enabled("osudirect") { + mirrors.push(Arc::new(OsuDirectMirror::new(&ctx))); + } + if is_enabled("nekoha") { + mirrors.push(Arc::new(NekohaMirror::new(&ctx))); + } + if is_enabled("nzbasic") { + mirrors.push(Arc::new(NzbasicMirror::new(&ctx))); + } + if is_enabled("osudl") { + mirrors.push(Arc::new(OsudlMirror::new(&ctx))); + } + if is_enabled("sayobot") { + mirrors.push(Arc::new(SayobotMirror::new(&ctx))); + } + if is_enabled("beatconnect") { + match cfg.beatconnect_api_key() { + Some(key) => mirrors.push(Arc::new(BeatconnectMirror::new(&ctx, key))), + None => warn!( + "beatconnect skipped: no [mirrors.beatconnect].api_key in config and \ + BEATCONNECT_API_KEY env var is unset" + ), + } + } + if is_enabled("osuapi") { + match OsuApiMirror::new(&ctx) { + Some(m) => mirrors.push(Arc::new(m)), + None => warn!( + "osuapi skipped: no osu! API credentials available — set [osu_api] in \ + config or OSU_CLIENT_ID / OSU_CLIENT_SECRET to enable the official \ + download endpoint" + ), + } + } + + if mirrors.is_empty() { + anyhow::bail!("every mirror is disabled; nothing to do"); + } + let attempt_timeout = match cli.mirror_timeout_secs { + 0 => None, + s => Some(std::time::Duration::from_secs(s)), + }; + Ok(MirrorPool::with_attempt_timeout(mirrors, attempt_timeout)) +} diff --git a/crates/osu_fetcher/src/mirrors/beatconnect.rs b/crates/osu_fetcher/src/mirrors/beatconnect.rs new file mode 100644 index 0000000000000000000000000000000000000000..5dce06e107688333717940d0ec838956367e82ab --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/beatconnect.rs @@ -0,0 +1,99 @@ +//! beatconnect.io — requires an API key passed via `token` query parameter. +//! +//! Endpoints (per ): +//! * `GET https://beatconnect.io/b/{set_id}?token=` — full archive +//! * No documented "novideo" variant; we only register `Full` support. +//! +//! beatconnect tends to be slower than the other mirrors and carries a +//! historical archive that occasionally has maps the others don't. It earns a +//! place in the fallback chain but should be ranked last by default so we +//! don't burn its rate budget when faster mirrors would have served the file. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "beatconnect"; +const BASE: &str = "https://beatconnect.io/b"; + +pub struct BeatconnectMirror { + client: Client, + limiter: RateLimited, + api_key: String, +} + +impl BeatconnectMirror { + pub fn new(ctx: &MirrorContext, api_key: String) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.beatconnect.clone(), + api_key, + } + } + + pub fn url(set_id: u64, api_key: &str) -> String { + // The API key goes via a query parameter so it survives 30x redirect + // bounces (some headers don't). Tokens are scoped to the user's + // account and are not bearer-grade — exposing them in a URL is the + // documented usage. + format!("{BASE}/{set_id}?token={api_key}") + } +} + +#[async_trait] +impl Mirror for BeatconnectMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, flavor: Flavor) -> bool { + matches!(flavor, Flavor::Full) + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + if !self.supports(flavor) { + return Err(MirrorError::UnsupportedFlavor { + mirror: NAME.into(), + flavor, + }); + } + self.limiter.acquire().await; + let url = Self::url(set_id, &self.api_key); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_includes_token_in_query_string() { + let url = BeatconnectMirror::url(789, "deadbeef"); + assert_eq!(url, "https://beatconnect.io/b/789?token=deadbeef"); + } + + #[test] + fn novideo_is_not_supported() { + // The mirror impl needs a `MirrorContext` to construct, which means a + // live `RateLimited`; we exercise the static `supports` predicate + // through a thin wrapper that doesn't hit the network. + let supports_full = matches!(Flavor::Full, Flavor::Full); + let supports_novideo = matches!(Flavor::NoVideo, Flavor::Full); + assert!(supports_full); + assert!(!supports_novideo); + } +} diff --git a/crates/osu_fetcher/src/mirrors/catboy.rs b/crates/osu_fetcher/src/mirrors/catboy.rs new file mode 100644 index 0000000000000000000000000000000000000000..908a4f5d0d473af731ae8261f6018a638ef9e487 --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/catboy.rs @@ -0,0 +1,87 @@ +//! catboy.best — public mirror (operated by osu.direct), no auth required. +//! +//! Endpoint: +//! * `GET https://catboy.best/d/{set_id}` — full archive +//! * `GET https://catboy.best/d/{set_id}n` — novideo (suffix `n` selects) +//! +//! catboy serves both flavors via the same path style; the URL form is the +//! only difference. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "catboy"; +const BASE: &str = "https://catboy.best/d"; + +pub struct CatboyMirror { + client: Client, + limiter: RateLimited, +} + +impl CatboyMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.catboy.clone(), + } + } + + pub fn url(set_id: u64, flavor: Flavor) -> String { + match flavor { + Flavor::Full => format!("{BASE}/{set_id}"), + Flavor::NoVideo => format!("{BASE}/{set_id}n"), + } + } +} + +#[async_trait] +impl Mirror for CatboyMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + true + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id, flavor); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_uses_plain_id() { + assert_eq!( + CatboyMirror::url(123, Flavor::Full), + "https://catboy.best/d/123" + ); + } + + #[test] + fn url_novideo_appends_n_suffix() { + assert_eq!( + CatboyMirror::url(123, Flavor::NoVideo), + "https://catboy.best/d/123n" + ); + } +} diff --git a/crates/osu_fetcher/src/mirrors/mod.rs b/crates/osu_fetcher/src/mirrors/mod.rs new file mode 100644 index 0000000000000000000000000000000000000000..0810b3d6c1dfccbd282f0e3ba376f7eee47188a6 --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/mod.rs @@ -0,0 +1,1138 @@ +//! Mirror abstraction + pool. +//! +//! Every concrete download mirror implements [`Mirror`] and is pushed into a +//! [`MirrorPool`]. The pool tries mirrors in priority order; on a recoverable +//! failure (any error other than [`MirrorError::Aborted`]) it advances to the +//! next mirror. Each individual attempt — success or failure — is reported +//! via [`AttemptRecord`] so the caller can log it to the state DB without the +//! pool having to know about persistence. +//! +//! Mirrors are *I/O-only*: they own a [`reqwest::Client`] and a +//! [`crate::ratelimit::RateLimited`] keyed on the mirror's name. They never +//! touch the filesystem or the state DB. This keeps each mirror impl small +//! enough to test by stubbing the URL through a wiremock server. + +use std::sync::Arc; +use std::sync::Mutex; +use std::time::Duration; + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::{Client, StatusCode}; +use thiserror::Error; +use tokio::time::Instant; + +use crate::api::OsuApi; +use crate::ratelimit::RateLimited; +use crate::verify::verify_bytes; +use crate::Flavor; + +pub mod beatconnect; +pub mod catboy; +pub mod nekoha; +pub mod nerinyan; +pub mod nzbasic; +pub mod osuapi; +pub mod osudirect; +pub mod osudl; +pub mod sayobot; + +#[derive(Debug, Error)] +pub enum MirrorError { + /// Server-confirmed: this set isn't here. Try next mirror. + #[error("not found on {mirror}")] + NotFound { mirror: String }, + + /// Server told us to slow down. The wrapper records this and tries the + /// next mirror; the limiter on this mirror will catch up via natural + /// pacing on the next iteration. + #[error("{mirror} rate limited")] + RateLimited { mirror: String }, + + /// Anything other than 2xx/404/429. + #[error("{mirror} returned HTTP {status}")] + HttpError { + mirror: String, + status: u16, + body_snippet: String, + }, + + /// Connection errors, timeouts, DNS, TLS — any pre-response failure. + #[error("{mirror} network error: {source}")] + Network { + mirror: String, + #[source] + source: reqwest::Error, + }, + + /// We got bytes back but they don't look like a `.osz` (no ZIP magic, or + /// truncated, or HTML error page slipped through). Treated as a recoverable + /// failure; try next mirror. + #[error("{mirror} returned invalid archive: {reason}")] + InvalidArchive { mirror: String, reason: String }, + + /// The mirror declines this flavor (e.g., novideo-only mirror with a + /// `Full` request). Try the next mirror without recording an attempt as + /// a failure. + #[error("{mirror} does not serve {flavor:?}")] + UnsupportedFlavor { mirror: String, flavor: Flavor }, + + /// Per-attempt wallclock deadline expired before the mirror returned a + /// response. Treated as a hard failure (try next mirror; penalize this + /// mirror's health like a Network error). The pool, not the individual + /// mirror, enforces this — mirrors all share the same per-call deadline. + #[error("{mirror} timed out after {after_secs}s")] + Timeout { mirror: String, after_secs: u64 }, + + /// Caller-side cancel. Stop the pool entirely. + #[error("download aborted")] + Aborted, +} + +impl MirrorError { + pub fn mirror_name(&self) -> &str { + match self { + MirrorError::NotFound { mirror } + | MirrorError::RateLimited { mirror } + | MirrorError::HttpError { mirror, .. } + | MirrorError::Network { mirror, .. } + | MirrorError::InvalidArchive { mirror, .. } + | MirrorError::Timeout { mirror, .. } + | MirrorError::UnsupportedFlavor { mirror, .. } => mirror, + MirrorError::Aborted => "(none)", + } + } +} + +/// Result of one HTTP attempt against a single mirror. +#[derive(Debug)] +pub struct AttemptRecord { + pub mirror: String, + pub duration: Duration, + pub http_status: Option, + pub bytes: Option, + pub error: Option, + pub outcome: AttemptOutcome, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum AttemptOutcome { + Success, + NotFound, + HttpError, + RateLimited, + Network, + InvalidArchive, + /// Mirror call exceeded the pool's per-attempt deadline. + Timeout, + UnsupportedFlavor, +} + +#[async_trait] +pub trait Mirror: Send + Sync { + fn name(&self) -> &str; + + /// True if this mirror can serve the requested flavor. If false, the pool + /// short-circuits to `MirrorError::UnsupportedFlavor` before any HTTP. + fn supports(&self, flavor: Flavor) -> bool; + + /// Fetch one beatmapset's `.osz` bytes. + async fn download(&self, set_id: u64, flavor: Flavor) -> Result; +} + +/// Lightweight observer plugged into the pool's per-attempt loop so an +/// outside watcher (the live dashboard) can track which mirrors are +/// currently in-flight without the pool having to know about progress UI. +/// Both methods default to no-op so non-observing callers can ignore it. +pub trait AttemptObserver: Send + Sync { + fn before_attempt(&self, _mirror: &str) {} + fn after_attempt(&self, _mirror: &str) {} +} + +/// Used by `MirrorPool::download` when no observer is provided. +pub struct NoOpObserver; +impl AttemptObserver for NoOpObserver {} + +/// Per-mirror health snapshot used by the selector. Held under a single +/// pool-wide `Mutex` — selection is fast (≤5 floats per call) and +/// updates are once-per-attempt, so contention is irrelevant compared to +/// the network round-trip. +#[derive(Clone, Debug)] +struct MirrorHealth { + /// EWMA of "did this attempt succeed". Range [0, 1]. Starts at 1.0 so + /// untested mirrors get the benefit of the doubt. + score: f64, + /// EWMA of successful-attempt latency in milliseconds. 0 = unknown. + /// Kept for diagnostics; not used in the selection weight (latency is + /// confounded with archive size; we use bandwidth instead). + avg_latency_ms: f64, + /// EWMA of throughput across successful attempts, in bytes/sec. + /// 0.0 = unknown — fresh mirrors get a neutral default in `weight()` + /// so they get fair attempts before being judged. This is the *real* + /// "is this mirror fast" metric: a mirror downloading 50 MB sets in + /// 5s has the same bandwidth as one downloading 5 MB sets in 0.5s, + /// even though their per-request latencies differ 10×. + avg_bandwidth_bps: f64, + /// Total attempts we've recorded — used to gate the "dormant" + /// classification so a single failure on a fresh mirror doesn't kill it. + attempts: u32, + /// Consecutive non-success non-NotFound outcomes. Resets to 0 on any + /// success or NotFound (NotFound = mirror is alive, just doesn't have + /// this set; not a health signal). + consecutive_hard_failures: u32, + /// Smooth weighted round-robin: accumulator for selection. + swrr_current: f64, +} + +impl MirrorHealth { + fn fresh() -> Self { + Self { + score: 1.0, + avg_latency_ms: 0.0, + avg_bandwidth_bps: 0.0, + attempts: 0, + consecutive_hard_failures: 0, + swrr_current: 0.0, + } + } + + /// Composite weight used for selection. Higher = more attractive. + /// `score²` (sharply punishes flaky mirrors) × `bandwidth_mbps` + /// (rewards fast throughput). Untested mirrors get a neutral + /// bandwidth default of 2 MiB/s so they aren't starved before + /// they've had a chance to demonstrate themselves. + fn weight(&self) -> f64 { + let bw_mibps = if self.avg_bandwidth_bps > 0.0 { + // Floor at 0.1 MiB/s so a single very-slow request doesn't + // make the weight collapse to ~0; we still want to rotate + // through and re-measure occasionally. + (self.avg_bandwidth_bps / 1_048_576.0).max(0.1) + } else { + 2.0 + }; + let raw = self.score * self.score * bw_mibps; + if self.is_dormant() { + // Dormant mirrors still get a small probe weight so we can + // detect recovery. Tuned so a single dormant mirror in a + // 5-mirror pool gets ~1–2% of starts. + 0.05_f64.min(raw) + } else { + raw + } + } + + /// Treat as dormant after enough probes confirm consistent failure. + /// Note: `attempts >= 5` gates this so a single transient burst on a + /// new mirror can't sideline it permanently. + fn is_dormant(&self) -> bool { + self.attempts >= 5 && self.score < 0.10 + } +} + +pub struct MirrorPool { + mirrors: Vec>, + /// All selection state lives behind a single mutex. Selection is fast + /// (≤5 mirrors × a few floats); contention here is dwarfed by the + /// network round-trip that follows. + state: Mutex, + /// Per-attempt wallclock budget. `None` falls back to whatever timeout + /// the underlying reqwest client uses; `Some(d)` aborts the mirror call + /// after `d` regardless of where it stalled (DNS, TLS, headers, body). + /// This is what stops a single hung mirror from holding a worker for + /// the full 120s reqwest ceiling while six healthy mirrors sit idle. + attempt_timeout: Option, +} + +struct PoolState { + health: Vec, +} + +/// Public snapshot returned by [`MirrorPool::health_snapshot`]. +#[derive(Clone, Debug)] +pub struct MirrorHealthSnapshot { + pub name: String, + pub score: f64, + pub avg_latency_ms: f64, + pub avg_bandwidth_bps: f64, + pub dormant: bool, +} + +impl MirrorPool { + pub fn new(mirrors: Vec>) -> Self { + Self::with_attempt_timeout(mirrors, None) + } + + /// Build a pool that aborts any single mirror call exceeding + /// `attempt_timeout`. Pass `None` to disable (rely only on the reqwest + /// client's own timeout). When a deadline fires the chain advances to + /// the next mirror just like any other recoverable failure. + pub fn with_attempt_timeout( + mirrors: Vec>, + attempt_timeout: Option, + ) -> Self { + let n = mirrors.len(); + Self { + mirrors, + state: Mutex::new(PoolState { + health: (0..n).map(|_| MirrorHealth::fresh()).collect(), + }), + attempt_timeout, + } + } + + pub fn names(&self) -> Vec<&str> { + self.mirrors.iter().map(|m| m.name()).collect() + } + + pub fn is_empty(&self) -> bool { + self.mirrors.is_empty() + } + + /// Snapshot of per-mirror health: `(name, score, avg_latency_ms, + /// avg_bandwidth_bps, dormant)`. Useful for the live dashboard or + /// "why is X being skipped" diagnostics. + pub fn health_snapshot(&self) -> Vec { + let state = self.state.lock().unwrap_or_else(|e| e.into_inner()); + self.mirrors + .iter() + .zip(&state.health) + .map(|(m, h)| MirrorHealthSnapshot { + name: m.name().to_string(), + score: h.score, + avg_latency_ms: h.avg_latency_ms, + avg_bandwidth_bps: h.avg_bandwidth_bps, + dormant: h.is_dormant(), + }) + .collect() + } + + /// Pick the order in which to try mirrors for the next request. + /// + /// 1. The first slot is chosen via *smooth weighted round-robin* — + /// each call increments per-mirror SWRR accumulators by their + /// health weight, picks the max, decrements by the total weight. + /// Over many calls this gives each mirror a share of starts + /// proportional to its weight, but interleaved smoothly rather + /// than in bursty runs. + /// 2. The remaining slots are filled in *descending weight* order so + /// that fall-through after a transient failure still goes to the + /// healthiest available mirror, not whatever happens to be next + /// in the Vec. + /// 3. Dormant mirrors are placed last in the chain (so a healthy + /// chain doesn't usually reach them) but still included — if + /// every healthy mirror returns NotFound, we want to ask the + /// dormant ones too before declaring the set missing. + fn build_chain(&self) -> Vec { + let n = self.mirrors.len(); + let mut state = self.state.lock().unwrap_or_else(|e| e.into_inner()); + + // Compute current weights. + let weights: Vec = state.health.iter().map(|h| h.weight()).collect(); + let total: f64 = weights.iter().sum(); + if total <= 0.0 { + // Pathological: every mirror is dormant with weight 0. Just + // serve them in declared order so the chain isn't empty. + return (0..n).collect(); + } + + // SWRR: bump every accumulator by its weight, then pick max. + for (i, w) in weights.iter().enumerate() { + state.health[i].swrr_current += w; + } + // Tie-break by *lower* index so ordering matches the Vec when + // every mirror has equal weight (e.g., a fresh pool's first + // request). `Iterator::max_by` returns the last element on ties, + // which would invert that — so we walk manually with strict `>`. + let mut start = 0; + let mut max_swrr = state.health[0].swrr_current; + for i in 1..state.health.len() { + if state.health[i].swrr_current > max_swrr { + max_swrr = state.health[i].swrr_current; + start = i; + } + } + state.health[start].swrr_current -= total; + + // Build remaining order: healthy by weight desc, then dormant. + let mut others: Vec = (0..n).filter(|i| *i != start).collect(); + others.sort_by(|a, b| { + let ad = state.health[*a].is_dormant(); + let bd = state.health[*b].is_dormant(); + // dormant after non-dormant + if ad != bd { + return ad.cmp(&bd); + } + // within group, higher weight first + weights[*b] + .partial_cmp(&weights[*a]) + .unwrap_or(std::cmp::Ordering::Equal) + }); + let mut chain = Vec::with_capacity(n); + chain.push(start); + chain.extend(others); + chain + } + + fn record_outcome( + &self, + idx: usize, + outcome: AttemptOutcome, + latency: Duration, + bytes: Option, + ) { + let mut state = self.state.lock().unwrap_or_else(|e| e.into_inner()); + let h = &mut state.health[idx]; + h.attempts = h.attempts.saturating_add(1); + match outcome { + AttemptOutcome::Success => { + // Mirror healthy → score climbs back toward 1.0 quickly + // so a previously-dormant mirror that recovers via probe + // rejoins the rotation within a few requests. + h.score = 0.7 * h.score + 0.3 * 1.0; + let now = latency.as_millis() as f64; + h.avg_latency_ms = if h.avg_latency_ms == 0.0 { + now + } else { + 0.7 * h.avg_latency_ms + 0.3 * now + }; + // Record observed throughput from this attempt — only + // signal we can compare across mirrors that's invariant + // to the size of the set being fetched. Skip degenerate + // cases (empty body or sub-millisecond timing) so a + // single weird request doesn't poison the EWMA. + if let Some(b) = bytes { + let secs = latency.as_secs_f64(); + if b > 0 && secs > 0.001 { + let bps = b as f64 / secs; + h.avg_bandwidth_bps = if h.avg_bandwidth_bps == 0.0 { + bps + } else { + 0.7 * h.avg_bandwidth_bps + 0.3 * bps + }; + } + } + h.consecutive_hard_failures = 0; + } + AttemptOutcome::NotFound => { + // Mirror is alive and answered correctly — they just + // don't host this set. No score change. We still reset + // the consecutive-hard-failure counter (the mirror is + // demonstrably responsive). + h.consecutive_hard_failures = 0; + } + AttemptOutcome::InvalidArchive => { + // Light penalty: invalid bytes can be a transient + // mid-update glitch on the mirror, not necessarily a + // dead host. (Per design note: "invalid doesn't mean + // dead.") Multiplier 0.92 means a mirror needs roughly + // 25 consecutive invalids to fall to score 0.10 — so a + // few flaky responses don't sideline a working mirror. + h.score = 0.92 * h.score; + h.consecutive_hard_failures = h.consecutive_hard_failures.saturating_add(1); + } + AttemptOutcome::RateLimited + | AttemptOutcome::HttpError + | AttemptOutcome::Network + | AttemptOutcome::Timeout => { + // Hard failures: 0.7 multiplier means ~7 consecutive + // hard failures drops score below the dormant threshold + // (0.10). RateLimited is in here intentionally — 429 + // means our pacing is wrong for this mirror, so we want + // fewer fresh starts there until headroom recovers. + // Timeout is grouped with Network because they're the + // same signal: this mirror is unresponsive *right now*. + h.score = 0.7 * h.score; + h.consecutive_hard_failures = h.consecutive_hard_failures.saturating_add(1); + } + AttemptOutcome::UnsupportedFlavor => { + // Carries no health information — no update. + } + } + } + + /// Backward-compatible entry point — equivalent to + /// [`download_with_observer`] using a no-op observer. + pub async fn download( + &self, + set_id: u64, + flavor: Flavor, + ) -> (Result<(String, Bytes), MirrorError>, Vec) { + self.download_with_observer(set_id, flavor, &NoOpObserver) + .await + } + + /// Try mirrors in health-aware order. Returns: + /// * `Ok((mirror_name, bytes, attempts))` — first success. + /// * `Err((last_error, attempts))` — every mirror was tried and none + /// produced bytes. `attempts` is in the order tried. + /// + /// `NotFound` from every mirror is reported as `MirrorError::NotFound` + /// so the caller can mark the set as `missing` rather than `failed`. + pub async fn download_with_observer( + &self, + set_id: u64, + flavor: Flavor, + observer: &O, + ) -> (Result<(String, Bytes), MirrorError>, Vec) { + let n = self.mirrors.len(); + let mut attempts = Vec::with_capacity(n); + let mut last_err = MirrorError::Aborted; + let mut all_not_found = true; + if n == 0 { + return (Err(MirrorError::Aborted), attempts); + } + + for idx in self.build_chain() { + let mirror = &self.mirrors[idx]; + let name = mirror.name().to_string(); + if !mirror.supports(flavor) { + attempts.push(AttemptRecord { + mirror: name.clone(), + duration: Duration::ZERO, + http_status: None, + bytes: None, + error: Some(format!("does not serve {flavor:?}")), + outcome: AttemptOutcome::UnsupportedFlavor, + }); + last_err = MirrorError::UnsupportedFlavor { + mirror: name, + flavor, + }; + all_not_found = false; + continue; + } + + observer.before_attempt(&name); + let started = Instant::now(); + let result = match self.attempt_timeout { + Some(d) => match tokio::time::timeout(d, mirror.download(set_id, flavor)).await { + Ok(r) => r, + Err(_elapsed) => Err(MirrorError::Timeout { + mirror: name.clone(), + after_secs: d.as_secs(), + }), + }, + None => mirror.download(set_id, flavor).await, + }; + let elapsed = started.elapsed(); + observer.after_attempt(&name); + + match result { + Ok(bytes) => { + self.record_outcome( + idx, + AttemptOutcome::Success, + elapsed, + Some(bytes.len() as u64), + ); + attempts.push(AttemptRecord { + mirror: name.clone(), + duration: elapsed, + http_status: Some(200), + bytes: Some(bytes.len() as u64), + error: None, + outcome: AttemptOutcome::Success, + }); + return (Ok((name, bytes)), attempts); + } + Err(err) => { + let outcome = match &err { + MirrorError::NotFound { .. } => AttemptOutcome::NotFound, + MirrorError::RateLimited { .. } => AttemptOutcome::RateLimited, + MirrorError::HttpError { .. } => AttemptOutcome::HttpError, + MirrorError::Network { .. } => AttemptOutcome::Network, + MirrorError::InvalidArchive { .. } => AttemptOutcome::InvalidArchive, + MirrorError::Timeout { .. } => AttemptOutcome::Timeout, + MirrorError::UnsupportedFlavor { .. } => AttemptOutcome::UnsupportedFlavor, + MirrorError::Aborted => { + attempts.push(AttemptRecord { + mirror: name, + duration: elapsed, + http_status: None, + bytes: None, + error: Some("aborted".into()), + outcome: AttemptOutcome::Network, + }); + return (Err(MirrorError::Aborted), attempts); + } + }; + self.record_outcome(idx, outcome, elapsed, None); + let http_status = match &err { + MirrorError::HttpError { status, .. } => Some(*status), + MirrorError::RateLimited { .. } => Some(429), + MirrorError::NotFound { .. } => Some(404), + _ => None, + }; + attempts.push(AttemptRecord { + mirror: name, + duration: elapsed, + http_status, + bytes: None, + error: Some(err.to_string()), + outcome, + }); + if !matches!(err, MirrorError::NotFound { .. }) { + all_not_found = false; + } + last_err = err; + } + } + } + + // Every mirror was tried. If literally every result was 404, + // promote to a "missing" signal so the caller can move the set + // to the `missing` terminal state instead of retrying as + // `failed`. + if all_not_found && !attempts.is_empty() { + ( + Err(MirrorError::NotFound { + mirror: "(all)".into(), + }), + attempts, + ) + } else { + (Err(last_err), attempts) + } + } +} + +/// Construct the User-Agent we send to every mirror. Includes a contact hint +/// so a mirror op who notices us can ask us to back off rather than silently +/// blocking. +pub fn user_agent() -> String { + format!( + "osu_fetcher/{} (osu-everything dataset; lekdan/osu-everything)", + env!("CARGO_PKG_VERSION") + ) +} + +/// Build a reqwest client preconfigured with timeouts + decompression. +/// +/// We share these knobs across every mirror; per-mirror tuning is handled by +/// the rate limiter, not by the client config. +pub fn build_client() -> Result { + Client::builder() + .user_agent(user_agent()) + .timeout(Duration::from_secs(120)) + .pool_idle_timeout(Duration::from_secs(60)) + .gzip(true) + .brotli(true) + .build() +} + +/// Common helper used by every mirror: convert a finished `reqwest::Response` +/// into the right `MirrorError` variant. Caller has already done the GET. +/// +/// On 2xx, the body is buffered into memory and *deep-verified* — the bytes +/// must parse as a ZIP and contain at least one `.osu` file. This catches +/// mirrors that respond 200 with a status page, a truncated zip, or any +/// shape that wouldn't survive ingestion. The `MirrorPool` treats +/// `InvalidArchive` as a recoverable failure and tries the next mirror, so +/// shoving the deep check up here is what makes mirror failover actually +/// reliable. +pub async fn classify_response( + mirror: &str, + resp: reqwest::Response, +) -> Result { + let status = resp.status(); + if status.is_success() { + let bytes = resp.bytes().await.map_err(|e| MirrorError::Network { + mirror: mirror.into(), + source: e, + })?; + if let Err(e) = verify_bytes(&bytes) { + return Err(MirrorError::InvalidArchive { + mirror: mirror.into(), + reason: e.to_string(), + }); + } + return Ok(bytes); + } + if status == StatusCode::NOT_FOUND { + return Err(MirrorError::NotFound { + mirror: mirror.into(), + }); + } + if status == StatusCode::TOO_MANY_REQUESTS { + return Err(MirrorError::RateLimited { + mirror: mirror.into(), + }); + } + let body = resp.text().await.unwrap_or_default(); + let snippet: String = body.chars().take(200).collect(); + Err(MirrorError::HttpError { + mirror: mirror.into(), + status: status.as_u16(), + body_snippet: snippet, + }) +} + +/// Bundle of construction inputs every mirror takes. Avoids 5x the same +/// `(client, rate_limiter)` argument list at every call site. +/// +/// `osu_api` is optional because not every subcommand has credentials — +/// the public mirrors don't need it; only [`osuapi::OsuApiMirror`] does. +/// When it's `None` the caller skips constructing that mirror. +#[derive(Clone)] +pub struct MirrorContext { + pub client: Client, + pub limiters: MirrorLimiters, + pub osu_api: Option>, +} + +/// Per-mirror rate limit configuration, all in requests/minute. +#[derive(Clone)] +pub struct MirrorLimiters { + pub nerinyan: RateLimited, + pub catboy: RateLimited, + pub sayobot: RateLimited, + pub nekoha: RateLimited, + pub beatconnect: RateLimited, + pub osudirect: RateLimited, + pub nzbasic: RateLimited, + pub osudl: RateLimited, + pub osuapi: RateLimited, +} + +#[cfg(test)] +mod tests { + use super::*; + + struct StubMirror { + name: &'static str, + outcome: StubOutcome, + flavors: Vec, + } + + enum StubOutcome { + Bytes(Bytes), + NotFound, + Error(String), + } + + #[async_trait] + impl Mirror for StubMirror { + fn name(&self) -> &str { + self.name + } + fn supports(&self, f: Flavor) -> bool { + self.flavors.contains(&f) + } + async fn download(&self, _set_id: u64, _flavor: Flavor) -> Result { + match &self.outcome { + StubOutcome::Bytes(b) => Ok(b.clone()), + StubOutcome::NotFound => Err(MirrorError::NotFound { + mirror: self.name.into(), + }), + StubOutcome::Error(msg) => Err(MirrorError::HttpError { + mirror: self.name.into(), + status: 500, + body_snippet: msg.clone(), + }), + } + } + } + + #[tokio::test] + async fn pool_returns_first_success() { + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "first", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "second", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04ok")), + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "third", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04unused")), + flavors: vec![Flavor::Full], + }), + ]); + let (result, attempts) = pool.download(123, Flavor::Full).await; + let (mirror, bytes) = result.expect("expected success"); + assert_eq!(mirror, "second"); + assert_eq!(&bytes[..4], b"PK\x03\x04"); + assert_eq!(attempts.len(), 2); + assert_eq!(attempts[0].outcome, AttemptOutcome::NotFound); + assert_eq!(attempts[1].outcome, AttemptOutcome::Success); + } + + #[tokio::test] + async fn pool_advances_past_5xx_to_a_working_mirror() { + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "broken", + outcome: StubOutcome::Error("upstream meltdown".into()), + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "good", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04ok")), + flavors: vec![Flavor::Full], + }), + ]); + let (result, attempts) = pool.download(7, Flavor::Full).await; + let (mirror, _) = result.expect("expected eventual success"); + assert_eq!(mirror, "good"); + assert_eq!(attempts[0].outcome, AttemptOutcome::HttpError); + assert_eq!(attempts[0].http_status, Some(500)); + assert_eq!(attempts[1].outcome, AttemptOutcome::Success); + } + + #[tokio::test] + async fn pool_exhausts_all_supported_mirrors_before_failing() { + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "first-broken", + outcome: StubOutcome::Error("first".into()), + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "missing", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "last-broken", + outcome: StubOutcome::Error("last".into()), + flavors: vec![Flavor::Full], + }), + ]); + let (result, attempts) = pool.download(7, Flavor::Full).await; + assert!(matches!(result, Err(MirrorError::HttpError { .. }))); + assert_eq!(attempts.len(), 3); + let names: Vec<&str> = attempts.iter().map(|a| a.mirror.as_str()).collect(); + assert!(names.contains(&"first-broken")); + assert!(names.contains(&"missing")); + assert!(names.contains(&"last-broken")); + } + + #[tokio::test] + async fn pool_promotes_all_404_to_not_found() { + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "a", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "b", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + ]); + let (result, attempts) = pool.download(123, Flavor::Full).await; + let err = result.unwrap_err(); + assert!(matches!(err, MirrorError::NotFound { .. })); + assert_eq!(attempts.len(), 2); + } + + #[tokio::test] + async fn pool_rotates_starting_mirror_when_health_is_equal() { + // All three mirrors return NotFound — that's a *neutral* signal, + // so health stays equal across all three. With equal weights, + // smooth weighted round-robin degenerates to plain round-robin. + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "a", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "b", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "c", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + ]); + + let mut starts = Vec::new(); + for _ in 0..6 { + let (_, attempts) = pool.download(1, Flavor::Full).await; + starts.push(attempts[0].mirror.clone()); + // Sanity: every call should still try all 3 mirrors. + assert_eq!(attempts.len(), 3); + } + // Six calls × three mirrors with equal weights → each gets two starts. + let mut counts = std::collections::HashMap::new(); + for s in &starts { + *counts.entry(s.clone()).or_insert(0) += 1; + } + for name in ["a", "b", "c"] { + assert_eq!( + counts.get(name).copied().unwrap_or(0), + 2, + "mirror {name} should start twice; got {counts:?}" + ); + } + } + + #[tokio::test] + async fn pool_dormant_mirror_stops_being_picked_as_start() { + // Five attempts of consecutive HTTP errors crosses the dormant + // threshold. Once dormant, the bad mirror should rarely be the + // *starting* choice; the healthy mirror should dominate starts. + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "broken", + outcome: StubOutcome::Error("upstream meltdown".into()), + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "good", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04ok")), + flavors: vec![Flavor::Full], + }), + ]); + + // Warm up: do 30 calls so health stats stabilize. After this, + // `broken` should be dormant and `good` should be the routine + // starter. + for _ in 0..30 { + let _ = pool.download(1, Flavor::Full).await; + } + + // Now check the next 20 starts: at most a handful (the probe + // budget) should hit `broken` first. + let mut broken_starts = 0; + for _ in 0..20 { + let (_, attempts) = pool.download(1, Flavor::Full).await; + if attempts[0].mirror == "broken" { + broken_starts += 1; + } + } + assert!( + broken_starts <= 3, + "expected dormant 'broken' to rarely be picked as start; got {broken_starts}/20" + ); + } + + #[tokio::test] + async fn pool_invalid_archive_does_not_immediately_dormant() { + // The user explicitly requested: invalid_archive should be a + // *light* penalty, not a death sentence. Two invalids in a row + // shouldn't sideline the mirror. + struct InvalidThenOk { + count: std::sync::atomic::AtomicU32, + } + #[async_trait] + impl Mirror for InvalidThenOk { + fn name(&self) -> &str { + "flaky" + } + fn supports(&self, _: Flavor) -> bool { + true + } + async fn download(&self, _: u64, _: Flavor) -> Result { + let c = self + .count + .fetch_add(1, std::sync::atomic::Ordering::Relaxed); + if c < 2 { + Err(MirrorError::InvalidArchive { + mirror: "flaky".into(), + reason: "test".into(), + }) + } else { + Ok(Bytes::from_static(b"PK\x03\x04ok")) + } + } + } + + let pool = MirrorPool::new(vec![Arc::new(InvalidThenOk { + count: std::sync::atomic::AtomicU32::new(0), + })]); + + // Two invalids — should not be dormant after. + let _ = pool.download(1, Flavor::Full).await; + let _ = pool.download(1, Flavor::Full).await; + let snap = pool.health_snapshot(); + assert!( + !snap[0].dormant, + "two invalids alone should not dormant a mirror" + ); + assert!( + snap[0].score > 0.5, + "score after 2 invalids should still be >0.5; got {}", + snap[0].score + ); + + // Subsequent attempt succeeds; score recovers. + let (result, _) = pool.download(1, Flavor::Full).await; + assert!(result.is_ok()); + } + + #[tokio::test] + async fn pool_records_bandwidth_from_successful_attempts() { + // A mirror that returns 1 MB after a synthetic 100 ms delay → 10 MiB/s. + struct FixedSizeMirror { + bytes: usize, + delay: Duration, + } + #[async_trait] + impl Mirror for FixedSizeMirror { + fn name(&self) -> &str { + "fixed" + } + fn supports(&self, _: Flavor) -> bool { + true + } + async fn download(&self, _: u64, _: Flavor) -> Result { + tokio::time::sleep(self.delay).await; + Ok(Bytes::from(vec![0u8; self.bytes])) + } + } + + let pool = MirrorPool::new(vec![Arc::new(FixedSizeMirror { + bytes: 1024 * 1024, + delay: Duration::from_millis(100), + })]); + // Run a few times so the EWMA stabilizes. + for _ in 0..3 { + let _ = pool.download(1, Flavor::Full).await; + } + let snap = pool.health_snapshot(); + let bw_mibps = snap[0].avg_bandwidth_bps / 1_048_576.0; + // 1 MiB / 0.1s = 10 MiB/s. Allow generous tolerance for runtime jitter. + assert!( + bw_mibps > 4.0 && bw_mibps < 30.0, + "expected ~10 MiB/s; got {bw_mibps}" + ); + } + + #[tokio::test] + async fn pool_observer_sees_before_and_after_each_attempt() { + use std::sync::atomic::{AtomicUsize, Ordering}; + struct CountingObserver { + befores: AtomicUsize, + afters: AtomicUsize, + } + impl AttemptObserver for CountingObserver { + fn before_attempt(&self, _: &str) { + self.befores.fetch_add(1, Ordering::Relaxed); + } + fn after_attempt(&self, _: &str) { + self.afters.fetch_add(1, Ordering::Relaxed); + } + } + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "a", + outcome: StubOutcome::NotFound, + flavors: vec![Flavor::Full], + }), + Arc::new(StubMirror { + name: "b", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04ok")), + flavors: vec![Flavor::Full], + }), + ]); + let obs = CountingObserver { + befores: AtomicUsize::new(0), + afters: AtomicUsize::new(0), + }; + let _ = pool.download_with_observer(1, Flavor::Full, &obs).await; + // Two mirrors tried (a NotFound, b Success). + assert_eq!(obs.befores.load(Ordering::Relaxed), 2); + assert_eq!(obs.afters.load(Ordering::Relaxed), 2); + } + + #[tokio::test] + async fn pool_aborts_slow_mirror_when_per_attempt_timeout_set() { + // Mirror that would never complete inside the deadline. The pool + // must bail with Timeout, advance to the next mirror, and succeed + // there — this is the exact scenario the deadline was added for + // (sayobot hanging on a single in-flight request for 60+s). + struct SleepyMirror { + name: &'static str, + delay: Duration, + } + #[async_trait] + impl Mirror for SleepyMirror { + fn name(&self) -> &str { + self.name + } + fn supports(&self, _: Flavor) -> bool { + true + } + async fn download(&self, _: u64, _: Flavor) -> Result { + tokio::time::sleep(self.delay).await; + Ok(Bytes::from_static(b"PK\x03\x04ok")) + } + } + let pool = MirrorPool::with_attempt_timeout( + vec![ + Arc::new(SleepyMirror { + name: "slow", + delay: Duration::from_secs(60), + }), + Arc::new(SleepyMirror { + name: "fast", + delay: Duration::from_millis(1), + }), + ], + Some(Duration::from_millis(100)), + ); + let (result, attempts) = pool.download(1, Flavor::Full).await; + let (mirror, _) = result.expect("expected fast mirror to succeed"); + assert_eq!(mirror, "fast"); + assert_eq!(attempts.len(), 2); + assert_eq!(attempts[0].outcome, AttemptOutcome::Timeout); + assert_eq!(attempts[0].mirror, "slow"); + assert_eq!(attempts[1].outcome, AttemptOutcome::Success); + } + + #[tokio::test] + async fn pool_without_attempt_timeout_lets_mirror_finish() { + // Default constructor (no per-attempt timeout) must not abort a + // mirror that takes a moment to respond — only the reqwest + // client's own timeout applies in that mode. + struct SleepyMirror; + #[async_trait] + impl Mirror for SleepyMirror { + fn name(&self) -> &str { + "slow" + } + fn supports(&self, _: Flavor) -> bool { + true + } + async fn download(&self, _: u64, _: Flavor) -> Result { + tokio::time::sleep(Duration::from_millis(50)).await; + Ok(Bytes::from_static(b"PK\x03\x04ok")) + } + } + let pool = MirrorPool::new(vec![Arc::new(SleepyMirror)]); + let (result, attempts) = pool.download(1, Flavor::Full).await; + assert!(result.is_ok(), "mirror should be allowed to finish"); + assert_eq!(attempts[0].outcome, AttemptOutcome::Success); + } + + #[tokio::test] + async fn pool_skips_unsupported_flavor_without_http() { + let pool = MirrorPool::new(vec![ + Arc::new(StubMirror { + name: "novideo-only", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04unused")), + flavors: vec![Flavor::NoVideo], + }), + Arc::new(StubMirror { + name: "full-capable", + outcome: StubOutcome::Bytes(Bytes::from_static(b"PK\x03\x04good")), + flavors: vec![Flavor::Full, Flavor::NoVideo], + }), + ]); + let (result, attempts) = pool.download(123, Flavor::Full).await; + let (mirror, _) = result.unwrap(); + assert_eq!(mirror, "full-capable"); + assert_eq!(attempts[0].outcome, AttemptOutcome::UnsupportedFlavor); + assert_eq!(attempts[0].http_status, None); + assert_eq!(attempts[1].outcome, AttemptOutcome::Success); + } +} diff --git a/crates/osu_fetcher/src/mirrors/nekoha.rs b/crates/osu_fetcher/src/mirrors/nekoha.rs new file mode 100644 index 0000000000000000000000000000000000000000..23a064dfbd5dcc88b5884770e55bebae9fca5305 --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/nekoha.rs @@ -0,0 +1,88 @@ +//! nekoha.moe — public mirror, no auth required. +//! +//! Endpoint: `GET https://mirror.nekoha.moe/api4/download/{set_id}`. The +//! legacy `/d/{set_id}` path was retired when the site was rewritten as a +//! React SPA; it now serves the HTML shell unconditionally and we'd reject +//! the bytes as `InvalidArchive`. Flavor selection on the v4 API is +//! unconfirmed, so we always request the default (Full) — the only +//! flavor the dataset pipeline ever asks for anyway. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "nekoha"; +const BASE: &str = "https://mirror.nekoha.moe/api4/download"; + +pub struct NekohaMirror { + client: Client, + limiter: RateLimited, +} + +impl NekohaMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.nekoha.clone(), + } + } + + pub fn url(set_id: u64, _flavor: Flavor) -> String { + // v4 API: single endpoint per set; flavor selection isn't documented + // and isn't needed by the pipeline. + format!("{BASE}/{set_id}") + } +} + +#[async_trait] +impl Mirror for NekohaMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + true + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id, flavor); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_uses_v4_api_path() { + assert_eq!( + NekohaMirror::url(456, Flavor::Full), + "https://mirror.nekoha.moe/api4/download/456" + ); + } + + #[test] + fn url_novideo_falls_back_to_full_endpoint() { + // NoVideo isn't differentiated on the v4 API; we still hand back + // a valid URL so the chain doesn't UnsupportedFlavor-skip nekoha. + assert_eq!( + NekohaMirror::url(456, Flavor::NoVideo), + "https://mirror.nekoha.moe/api4/download/456" + ); + } +} diff --git a/crates/osu_fetcher/src/mirrors/nerinyan.rs b/crates/osu_fetcher/src/mirrors/nerinyan.rs new file mode 100644 index 0000000000000000000000000000000000000000..864995dcca845116e48c21f0a80679c84fde9971 --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/nerinyan.rs @@ -0,0 +1,85 @@ +//! nerinyan.moe — public mirror, no auth required. +//! +//! Endpoint: `GET https://api.nerinyan.moe/d/{set_id}` (full archive). +//! Toggle assets via the `nv`/`nb`/`nh` query params; we leave them all +//! unset to request the full original `.osz`. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "nerinyan"; +const BASE: &str = "https://api.nerinyan.moe/d"; + +pub struct NerinyanMirror { + client: Client, + limiter: RateLimited, +} + +impl NerinyanMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.nerinyan.clone(), + } + } + + pub fn url(set_id: u64, flavor: Flavor) -> String { + match flavor { + Flavor::Full => format!("{BASE}/{set_id}"), + Flavor::NoVideo => format!("{BASE}/{set_id}?nv=true"), + } + } +} + +#[async_trait] +impl Mirror for NerinyanMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + // Both flavors are supported via query params. + true + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id, flavor); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_has_no_params() { + assert_eq!( + NerinyanMirror::url(123, Flavor::Full), + "https://api.nerinyan.moe/d/123" + ); + } + + #[test] + fn url_novideo_uses_nv_param() { + assert_eq!( + NerinyanMirror::url(123, Flavor::NoVideo), + "https://api.nerinyan.moe/d/123?nv=true" + ); + } +} diff --git a/crates/osu_fetcher/src/mirrors/nzbasic.rs b/crates/osu_fetcher/src/mirrors/nzbasic.rs new file mode 100644 index 0000000000000000000000000000000000000000..8f139dad8ed246c919fd450b3978285fb74f5c34 --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/nzbasic.rs @@ -0,0 +1,102 @@ +//! direct.nzbasic.com — public mirror, no auth required. +//! +//! Endpoint: `GET https://direct.nzbasic.com/{set_id}.osz` — full archive. +//! This is the same endpoint used by nzbasic's own +//! [batch-beatmap-downloader](https://github.com/nzbasic/batch-beatmap-downloader), +//! which just hardcodes a `direct + "{setId}.osz"` GET. There is no documented +//! novideo variant, so we only register `Full` support; a `NoVideo` request +//! short-circuits to `UnsupportedFlavor` before any HTTP. +//! +//! Note on missing sets: the upstream Go downloader observes that this mirror +//! sometimes returns a tiny (~36 byte) JSON-ish "doesn't exist" body with a +//! 200 status instead of a real 404. We don't special-case that here — the +//! shared `classify_response` helper deep-verifies every successful body via +//! [`crate::verify::verify_bytes`] and rejects anything without a valid ZIP + +//! at least one `.osu` file. The pool treats `InvalidArchive` as a recoverable +//! error and advances to the next mirror, which gives us the same behavior +//! a proper 404 would. The only cost is a small health-score penalty against +//! this mirror per missing set; tolerable in practice. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "nzbasic"; +const BASE: &str = "https://direct.nzbasic.com"; + +pub struct NzbasicMirror { + client: Client, + limiter: RateLimited, +} + +impl NzbasicMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.nzbasic.clone(), + } + } + + pub fn url(set_id: u64) -> String { + format!("{BASE}/{set_id}.osz") + } +} + +#[async_trait] +impl Mirror for NzbasicMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, flavor: Flavor) -> bool { + matches!(flavor, Flavor::Full) + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + if !self.supports(flavor) { + return Err(MirrorError::UnsupportedFlavor { + mirror: NAME.into(), + flavor, + }); + } + self.limiter.acquire().await; + let url = Self::url(set_id); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_uses_osz_suffix() { + assert_eq!( + NzbasicMirror::url(1234), + "https://direct.nzbasic.com/1234.osz" + ); + } + + #[test] + fn novideo_is_not_supported() { + // Mirror has no documented novideo path; a NoVideo request must + // surface as UnsupportedFlavor before we burn a rate-limit token. + let supports_full = matches!(Flavor::Full, Flavor::Full); + let supports_novideo = matches!(Flavor::NoVideo, Flavor::Full); + assert!(supports_full); + assert!(!supports_novideo); + } +} diff --git a/crates/osu_fetcher/src/mirrors/osuapi.rs b/crates/osu_fetcher/src/mirrors/osuapi.rs new file mode 100644 index 0000000000000000000000000000000000000000..214f8117afb1ac9aa2686f5ab74e795d4ecf43ae --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/osuapi.rs @@ -0,0 +1,143 @@ +//! Official osu! API — bearer-token authenticated download endpoint. +//! +//! Endpoint: `GET https://osu.ppy.sh/api/v2/beatmapsets/{set_id}/download`, +//! optionally with `?noVideo=1` for the no-video flavor. Authentication +//! reuses the same [`OsuApi`] instance the `enumerate` phase uses, so a +//! single token is shared across the whole process — no second OAuth +//! handshake just for downloads. +//! +//! On 401 we invalidate the cached token and retry once. Repeated auth +//! failures (e.g., a `client_credentials` token without the right scope +//! to hit this endpoint) become consecutive hard failures in the pool's +//! health view, so the mirror is sidelined cleanly without poisoning the +//! whole run. +//! +//! The mirror is opt-out via `--disable osuapi` and skipped entirely +//! when no credentials are configured (handled by the caller in +//! `main.rs` — see [`OsuApiMirror::new`] returning `Option`). + +use std::sync::Arc; + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::{header::AUTHORIZATION, StatusCode}; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::api::OsuApi; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "osuapi"; +const BASE: &str = "https://osu.ppy.sh/api/v2/beatmapsets"; + +pub struct OsuApiMirror { + api: Arc, + limiter: RateLimited, +} + +impl OsuApiMirror { + /// Build the mirror. Returns `None` when no credentials were supplied + /// (`MirrorContext::osu_api` is `None`); the caller treats that as + /// "skip osuapi" instead of a hard configuration error so users + /// running the public mirrors alone don't need to register an OAuth + /// app. + pub fn new(ctx: &MirrorContext) -> Option { + let api = ctx.osu_api.clone()?; + Some(Self { + api, + limiter: ctx.limiters.osuapi.clone(), + }) + } + + pub fn url(set_id: u64, flavor: Flavor) -> String { + match flavor { + Flavor::Full => format!("{BASE}/{set_id}/download"), + Flavor::NoVideo => format!("{BASE}/{set_id}/download?noVideo=1"), + } + } + + /// Convert an auth-flow failure (token mint or refresh error) into a + /// `MirrorError`. We can't construct a `reqwest::Error` from outside + /// the reqwest crate, and dragging anyhow into `MirrorError` would + /// pollute every other mirror, so we surface it as a synthetic 401 + /// `HttpError` — the closest existing variant. The pool's health + /// scoring treats 401 as a hard failure, which is exactly right here. + fn token_error(reason: impl ToString) -> MirrorError { + let snippet: String = reason.to_string().chars().take(200).collect(); + MirrorError::HttpError { + mirror: NAME.into(), + status: 401, + body_snippet: format!("auth: {snippet}"), + } + } + + async fn send(&self, url: &str, token: &str) -> Result { + // Headers match the lazer client byte-for-byte: bearer + pinned + // x-api-version. The User-Agent is set on the shared OsuApi client + // (which runs in lazer mode when the user provides username + + // password), so /api/v2/beatmapsets/{id}/download requests look + // indistinguishable from a real lazer client on the wire. + self.api + .client() + .get(url) + .header(AUTHORIZATION, format!("Bearer {token}")) + .header("x-api-version", self.api.api_version_header()) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + }) + } +} + +#[async_trait] +impl Mirror for OsuApiMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + // The endpoint accepts both flavors via `?noVideo=1`. + true + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id, flavor); + let token = self.api.current_token().await.map_err(Self::token_error)?; + let resp = self.send(&url, &token).await?; + if resp.status() == StatusCode::UNAUTHORIZED { + // Cached token may have been invalidated server-side. Force a + // mint and try once more before falling through to the next + // mirror. The pool will sideline us via health scoring if 401 + // becomes the steady state. + self.api.invalidate_token().await; + let token = self.api.current_token().await.map_err(Self::token_error)?; + let resp = self.send(&url, &token).await?; + return classify_response(NAME, resp).await; + } + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_uses_documented_endpoint() { + assert_eq!( + OsuApiMirror::url(218851, Flavor::Full), + "https://osu.ppy.sh/api/v2/beatmapsets/218851/download" + ); + } + + #[test] + fn url_novideo_appends_no_video_query() { + assert_eq!( + OsuApiMirror::url(218851, Flavor::NoVideo), + "https://osu.ppy.sh/api/v2/beatmapsets/218851/download?noVideo=1" + ); + } +} diff --git a/crates/osu_fetcher/src/mirrors/osudirect.rs b/crates/osu_fetcher/src/mirrors/osudirect.rs new file mode 100644 index 0000000000000000000000000000000000000000..edcd5d2ad4f6f78c78bc3a3bd16f1cdd4e1035fd --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/osudirect.rs @@ -0,0 +1,94 @@ +//! osu.direct — public mirror, no auth required. +//! +//! Endpoint: `GET https://osu.direct/api/d/{set_id}` (full archive) or +//! `?noVideo=true` for the no-video flavor. Returns a 302 redirect to a +//! signed iDrive E2 (S3-compatible) URL; reqwest's default redirect +//! policy follows it transparently, so the call site sees the eventual +//! `.osz` body the same as any other mirror. +//! +//! Native rate limit (observed via `RateLimit-Limit` header): 120 +//! requests / 60s — generous compared to other mirrors. Our default +//! `--osudirect-rpm` is 60 for headroom; override with the flag if +//! you've coordinated higher. +//! +//! Docs: + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "osudirect"; +const BASE: &str = "https://osu.direct/api/d"; + +pub struct OsuDirectMirror { + client: Client, + limiter: RateLimited, +} + +impl OsuDirectMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.osudirect.clone(), + } + } + + pub fn url(set_id: u64, flavor: Flavor) -> String { + match flavor { + Flavor::Full => format!("{BASE}/{set_id}"), + Flavor::NoVideo => format!("{BASE}/{set_id}?noVideo=true"), + } + } +} + +#[async_trait] +impl Mirror for OsuDirectMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + // Both flavors via the noVideo query param. + true + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id, flavor); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_uses_plain_id() { + assert_eq!( + OsuDirectMirror::url(1234, Flavor::Full), + "https://osu.direct/api/d/1234" + ); + } + + #[test] + fn url_novideo_appends_query_param() { + assert_eq!( + OsuDirectMirror::url(1234, Flavor::NoVideo), + "https://osu.direct/api/d/1234?noVideo=true" + ); + } +} diff --git a/crates/osu_fetcher/src/mirrors/osudl.rs b/crates/osu_fetcher/src/mirrors/osudl.rs new file mode 100644 index 0000000000000000000000000000000000000000..e370259ae97b9733d78966b5ad6ca4202aab3ab0 --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/osudl.rs @@ -0,0 +1,77 @@ +//! osudl.org — public mirror, no auth required. +//! +//! Endpoint: `GET https://osudl.org/s/{set_id}`. The mirror exposes a single +//! short-link path regardless of flavor; reqwest follows whatever redirect +//! it issues to the underlying archive. We treat the response as Full (the +//! dataset's only target) and let `classify_response` deep-verify the bytes +//! as a real `.osz` before accepting them. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "osudl"; +const BASE: &str = "https://osudl.org/s"; + +pub struct OsudlMirror { + client: Client, + limiter: RateLimited, +} + +impl OsudlMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.osudl.clone(), + } + } + + pub fn url(set_id: u64) -> String { + format!("{BASE}/{set_id}") + } +} + +#[async_trait] +impl Mirror for OsudlMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + true + } + + async fn download(&self, set_id: u64, _flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_uses_short_link_path() { + assert_eq!(OsudlMirror::url(2513011), "https://osudl.org/s/2513011"); + } + + #[test] + fn url_works_for_low_id() { + assert_eq!(OsudlMirror::url(1), "https://osudl.org/s/1"); + } +} diff --git a/crates/osu_fetcher/src/mirrors/sayobot.rs b/crates/osu_fetcher/src/mirrors/sayobot.rs new file mode 100644 index 0000000000000000000000000000000000000000..778254dbc48b3c456d1dab780dba3615b315a8af --- /dev/null +++ b/crates/osu_fetcher/src/mirrors/sayobot.rs @@ -0,0 +1,90 @@ +//! sayobot.cn — public Chinese mirror, no auth required. +//! +//! Endpoint: `GET https://txy1.sayobot.cn/beatmaps/download/{type}/{set_id}` +//! where `{type}` is `full`, `novideo`, or `mini`. For our lossless dataset +//! we only use `full` and `novideo`; `mini` strips hitsounds and is therefore +//! not useful as a primary source. +//! +//! sayobot is geographically far from the typical English-speaking user but +//! retains some maps that have rotated off Western mirrors, so it earns a +//! place in the fallback chain. + +use async_trait::async_trait; +use bytes::Bytes; +use reqwest::Client; + +use super::{classify_response, Mirror, MirrorContext, MirrorError}; +use crate::ratelimit::RateLimited; +use crate::Flavor; + +pub const NAME: &str = "sayobot"; +const BASE: &str = "https://txy1.sayobot.cn/beatmaps/download"; + +pub struct SayobotMirror { + client: Client, + limiter: RateLimited, +} + +impl SayobotMirror { + pub fn new(ctx: &MirrorContext) -> Self { + Self { + client: ctx.client.clone(), + limiter: ctx.limiters.sayobot.clone(), + } + } + + pub fn url(set_id: u64, flavor: Flavor) -> String { + let kind = match flavor { + Flavor::Full => "full", + Flavor::NoVideo => "novideo", + }; + format!("{BASE}/{kind}/{set_id}") + } +} + +#[async_trait] +impl Mirror for SayobotMirror { + fn name(&self) -> &str { + NAME + } + + fn supports(&self, _flavor: Flavor) -> bool { + true + } + + async fn download(&self, set_id: u64, flavor: Flavor) -> Result { + self.limiter.acquire().await; + let url = Self::url(set_id, flavor); + let resp = self + .client + .get(&url) + .send() + .await + .map_err(|e| MirrorError::Network { + mirror: NAME.into(), + source: e, + })?; + classify_response(NAME, resp).await + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn url_full_uses_full_path_segment() { + assert_eq!( + SayobotMirror::url(123, Flavor::Full), + "https://txy1.sayobot.cn/beatmaps/download/full/123" + ); + } + + #[test] + fn url_novideo_uses_novideo_path_segment() { + assert_eq!( + SayobotMirror::url(123, Flavor::NoVideo), + "https://txy1.sayobot.cn/beatmaps/download/novideo/123" + ); + } +} diff --git a/crates/osu_fetcher/src/progress.rs b/crates/osu_fetcher/src/progress.rs new file mode 100644 index 0000000000000000000000000000000000000000..e9aeffa396d771b95ab32a805ce9f509b806c9bc --- /dev/null +++ b/crates/osu_fetcher/src/progress.rs @@ -0,0 +1,612 @@ +//! Live terminal dashboards for the long-running subcommands. +//! +//! For `download`, this is a multi-pane view built on `indicatif`'s +//! [`MultiProgress`]: a header line, the main progress bar, an aggregate +//! totals line, and a per-mirror table. The dashboard is purely a *view* — +//! callers update it via lock-free atomic counters, and a background tick +//! task re-renders the messages every 250 ms. Counters and bars live +//! together inside [`DownloadDashboard`] so a single `Arc` is everything a +//! worker needs. +//! +//! When stderr is not a TTY (CI, log redirect, `--no-progress`), the +//! [`MultiProgress`] is built with a hidden draw target so the same code +//! paths are used either way; calls become silent rather than missing. +//! +//! Design notes: +//! * The mirror table is a column-aligned text format rendered into the +//! `set_message` of one spinner per mirror. The header row uses the same +//! format string with the column titles, so the columns can never drift +//! out of alignment. +//! * The main bar's `pos` is incremented exactly once per terminal worker +//! outcome (success / failed / missing). `aborted` does *not* advance the +//! bar — the row will be retried on the next run, so counting it as +//! progress would lie about ETA. +//! * `enable_steady_tick` is intentionally not used; the tick task drives +//! redraw via `set_message`. + +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +#[cfg(unix)] +use console::Term; +use indicatif::{ + HumanBytes, HumanDuration, MultiProgress, ProgressBar, ProgressDrawTarget, ProgressStyle, +}; +use tokio::task::JoinHandle; +use tokio_util::sync::CancellationToken; + +use crate::mirrors::{AttemptObserver, AttemptOutcome as MirrorAttemptOutcome}; + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum ProgressTarget { + Hidden, + Stderr, + Tty, +} + +impl ProgressTarget { + pub fn enabled(self) -> bool { + !matches!(self, Self::Hidden) + } +} + +fn draw_target(target: ProgressTarget) -> ProgressDrawTarget { + match target { + ProgressTarget::Hidden => ProgressDrawTarget::hidden(), + ProgressTarget::Stderr => ProgressDrawTarget::stderr(), + ProgressTarget::Tty => tty_draw_target().unwrap_or_else(ProgressDrawTarget::stderr), + } +} + +#[cfg(unix)] +fn tty_draw_target() -> Option { + let read = std::fs::OpenOptions::new() + .read(true) + .open("/dev/tty") + .ok()?; + let write = std::fs::OpenOptions::new() + .write(true) + .open("/dev/tty") + .ok()?; + Some(ProgressDrawTarget::term( + Term::read_write_pair(read, write), + 20, + )) +} + +#[cfg(not(unix))] +fn tty_draw_target() -> Option { + None +} + +/// Per-mirror counters. All fields use `Relaxed` ordering — accuracy across +/// threads doesn't need a memory barrier; we just want monotonically +/// non-decreasing values that the renderer reads as a snapshot. +#[derive(Default)] +struct MirrorCounters { + reqs: AtomicU64, + ok: AtomicU64, + not_found: AtomicU64, + rate_limited: AtomicU64, + network: AtomicU64, + invalid: AtomicU64, + http_error: AtomicU64, + /// Counts attempts that hit the pool's per-attempt deadline. Surfaced + /// in its own dashboard column so a hung mirror is visually obvious + /// (vs being lumped into a generic "err" bucket). + timeout: AtomicU64, + total_duration_ms: AtomicU64, + /// Sum of successful-attempt durations only — pairs with `bytes` + /// (success-only) to give a clean MiB/s for the dashboard. + total_success_duration_ms: AtomicU64, + inflight: AtomicU64, + bytes: AtomicU64, +} + +/// Top-level dashboard for the `download` subcommand. +pub struct DownloadDashboard { + multi: MultiProgress, + header: ProgressBar, + main: ProgressBar, + totals: ProgressBar, + mirror_header: ProgressBar, + mirror_bars: Vec, + + mirrors: Vec<(String, MirrorCounters)>, + + success: AtomicU64, + failed: AtomicU64, + missing: AtomicU64, + aborted: AtomicU64, + bytes: AtomicU64, + inflight: AtomicU64, + started: Instant, + + enabled: bool, + concurrency: usize, +} + +impl DownloadDashboard { + pub fn new( + total: u64, + concurrency: usize, + mirrors: &[&str], + target: ProgressTarget, + ) -> Arc { + let multi = MultiProgress::with_draw_target(draw_target(target)); + + let header = multi.add(ProgressBar::new_spinner()); + header.set_style(ProgressStyle::with_template("{msg}").unwrap()); + + let main = multi.add(ProgressBar::new(total)); + main.set_style( + ProgressStyle::with_template( + " [{bar:40.cyan/blue}] {pos:>7}/{len:<7} {percent:>3}% · {msg}", + ) + .unwrap() + .progress_chars("█▉▊▋▌▍▎▏ "), + ); + main.set_message("starting…"); + + let totals = multi.add(ProgressBar::new_spinner()); + totals.set_style(ProgressStyle::with_template(" {msg}").unwrap()); + totals.set_message("ok 0 · failed 0 · missing 0 · aborted 0".to_string()); + + let mirror_header = multi.add(ProgressBar::new_spinner()); + mirror_header.set_style(ProgressStyle::with_template("{msg}").unwrap()); + mirror_header.set_message(mirror_header_line()); + + let mut mirror_bars = Vec::with_capacity(mirrors.len()); + let mut mirrors_vec = Vec::with_capacity(mirrors.len()); + for name in mirrors { + let pb = multi.add(ProgressBar::new_spinner()); + pb.set_style(ProgressStyle::with_template("{msg}").unwrap()); + let counters = MirrorCounters::default(); + pb.set_message(format_mirror_line(name, &counters)); + mirror_bars.push(pb); + mirrors_vec.push((name.to_string(), counters)); + } + + let dash = Arc::new(Self { + multi, + header, + main, + totals, + mirror_header, + mirror_bars, + mirrors: mirrors_vec, + success: AtomicU64::new(0), + failed: AtomicU64::new(0), + missing: AtomicU64::new(0), + aborted: AtomicU64::new(0), + bytes: AtomicU64::new(0), + inflight: AtomicU64::new(0), + started: Instant::now(), + enabled: target.enabled(), + concurrency, + }); + dash.render(); + dash + } + + /// Print a line above the dashboard. Visible in both enabled and hidden + /// mode (in hidden mode it falls back to plain stderr). + pub fn println(&self, msg: impl AsRef) { + if self.enabled { + let _ = self.multi.println(msg.as_ref()); + } else { + eprintln!("{}", msg.as_ref()); + } + } + + pub fn record_attempt( + &self, + mirror: &str, + outcome: MirrorAttemptOutcome, + duration: Duration, + bytes: Option, + ) { + let Some((_, c)) = self.mirrors.iter().find(|(n, _)| n == mirror) else { + return; + }; + c.reqs.fetch_add(1, Ordering::Relaxed); + c.total_duration_ms + .fetch_add(duration.as_millis() as u64, Ordering::Relaxed); + if let Some(b) = bytes { + c.bytes.fetch_add(b, Ordering::Relaxed); + } + match outcome { + MirrorAttemptOutcome::Success => { + c.ok.fetch_add(1, Ordering::Relaxed); + c.total_success_duration_ms + .fetch_add(duration.as_millis() as u64, Ordering::Relaxed); + } + MirrorAttemptOutcome::NotFound => { + c.not_found.fetch_add(1, Ordering::Relaxed); + } + MirrorAttemptOutcome::RateLimited => { + c.rate_limited.fetch_add(1, Ordering::Relaxed); + } + MirrorAttemptOutcome::Network => { + c.network.fetch_add(1, Ordering::Relaxed); + } + MirrorAttemptOutcome::InvalidArchive => { + c.invalid.fetch_add(1, Ordering::Relaxed); + } + MirrorAttemptOutcome::HttpError => { + c.http_error.fetch_add(1, Ordering::Relaxed); + } + MirrorAttemptOutcome::Timeout => { + c.timeout.fetch_add(1, Ordering::Relaxed); + } + MirrorAttemptOutcome::UnsupportedFlavor => {} + } + } + + pub fn mirror_inflight_inc(&self, mirror: &str) { + if let Some((_, c)) = self.mirrors.iter().find(|(n, _)| n == mirror) { + c.inflight.fetch_add(1, Ordering::Relaxed); + } + } + pub fn mirror_inflight_dec(&self, mirror: &str) { + if let Some((_, c)) = self.mirrors.iter().find(|(n, _)| n == mirror) { + c.inflight.fetch_sub(1, Ordering::Relaxed); + } + } + pub fn worker_inflight_inc(&self) { + self.inflight.fetch_add(1, Ordering::Relaxed); + } + pub fn worker_inflight_dec(&self) { + self.inflight.fetch_sub(1, Ordering::Relaxed); + } + + pub fn record_success(&self, bytes: u64) { + self.success.fetch_add(1, Ordering::Relaxed); + self.bytes.fetch_add(bytes, Ordering::Relaxed); + self.main.inc(1); + } + pub fn record_failed(&self) { + self.failed.fetch_add(1, Ordering::Relaxed); + self.main.inc(1); + } + pub fn record_missing(&self) { + self.missing.fetch_add(1, Ordering::Relaxed); + self.main.inc(1); + } + pub fn record_aborted(&self) { + // Aborted rows go back to pending, so they shouldn't advance the bar + // (otherwise ETA lies on resume). + self.aborted.fetch_add(1, Ordering::Relaxed); + } + + /// Recompute messages for all bars from current atomic state. + pub fn render(&self) { + let elapsed = self.started.elapsed(); + let elapsed_secs = elapsed.as_secs_f64().max(0.001); + let success = self.success.load(Ordering::Relaxed); + let failed = self.failed.load(Ordering::Relaxed); + let missing = self.missing.load(Ordering::Relaxed); + let aborted = self.aborted.load(Ordering::Relaxed); + let bytes = self.bytes.load(Ordering::Relaxed); + let inflight = self.inflight.load(Ordering::Relaxed); + + // Header — keep it short; the running clock makes it feel alive. + self.header.set_message(format!( + "osu_fetcher download · {} workers · running {}", + self.concurrency, + HumanDuration(elapsed), + )); + + // Main bar message: ETA + sets/sec. + let pos = self.main.position(); + let len = self.main.length().unwrap_or(0); + let sps = pos as f64 / elapsed_secs; + let eta_str = if sps > 0.05 && len > pos { + let secs = ((len - pos) as f64 / sps) as u64; + format!("{}", HumanDuration(Duration::from_secs(secs))) + } else { + "—".to_string() + }; + self.main + .set_message(format!("ETA {:>10} · {:>5.1} sets/s", eta_str, sps)); + + // Totals. + let avg_size = if success > 0 { bytes / success } else { 0 }; + let bps = (bytes as f64 / elapsed_secs) as u64; + self.totals.set_message(format!( + "ok {success} failed {failed} missing {missing} aborted {aborted} · {} at {}/s · avg {} · {inflight} in flight", + HumanBytes(bytes), + HumanBytes(bps), + HumanBytes(avg_size), + )); + + // Per-mirror lines. + for (i, (name, c)) in self.mirrors.iter().enumerate() { + self.mirror_bars[i].set_message(format_mirror_line(name, c)); + } + } + + /// Stop drawing and print one final summary line. Call once at the end + /// of `download::run`. + pub fn finalize(&self) { + self.render(); + // Set the main bar's prefix-ish message to a finished state, then + // freeze everything. `finish` leaves the bars at their current + // rendered values so the user can see the final dashboard. + self.header.finish(); + self.main.finish(); + self.totals.finish(); + self.mirror_header.finish(); + for pb in &self.mirror_bars { + pb.finish(); + } + } +} + +/// Wire the dashboard up as the pool's per-attempt observer so the +/// per-mirror `in` column reflects real-time concurrency. Uses the +/// existing `mirror_inflight_inc/dec` atomics. +impl AttemptObserver for DownloadDashboard { + fn before_attempt(&self, mirror: &str) { + self.mirror_inflight_inc(mirror); + } + fn after_attempt(&self, mirror: &str) { + self.mirror_inflight_dec(mirror); + } +} + +const COL_NAME: usize = 14; +const COL_REQS: usize = 7; +const COL_OK: usize = 7; +const COL_MISS: usize = 7; +const COL_RL: usize = 5; +const COL_ERR: usize = 5; +const COL_TMO: usize = 5; +const COL_INV: usize = 5; +const COL_MS: usize = 6; +const COL_MBPS: usize = 7; +const COL_PCT: usize = 6; +const COL_IN: usize = 5; + +fn mirror_header_line() -> String { + format!( + " {:w_reqs$} {:>w_ok$} {:>w_miss$} {:>w_rl$} {:>w_err$} {:>w_tmo$} {:>w_inv$} {:>w_ms$} {:>w_mbps$} {:>w_pct$} {:>w_in$}", + "mirror", "reqs", "ok", "miss", "429", "err", "tmo", "inv", "ms", "MiB/s", "ok%", "in", + w_name = COL_NAME, + w_reqs = COL_REQS, + w_ok = COL_OK, + w_miss = COL_MISS, + w_rl = COL_RL, + w_err = COL_ERR, + w_tmo = COL_TMO, + w_inv = COL_INV, + w_ms = COL_MS, + w_mbps = COL_MBPS, + w_pct = COL_PCT, + w_in = COL_IN, + ) +} + +fn format_mirror_line(name: &str, c: &MirrorCounters) -> String { + let reqs = c.reqs.load(Ordering::Relaxed); + let ok = c.ok.load(Ordering::Relaxed); + let miss = c.not_found.load(Ordering::Relaxed); + let rate = c.rate_limited.load(Ordering::Relaxed); + let net = c.network.load(Ordering::Relaxed); + let http = c.http_error.load(Ordering::Relaxed); + let inv = c.invalid.load(Ordering::Relaxed); + let tmo = c.timeout.load(Ordering::Relaxed); + let dur = c.total_duration_ms.load(Ordering::Relaxed); + let success_dur = c.total_success_duration_ms.load(Ordering::Relaxed); + let bytes = c.bytes.load(Ordering::Relaxed); + let inflight = c.inflight.load(Ordering::Relaxed); + // `err` keeps its original meaning (network + http_error) so users + // who scan it for "things going wrong" still see the same number; + // timeouts get their own column because they're the specific signal + // the user added a deadline to detect. + let err = net + http; + let avg_ms = if reqs > 0 { dur / reqs } else { 0 }; + let mibps = if success_dur > 0 { + // bytes / (success_dur ms) → bytes / (success_dur / 1000 sec). + // Convert to MiB/s. + let bps = bytes as f64 * 1000.0 / success_dur as f64; + format!("{:.2}", bps / 1_048_576.0) + } else { + "—".to_string() + }; + let ok_pct = if reqs > 0 { + format!("{:.1}%", 100.0 * ok as f64 / reqs as f64) + } else { + "—".to_string() + }; + format!( + " {:w_reqs$} {:>w_ok$} {:>w_miss$} {:>w_rl$} {:>w_err$} {:>w_tmo$} {:>w_inv$} {:>w_ms$} {:>w_mbps$} {:>w_pct$} {:>w_in$}", + truncate(name, COL_NAME), + reqs, + ok, + miss, + rate, + err, + tmo, + inv, + avg_ms, + mibps, + ok_pct, + inflight, + w_name = COL_NAME, + w_reqs = COL_REQS, + w_ok = COL_OK, + w_miss = COL_MISS, + w_rl = COL_RL, + w_err = COL_ERR, + w_tmo = COL_TMO, + w_inv = COL_INV, + w_ms = COL_MS, + w_mbps = COL_MBPS, + w_pct = COL_PCT, + w_in = COL_IN, + ) +} + +fn truncate(s: &str, n: usize) -> String { + if s.chars().count() <= n { + s.to_string() + } else { + s.chars() + .take(n.saturating_sub(1)) + .chain(std::iter::once('…')) + .collect() + } +} + +/// Spawn a background task that re-renders the dashboard every 250 ms until +/// `shutdown` fires. The handle should be awaited (or aborted) by +/// `download::run` before the dashboard is finalized. +pub fn spawn_tick_task( + dash: Arc, + shutdown: CancellationToken, +) -> JoinHandle<()> { + tokio::spawn(async move { + let mut interval = tokio::time::interval(Duration::from_millis(250)); + interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); + loop { + tokio::select! { + _ = shutdown.cancelled() => { + dash.render(); + break; + } + _ = interval.tick() => dash.render(), + } + } + }) +} + +/// Whether stderr is connected to a terminal. Use this to decide whether +/// to enable the dashboard by default. +pub fn stderr_is_terminal() -> bool { + use std::io::IsTerminal; + std::io::stderr().is_terminal() +} + +/// Lightweight one-line spinner used by `enumerate` and `scan`. The total +/// is unknown (cursor-driven pagination / fs walk), so a counter spinner +/// is the right shape — no length, just an updating message. +pub struct CounterSpinner { + multi: MultiProgress, + pb: ProgressBar, + enabled: bool, +} + +impl CounterSpinner { + pub fn new(prefix: &str, enable: bool) -> Self { + let multi = if enable { + MultiProgress::with_draw_target(ProgressDrawTarget::stderr()) + } else { + MultiProgress::with_draw_target(ProgressDrawTarget::hidden()) + }; + let pb = multi.add(ProgressBar::new_spinner()); + pb.set_style( + ProgressStyle::with_template(" {spinner:.cyan} {prefix} · {msg}") + .unwrap() + .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ "), + ); + pb.set_prefix(prefix.to_string()); + pb.set_message("starting…"); + pb.enable_steady_tick(Duration::from_millis(120)); + Self { + multi, + pb, + enabled: enable, + } + } + + pub fn set_message(&self, msg: impl Into) { + self.pb.set_message(msg.into()); + } + + pub fn println(&self, msg: impl AsRef) { + if self.enabled { + let _ = self.multi.println(msg.as_ref()); + } else { + eprintln!("{}", msg.as_ref()); + } + } + + pub fn finish(&self, final_msg: impl Into) { + self.pb.set_message(final_msg.into()); + self.pb.finish(); + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn header_and_row_have_matching_widths() { + let header = mirror_header_line(); + let row = format_mirror_line("nerinyan", &MirrorCounters::default()); + assert_eq!( + header.chars().count(), + row.chars().count(), + "header `{}` and row `{}` should be equal width", + header, + row + ); + } + + #[test] + fn mirror_name_truncates_when_too_long() { + let row = format_mirror_line("a-very-long-mirror-name", &MirrorCounters::default()); + // Should still match header width. + assert_eq!(row.chars().count(), mirror_header_line().chars().count()); + } + + #[test] + fn record_attempt_increments_appropriate_counters() { + let dash = DownloadDashboard::new(10, 1, &["nerinyan"], ProgressTarget::Hidden); + dash.record_attempt( + "nerinyan", + MirrorAttemptOutcome::Success, + Duration::from_millis(100), + Some(1024), + ); + dash.record_attempt( + "nerinyan", + MirrorAttemptOutcome::RateLimited, + Duration::from_millis(50), + None, + ); + let (_, c) = &dash.mirrors[0]; + assert_eq!(c.reqs.load(Ordering::Relaxed), 2); + assert_eq!(c.ok.load(Ordering::Relaxed), 1); + assert_eq!(c.rate_limited.load(Ordering::Relaxed), 1); + assert_eq!(c.total_duration_ms.load(Ordering::Relaxed), 150); + assert_eq!(c.bytes.load(Ordering::Relaxed), 1024); + } + + #[test] + fn record_success_advances_main_bar_record_aborted_does_not() { + let dash = DownloadDashboard::new(10, 1, &[], ProgressTarget::Hidden); + dash.record_success(2048); + dash.record_aborted(); + assert_eq!(dash.main.position(), 1, "abort should not advance bar"); + assert_eq!(dash.success.load(Ordering::Relaxed), 1); + assert_eq!(dash.aborted.load(Ordering::Relaxed), 1); + assert_eq!(dash.bytes.load(Ordering::Relaxed), 2048); + } + + #[test] + fn record_attempt_for_unknown_mirror_is_noop() { + let dash = DownloadDashboard::new(10, 1, &["nerinyan"], ProgressTarget::Hidden); + dash.record_attempt( + "ghostmirror", + MirrorAttemptOutcome::Success, + Duration::from_millis(10), + None, + ); + let (_, c) = &dash.mirrors[0]; + assert_eq!(c.reqs.load(Ordering::Relaxed), 0); + } +} diff --git a/crates/osu_fetcher/src/ratelimit.rs b/crates/osu_fetcher/src/ratelimit.rs new file mode 100644 index 0000000000000000000000000000000000000000..84bbd6686765d114ebd6c601a4fbc5a52abfd032 --- /dev/null +++ b/crates/osu_fetcher/src/ratelimit.rs @@ -0,0 +1,132 @@ +//! Per-target rate limiting on top of `governor`. +//! +//! The osu! API and every mirror gets its own `RateLimited` instance so that +//! the global concurrency cap (`Semaphore` in `download::run`) bounds in-flight +//! requests, while these per-target governors enforce *throughput* against +//! each upstream independently. +//! +//! Limits are configured per minute and **evenly paced** — at most one +//! token outstanding at any moment, refilled at `rpm / 60` per second. +//! `governor`'s `Quota::per_minute(rpm)` defaults to a burst size equal to +//! `rpm`, which would let a `--concurrency 1024` worker pool drain a whole +//! minute's quota in a single instant the moment a fresh limiter wakes up. +//! That respects the rate over a 1-minute window but feels like a TCP +//! swarm to the mirror operator and is exactly what high-concurrency +//! callers complain about. We override the burst to 1 so concurrency does +//! not change the rate the upstream sees. +//! +//! The `acquire` helper just waits until the limiter says ready. Callers that +//! want to time out the wait should `tokio::select!` against their own +//! deadline. + +use std::num::NonZeroU32; +use std::sync::Arc; + +use governor::{ + clock::DefaultClock, + state::{InMemoryState, NotKeyed}, + Quota, RateLimiter, +}; + +type DirectRateLimiter = RateLimiter; + +/// Named, cloneable, per-target rate limiter. +/// +/// `name` is purely cosmetic — it shows up in `tracing` events when the +/// limiter blocks a request. Cloning is cheap (Arc bump). +#[derive(Clone)] +pub struct RateLimited { + name: Arc, + limiter: Arc, + rpm: u32, +} + +impl RateLimited { + /// Build a limiter that allows `rpm` requests per minute, paced + /// evenly: tokens refill every `60s / rpm`, and at most one is + /// available at any instant (burst = 1). Concurrency above the rate + /// just queues — the upstream still sees the documented throughput. + /// `rpm` is clamped to at least 1 so callers can pass user-supplied + /// values without an unwrap. + pub fn per_minute(name: impl Into>, rpm: u32) -> Self { + let rpm_nz = NonZeroU32::new(rpm.max(1)).expect("clamped above 0"); + let burst = NonZeroU32::new(1).expect("1 is non-zero"); + let quota = Quota::per_minute(rpm_nz).allow_burst(burst); + Self { + name: name.into(), + limiter: Arc::new(RateLimiter::direct(quota)), + rpm: rpm_nz.get(), + } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn rpm(&self) -> u32 { + self.rpm + } + + /// Block until the limiter has a token available, then return. + pub async fn acquire(&self) { + // governor returns immediately when capacity exists; otherwise it + // sleeps until the next refill. Either way, no early-return needed. + self.limiter.until_ready().await; + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::time::Instant; + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn rate_limited_paces_back_to_back_requests() { + // 60 rpm = period 1s, burst = 1. First acquire passes instantly, + // the second must wait roughly the period. + let rl = RateLimited::per_minute("test", 60); + rl.acquire().await; + let t0 = Instant::now(); + rl.acquire().await; + let waited = t0.elapsed(); + assert!( + waited >= std::time::Duration::from_millis(700), + "expected to wait ~1s between back-to-back acquires; only waited {:?}", + waited + ); + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 4)] + async fn rate_limited_does_not_let_concurrency_swamp_upstream() { + // The bug we're guarding against: with burst=rpm, 25 concurrent + // acquires would all complete in milliseconds. With burst=1 the + // upstream sees them at the configured pace regardless of how + // many futures are queued. + // + // 1200 rpm = period 50ms. 25 acquires → first immediate, remaining + // 24 paced 50ms apart → expect ~24 * 50ms = ~1.2s of wallclock, + // well above what an unconstrained burst would produce. + let rl = RateLimited::per_minute("swamp", 1200); + let t0 = Instant::now(); + let mut handles = Vec::with_capacity(25); + for _ in 0..25 { + let rl = rl.clone(); + handles.push(tokio::spawn(async move { rl.acquire().await })); + } + for h in handles { + h.await.unwrap(); + } + let elapsed = t0.elapsed(); + assert!( + elapsed >= std::time::Duration::from_millis(1000), + "25 acquires at 1200 rpm with burst=1 should take ~1.2s; took {:?}", + elapsed + ); + } + + #[test] + fn rpm_zero_clamps_to_one() { + let rl = RateLimited::per_minute("zero", 0); + assert_eq!(rl.rpm(), 1); + } +} diff --git a/crates/osu_fetcher/src/runlock.rs b/crates/osu_fetcher/src/runlock.rs new file mode 100644 index 0000000000000000000000000000000000000000..3148eaf33d7b6ac4d2079fcb37078c4fc8a22138 --- /dev/null +++ b/crates/osu_fetcher/src/runlock.rs @@ -0,0 +1,125 @@ +//! Single-writer file lock for the `download` command. +//! +//! Two concurrent `osu_fetcher download` processes are catastrophic for our +//! state machine: process B's startup-time `requeue_in_progress()` would +//! flip process A's live in-flight claims back to `pending`, then B would +//! re-claim them. Two workers trying to download the same set hit a +//! `MoveFileExW`-replace collision on Windows and one of them spuriously +//! marks the row failed. +//! +//! The defense: take an OS-level exclusive file lock at the start of a +//! download run and hold it for the duration. The lock is released +//! automatically by the kernel when the process exits — graceful exit, panic, +//! SIGKILL, or power-off — so there's no PID-aliveness logic to maintain +//! and no stale lockfiles to clean up. We use `std::fs::File::try_lock` +//! (stable since Rust 1.89), which is `LockFileEx(LOCKFILE_EXCLUSIVE_LOCK +//! | LOCKFILE_FAIL_IMMEDIATELY)` on Windows and `flock(LOCK_EX|LOCK_NB)` on +//! Unix. + +use std::fs::{File, OpenOptions}; +use std::path::{Path, PathBuf}; + +use anyhow::{anyhow, Context, Result}; + +/// RAII guard for the lock. Drop releases the lock; `path()` exposes the +/// path the lock file was created at for diagnostic logging. +#[derive(Debug)] +pub struct DownloadLock { + file: File, + path: PathBuf, +} + +impl DownloadLock { + /// Acquire the lock or return an error explaining why it's already held. + /// `path` is the lockfile location — typically next to the state DB. + pub fn acquire(path: &Path) -> Result { + let file = OpenOptions::new() + .create(true) + .read(true) + .write(true) + .truncate(false) + .open(path) + .with_context(|| format!("opening lockfile {}", path.display()))?; + if let Err(e) = file.try_lock() { + return Err(anyhow!( + "another osu_fetcher download appears to be running ({}); \ + lockfile path is {}. The file may remain after clean or \ + killed exits; that is harmless because the OS lock is what \ + matters. Check for a live osu_fetcher process before retrying.", + e, + path.display() + )); + } + // We deliberately don't stamp PID/timestamp into the file body — + // on Windows `LockFileEx` locks the byte range, so a third-party + // reader can't actually read the contents anyway. To find the + // holder, use `lsof ` (Unix) or Process Explorer (Windows). + Ok(Self { + file, + path: path.to_path_buf(), + }) + } + + pub fn path(&self) -> &Path { + &self.path + } +} + +impl Drop for DownloadLock { + fn drop(&mut self) { + // OS releases the lock on file close (which Drop on `File` does) + // anyway. Calling unlock() explicitly here just makes the release + // happen before the process keeps running — useful if a long-lived + // process wants to release between phases. + let _ = self.file.unlock(); + // Don't delete the lockfile: a different concurrent acquire may + // have raced in between our unlock and the would-be delete. + // Leaving the file is harmless — std re-locks on next acquire. + } +} + +#[cfg(test)] +mod tests { + use super::*; + use tempfile::TempDir; + + #[test] + fn acquire_then_drop_releases() { + let dir = TempDir::new().unwrap(); + let path = dir.path().join(".lock"); + { + let _g = DownloadLock::acquire(&path).expect("first lock"); + } + // Should be re-acquirable after drop. + let _g2 = DownloadLock::acquire(&path).expect("second lock after drop"); + } + + #[test] + fn concurrent_acquire_fails() { + let dir = TempDir::new().unwrap(); + let path = dir.path().join(".lock"); + let g1 = DownloadLock::acquire(&path).expect("first lock"); + let err = DownloadLock::acquire(&path).expect_err("second concurrent should fail"); + assert!( + err.to_string().contains("running"), + "unexpected error: {err}" + ); + drop(g1); + // Now re-acquirable. + let _g3 = DownloadLock::acquire(&path).expect("third lock after first dropped"); + } + + #[test] + fn lockfile_persists_on_disk_until_drop() { + let dir = TempDir::new().unwrap(); + let path = dir.path().join(".lock"); + let g = DownloadLock::acquire(&path).unwrap(); + assert!(path.exists()); + // After drop, the file remains (we don't delete to avoid a + // race with a concurrent acquire); verify only that the lock + // is released, not the path. + drop(g); + let _g2 = DownloadLock::acquire(&path).expect("re-acquire after drop"); + assert!(path.exists()); + } +} diff --git a/crates/osu_fetcher/src/scan.rs b/crates/osu_fetcher/src/scan.rs new file mode 100644 index 0000000000000000000000000000000000000000..8b6f7d6b960ec8f094ebb7bd07dd1d2f23cb0b77 --- /dev/null +++ b/crates/osu_fetcher/src/scan.rs @@ -0,0 +1,190 @@ +//! `scan` subcommand — record `.osz` files already on disk. +//! +//! Walks the `archives-dir` once and records every `.osz` whose filename +//! parses as a beatmapset id. Sets in the directory but with non-numeric +//! filenames are skipped (they could exist for ad-hoc reasons; we don't +//! presume to interpret them). +//! +//! Pass `verify = true` to additionally open each archive and reject corrupt +//! ones — corrupt archives are left in `pending` so a `download` run will +//! re-fetch them. Without `verify`, scan is fast: a single `read_dir` pass. + +use std::path::{Path, PathBuf}; +use std::sync::Arc; + +use anyhow::{Context, Result}; +use tokio::fs; +use tracing::{debug, info, warn}; + +use crate::progress::CounterSpinner; +use crate::state::StateDb; +use crate::verify::verify_path; + +#[derive(Clone, Copy, Debug, Default)] +pub struct ScanStats { + pub seen: u64, + pub recorded: u64, + pub bad_name: u64, + pub bad_archive: u64, +} + +/// Walk `archives_dir`, recording every `.osz` into the state DB. +/// +/// `progress`, when supplied, gets a fresh `set_message` after every file so +/// the user has a live counter; pass `None` from tests to keep the call +/// silent. +pub async fn scan_archives( + state: Arc, + archives_dir: &Path, + verify: bool, + progress: Option<&CounterSpinner>, +) -> Result { + if !archives_dir.exists() { + anyhow::bail!( + "archives directory does not exist: {}", + archives_dir.display() + ); + } + let mut stats = ScanStats::default(); + let mut entries = fs::read_dir(archives_dir) + .await + .with_context(|| format!("reading {}", archives_dir.display()))?; + while let Some(entry) = entries.next_entry().await.context("walking archives dir")? { + let path = entry.path(); + if !path.is_file() { + continue; + } + let Some(set_id) = parse_set_id_from_filename(&path) else { + stats.bad_name += 1; + continue; + }; + stats.seen += 1; + + let meta = fs::metadata(&path) + .await + .with_context(|| format!("stat {}", path.display()))?; + let bytes = meta.len(); + + if verify { + // Run sync zip open inside spawn_blocking — the verify path is + // CPU-bound and small (we only walk entries, not decompress). + let p = path.clone(); + match tokio::task::spawn_blocking(move || verify_path(&p)) + .await + .context("verify worker join")? + { + Ok(_) => (), + Err(e) => { + warn!(set_id, err = %e, "scan: invalid archive, leaving pending"); + stats.bad_archive += 1; + continue; + } + } + } + + state.record_present(set_id, &path.to_string_lossy(), bytes)?; + stats.recorded += 1; + if let Some(p) = progress { + p.set_message(format!( + "seen {} · recorded {} · bad name {} · bad archive {}", + stats.seen, stats.recorded, stats.bad_name, stats.bad_archive + )); + } + if stats.recorded % 1000 == 0 { + debug!(recorded = stats.recorded, "scan progress"); + } + } + info!( + seen = stats.seen, + recorded = stats.recorded, + bad_name = stats.bad_name, + bad_archive = stats.bad_archive, + "scan complete" + ); + Ok(stats) +} + +/// Pull a `set_id` out of `.osz` (case-insensitive on extension). +/// +/// Returns `None` for any filename whose stem isn't a positive integer that +/// fits in `u64`. We intentionally accept *only* numeric filenames so the +/// scan is conservative: ad-hoc renamed archives stay invisible to the state +/// DB rather than being misattributed to the wrong set. +pub fn parse_set_id_from_filename(path: &Path) -> Option { + let stem = path.file_stem()?.to_str()?; + let ext = path + .extension() + .and_then(|e| e.to_str()) + .unwrap_or("") + .to_ascii_lowercase(); + if ext != "osz" { + return None; + } + stem.parse::().ok().filter(|n| *n > 0) +} + +/// Convenience wrapper used by the scan smoke test: scan the directory, not +/// touching the DB. Returns the parsed set_ids. +#[allow(dead_code)] +pub async fn list_set_ids(archives_dir: &Path) -> Result> { + if !archives_dir.exists() { + return Ok(Vec::new()); + } + let mut ids = Vec::new(); + let mut entries = fs::read_dir(archives_dir).await?; + while let Some(entry) = entries.next_entry().await? { + let path: PathBuf = entry.path(); + if let Some(id) = parse_set_id_from_filename(&path) { + ids.push(id); + } + } + ids.sort_unstable(); + Ok(ids) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::path::PathBuf; + + #[test] + fn parse_set_id_accepts_numeric_osz() { + assert_eq!( + parse_set_id_from_filename(&PathBuf::from("/p/123456.osz")), + Some(123456) + ); + } + + #[test] + fn parse_set_id_handles_uppercase_extension() { + assert_eq!( + parse_set_id_from_filename(&PathBuf::from("/p/789.OSZ")), + Some(789) + ); + } + + #[test] + fn parse_set_id_rejects_non_osz_extension() { + assert_eq!( + parse_set_id_from_filename(&PathBuf::from("/p/123.zip")), + None + ); + } + + #[test] + fn parse_set_id_rejects_non_numeric_stem() { + assert_eq!( + parse_set_id_from_filename(&PathBuf::from("/p/songname.osz")), + None + ); + assert_eq!( + parse_set_id_from_filename(&PathBuf::from("/p/123-edit.osz")), + None + ); + } + + #[test] + fn parse_set_id_rejects_zero() { + assert_eq!(parse_set_id_from_filename(&PathBuf::from("/p/0.osz")), None); + } +} diff --git a/crates/osu_fetcher/src/state.rs b/crates/osu_fetcher/src/state.rs new file mode 100644 index 0000000000000000000000000000000000000000..e55065a4b6df9a94cf635d62223e89df2907be82 --- /dev/null +++ b/crates/osu_fetcher/src/state.rs @@ -0,0 +1,1223 @@ +//! SQLite-backed persistent state for `osu_fetcher`. +//! +//! Schema is created on first open via [`StateDb::open`] and version-stamped +//! into the `meta` table so future migrations have a hook. WAL mode is enabled +//! for crash safety and concurrent reads while a worker writes. Foreign keys +//! are enabled so deleting a `sets` row also drops its `mirror_attempts`. +//! +//! Tables: +//! +//! * `sets` — one row per beatmapset of interest. The "wanted" half is filled +//! by `enumerate` (from the official API); the "acquisition" half is filled +//! by `scan` (we found `.osz` on disk) and `download` (we just fetched +//! it). The columns are deliberately nullable so partial info from either +//! side is preserved. +//! +//! * `mirror_attempts` — append-only audit log. One row per HTTP attempt +//! regardless of outcome. Used to compute mirror success rates and as raw +//! forensics for stuck downloads. +//! +//! * `meta` — small key/value bag for the schema version and per-status +//! enumerate cursor checkpoints. +//! +//! All public methods take `&self` and serialize through the inner mutex, so +//! the same `StateDb` can be shared across worker tasks (`Arc`). +//! Calls are short and serialized blocking operations on the connection — for +//! our scale (~37k rows + ~tens of thousands of attempts), this is well +//! within rusqlite's comfort zone. + +use std::path::Path; +use std::sync::Mutex; +use std::time::{SystemTime, UNIX_EPOCH}; + +use anyhow::{Context, Result}; +use rusqlite::{params, Connection, OptionalExtension, Transaction}; + +use crate::discover::{DiscoveryAggregate, DiscoveryEntry}; +use crate::RankedStatus; + +pub const SCHEMA_VERSION: i64 = 2; + +/// Lifecycle states for a beatmapset row. +/// +/// `pending` rows are eligible for download workers. `in_progress` is held +/// only while a worker is actively fetching; on startup, any leftover +/// `in_progress` is reset to `pending` so a crashed worker doesn't strand its +/// claim. Terminal states (`success`, `failed`, `missing`) require explicit +/// user action (e.g. `retry`) to re-enter the queue. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum DownloadStatus { + Pending, + InProgress, + Success, + Failed, + Missing, +} + +impl DownloadStatus { + pub fn as_str(self) -> &'static str { + match self { + DownloadStatus::Pending => "pending", + DownloadStatus::InProgress => "in_progress", + DownloadStatus::Success => "success", + DownloadStatus::Failed => "failed", + DownloadStatus::Missing => "missing", + } + } + + pub fn parse(s: &str) -> Option { + Some(match s { + "pending" => DownloadStatus::Pending, + "in_progress" => DownloadStatus::InProgress, + "success" => DownloadStatus::Success, + "failed" => DownloadStatus::Failed, + "missing" => DownloadStatus::Missing, + _ => return None, + }) + } +} + +/// Snapshot of the queue used by `status`. +#[derive(Clone, Debug, Default)] +pub struct StatusCounts { + pub wanted: u64, + pub pending: u64, + pub in_progress: u64, + pub success: u64, + pub failed: u64, + pub missing: u64, +} + +/// One outcome of a single HTTP attempt against a mirror. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum AttemptOutcome { + Success, + NotFound, + HttpError, + RateLimited, + Network, + InvalidArchive, + /// Per-attempt deadline elapsed before the mirror returned a response. + Timeout, +} + +impl AttemptOutcome { + pub fn as_str(self) -> &'static str { + match self { + AttemptOutcome::Success => "success", + AttemptOutcome::NotFound => "not_found", + AttemptOutcome::HttpError => "http_error", + AttemptOutcome::RateLimited => "rate_limited", + AttemptOutcome::Network => "network", + AttemptOutcome::InvalidArchive => "invalid_archive", + AttemptOutcome::Timeout => "timeout", + } + } +} + +/// Wanted-set facts harvested from the osu! API's beatmapset search. +pub struct WantedRow<'a> { + pub set_id: u64, + pub ranked_status: RankedStatus, + pub artist: Option<&'a str>, + pub title: Option<&'a str>, + pub creator: Option<&'a str>, + pub api_last_updated: Option<&'a str>, +} + +/// Acquisition-side update written when a download succeeds. +pub struct DownloadSuccess<'a> { + pub set_id: u64, + pub mirror: &'a str, + pub bytes: u64, + pub sha256: &'a str, + pub flavor: &'a str, + pub saved_path: &'a str, +} + +/// Acquisition-side update written when a download fails (transient). +pub struct DownloadFailure<'a> { + pub set_id: u64, + pub mirror: &'a str, + pub error: &'a str, +} + +pub struct StateDb { + inner: Mutex, +} + +impl StateDb { + /// Open or create the state database at `path`. The schema is applied + /// idempotently — opening an existing DB is a no-op once `schema_version` + /// matches `SCHEMA_VERSION`. + pub fn open(path: impl AsRef) -> Result { + let conn = Connection::open(path.as_ref()) + .with_context(|| format!("opening state DB at {:?}", path.as_ref()))?; + Self::configure_and_migrate(&conn)?; + Ok(Self { + inner: Mutex::new(conn), + }) + } + + /// Build an in-memory state DB. Useful for tests. + pub fn open_memory() -> Result { + let conn = Connection::open_in_memory()?; + Self::configure_and_migrate(&conn)?; + Ok(Self { + inner: Mutex::new(conn), + }) + } + + fn configure_and_migrate(conn: &Connection) -> Result<()> { + // WAL gives us the resilience profile we want for crash recovery. + conn.pragma_update(None, "journal_mode", "WAL")?; + conn.pragma_update(None, "synchronous", "NORMAL")?; + conn.pragma_update(None, "foreign_keys", "ON")?; + + conn.execute_batch(SCHEMA_SQL)?; + + // Stamp + future-proof the schema version. + let now = unix_now(); + conn.execute( + "INSERT INTO meta(key, value, updated_at) VALUES('schema_version', ?, ?) + ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at", + params![SCHEMA_VERSION.to_string(), now], + )?; + Ok(()) + } + + /// Reset stale `in_progress` rows from a prior run back to `pending`. + /// Run at startup before dispatching workers. + pub fn requeue_in_progress(&self) -> Result { + let conn = self.lock(); + let n = conn.execute( + "UPDATE sets SET download_status = 'pending' + WHERE download_status = 'in_progress'", + [], + )?; + Ok(n as u64) + } + + /// Insert or refresh a `wanted` row. + /// + /// Existing acquisition columns are preserved unless the API reports a + /// strictly newer `last_updated` than the row currently records. In that + /// case a terminal acquisition row is moved back to `pending` so the + /// updater downloads the new `.osz` revision instead of treating the old + /// compact dataset entry as current. + pub fn upsert_wanted(&self, row: &WantedRow<'_>) -> Result<()> { + let conn = self.lock(); + let now = unix_now(); + conn.execute( + "INSERT INTO sets(set_id, wanted, ranked_status, artist, title, creator, + api_last_updated, discovered_at, download_status) + VALUES(?, 1, ?, ?, ?, ?, ?, ?, 'pending') + ON CONFLICT(set_id) DO UPDATE SET + wanted = 1, + ranked_status = excluded.ranked_status, + artist = COALESCE(excluded.artist, sets.artist), + title = COALESCE(excluded.title, sets.title), + creator = COALESCE(excluded.creator, sets.creator), + api_last_updated = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND ( + sets.api_last_updated IS NULL + OR excluded.api_last_updated > sets.api_last_updated + ) + THEN excluded.api_last_updated + ELSE sets.api_last_updated + END, + discovered_at = COALESCE(sets.discovered_at, excluded.discovered_at), + download_status = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN 'pending' + ELSE sets.download_status + END, + last_error = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN NULL + ELSE sets.last_error + END, + bytes = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN NULL + ELSE sets.bytes + END, + sha256 = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN NULL + ELSE sets.sha256 + END, + flavor = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN NULL + ELSE sets.flavor + END, + saved_path = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN NULL + ELSE sets.saved_path + END, + completed_at = CASE + WHEN excluded.api_last_updated IS NOT NULL + AND sets.api_last_updated IS NOT NULL + AND excluded.api_last_updated > sets.api_last_updated + AND sets.download_status IN ('success', 'failed', 'missing') + THEN NULL + ELSE sets.completed_at + END", + params![ + row.set_id as i64, + row.ranked_status.as_api_str(), + row.artist, + row.title, + row.creator, + row.api_last_updated, + now, + ], + )?; + Ok(()) + } + + /// Mark `set_id` as already on disk (e.g. from a `scan` pass). Sets the + /// download_status to `success` and records the path. Does not require + /// the row to already exist — scan can find archives the API didn't list. + pub fn record_present(&self, set_id: u64, saved_path: &str, bytes: u64) -> Result<()> { + let conn = self.lock(); + let now = unix_now(); + conn.execute( + "INSERT INTO sets(set_id, wanted, download_status, saved_path, bytes, + completed_at, discovered_at) + VALUES(?, 0, 'success', ?, ?, ?, ?) + ON CONFLICT(set_id) DO UPDATE SET + download_status = 'success', + saved_path = excluded.saved_path, + bytes = excluded.bytes, + completed_at = excluded.completed_at, + discovered_at = COALESCE(sets.discovered_at, excluded.discovered_at)", + params![set_id as i64, saved_path, bytes as i64, now, now], + )?; + Ok(()) + } + + /// Atomically claim the next pending set for a worker. Returns `None` if + /// the queue is empty. + /// + /// We pick the lowest set_id first so workers progress through the + /// catalog in a predictable order. The `RETURNING` clause keeps the claim + /// in one round-trip. + pub fn claim_next_pending(&self) -> Result> { + let conn = self.lock(); + let now = unix_now(); + let id: Option = conn + .query_row( + "UPDATE sets + SET download_status = 'in_progress', + last_attempt_at = ? + WHERE set_id = ( + SELECT set_id FROM sets + WHERE download_status = 'pending' AND wanted = 1 + ORDER BY set_id + LIMIT 1 + ) + RETURNING set_id", + params![now], + |r| r.get::<_, i64>(0), + ) + .optional()?; + Ok(id.map(|n| n as u64)) + } + + /// Mark a previously-claimed `set_id` back as pending. Used on graceful + /// shutdown to release the worker's claim. + pub fn release_claim(&self, set_id: u64) -> Result<()> { + let conn = self.lock(); + conn.execute( + "UPDATE sets SET download_status = 'pending' + WHERE set_id = ? AND download_status = 'in_progress'", + params![set_id as i64], + )?; + Ok(()) + } + + pub fn record_attempt( + &self, + set_id: u64, + mirror: &str, + outcome: AttemptOutcome, + http_status: Option, + bytes: Option, + duration_ms: Option, + error: Option<&str>, + ) -> Result<()> { + let conn = self.lock(); + let now = unix_now(); + conn.execute( + "INSERT INTO mirror_attempts(set_id, mirror, attempted_at, duration_ms, + http_status, bytes, outcome, error) + VALUES(?, ?, ?, ?, ?, ?, ?, ?)", + params![ + set_id as i64, + mirror, + now, + duration_ms.map(|n| n as i64), + http_status.map(|n| n as i64), + bytes.map(|n| n as i64), + outcome.as_str(), + error, + ], + )?; + Ok(()) + } + + pub fn finish_success(&self, s: &DownloadSuccess<'_>) -> Result<()> { + let conn = self.lock(); + let now = unix_now(); + let mut tx_conn = conn; + let tx = tx_conn.transaction()?; + tx.execute( + "UPDATE sets SET + download_status = 'success', + last_mirror = ?, + last_attempt_at = ?, + attempts = attempts + 1, + bytes = ?, + sha256 = ?, + flavor = ?, + saved_path = ?, + completed_at = ?, + last_error = NULL + WHERE set_id = ?", + params![ + s.mirror, + now, + s.bytes as i64, + s.sha256, + s.flavor, + s.saved_path, + now, + s.set_id as i64, + ], + )?; + tx.commit()?; + Ok(()) + } + + pub fn finish_failed(&self, f: &DownloadFailure<'_>) -> Result<()> { + self.finish_terminal(f, DownloadStatus::Failed) + } + + pub fn finish_missing(&self, f: &DownloadFailure<'_>) -> Result<()> { + self.finish_terminal(f, DownloadStatus::Missing) + } + + fn finish_terminal(&self, f: &DownloadFailure<'_>, st: DownloadStatus) -> Result<()> { + let conn = self.lock(); + let now = unix_now(); + let mut tx_conn = conn; + let tx = tx_conn.transaction()?; + tx.execute( + "UPDATE sets SET + download_status = ?, + last_mirror = ?, + last_attempt_at = ?, + attempts = attempts + 1, + last_error = ? + WHERE set_id = ?", + params![st.as_str(), f.mirror, now, f.error, f.set_id as i64], + )?; + tx.commit()?; + Ok(()) + } + + /// Reset terminal failed/missing rows back to pending so the next + /// `download` run will retry them. Returns the count moved. + pub fn reset_failed_to_pending(&self) -> Result { + let conn = self.lock(); + let n = conn.execute( + "UPDATE sets SET download_status = 'pending', last_error = NULL + WHERE download_status IN ('failed', 'missing')", + [], + )?; + Ok(n as u64) + } + + /// Mark a specific set's on-disk archive as corrupt: status → pending, + /// blob metadata cleared so the next `download` overwrites cleanly. + /// Used by `verify --fix`; idempotent. + pub fn mark_archive_corrupt(&self, set_id: u64) -> Result<()> { + let conn = self.lock(); + conn.execute( + "UPDATE sets SET + download_status = 'pending', + bytes = NULL, + sha256 = NULL, + flavor = NULL, + saved_path = NULL, + last_error = 'verify: corrupt archive' + WHERE set_id = ?", + params![set_id as i64], + )?; + Ok(()) + } + + /// Count rows that a `download` worker can or will touch this run: + /// `pending` (eligible) + `in_progress` (currently claimed; will be + /// requeued on startup). Used to give the progress bar a real ceiling. + pub fn count_pending_wanted(&self) -> Result { + let conn = self.lock(); + let n: i64 = conn.query_row( + "SELECT COUNT(*) FROM sets + WHERE wanted = 1 AND download_status IN ('pending', 'in_progress')", + [], + |r| r.get(0), + )?; + Ok(n as u64) + } + + pub fn status_counts(&self) -> Result { + let conn = self.lock(); + let mut counts = StatusCounts::default(); + + counts.wanted = conn.query_row("SELECT COUNT(*) FROM sets WHERE wanted = 1", [], |r| { + r.get::<_, i64>(0) + })? as u64; + + let mut stmt = + conn.prepare("SELECT download_status, COUNT(*) FROM sets GROUP BY download_status")?; + let rows = stmt.query_map([], |r| { + let st: String = r.get(0)?; + let c: i64 = r.get(1)?; + Ok((st, c as u64)) + })?; + for row in rows { + let (st, c) = row?; + match st.as_str() { + "pending" => counts.pending = c, + "in_progress" => counts.in_progress = c, + "success" => counts.success = c, + "failed" => counts.failed = c, + "missing" => counts.missing = c, + _ => (), + } + } + Ok(counts) + } + + /// Persist a per-status enumerate cursor so a crashed enumerate can resume + /// from where it left off. + pub fn set_enumerate_cursor(&self, status: RankedStatus, cursor: Option<&str>) -> Result<()> { + let conn = self.lock(); + let key = format!("enumerate.cursor.{}", status.as_api_str()); + let now = unix_now(); + match cursor { + Some(c) => { + conn.execute( + "INSERT INTO meta(key, value, updated_at) VALUES(?, ?, ?) + ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at", + params![key, c, now], + )?; + } + None => { + conn.execute("DELETE FROM meta WHERE key = ?", params![key])?; + } + } + Ok(()) + } + + pub fn get_enumerate_cursor(&self, status: RankedStatus) -> Result> { + let conn = self.lock(); + let key = format!("enumerate.cursor.{}", status.as_api_str()); + let v: Option = conn + .query_row("SELECT value FROM meta WHERE key = ?", params![key], |r| { + r.get(0) + }) + .optional()?; + Ok(v) + } + + /// Persist the high-water mark of `last_updated` from the most recent + /// *successful* enumerate of `status`. Used by incremental enumerate to + /// stop pagination once it hits already-known entries. + pub fn set_enumerate_high_water( + &self, + status: RankedStatus, + value: Option<&str>, + ) -> Result<()> { + let conn = self.lock(); + let key = format!("enumerate.high_water.{}", status.as_api_str()); + let now = unix_now(); + match value { + Some(v) => { + conn.execute( + "INSERT INTO meta(key, value, updated_at) VALUES(?, ?, ?) + ON CONFLICT(key) DO UPDATE SET value=excluded.value, updated_at=excluded.updated_at", + params![key, v, now], + )?; + } + None => { + conn.execute("DELETE FROM meta WHERE key = ?", params![key])?; + } + } + Ok(()) + } + + pub fn get_enumerate_high_water(&self, status: RankedStatus) -> Result> { + let conn = self.lock(); + let key = format!("enumerate.high_water.{}", status.as_api_str()); + let v: Option = conn + .query_row("SELECT value FROM meta WHERE key = ?", params![key], |r| { + r.get(0) + }) + .optional()?; + Ok(v) + } + + /// Upsert one (mirror, set) report from `discover_all`. Updating the row + /// if it already exists is the right semantics — a mirror's view can + /// shift between runs (a set re-ranks, a creator gets restored), and we + /// want the freshest claim per mirror to drive the aggregator. + pub fn record_discovery(&self, mirror: &str, entry: &DiscoveryEntry) -> Result<()> { + let conn = self.lock(); + let now = unix_now(); + conn.execute( + "INSERT INTO mirror_discoveries(set_id, mirror, claimed_status, has_osu_std, + mirror_last_updated, last_seen_at) + VALUES(?, ?, ?, ?, ?, ?) + ON CONFLICT(set_id, mirror) DO UPDATE SET + claimed_status = excluded.claimed_status, + has_osu_std = excluded.has_osu_std, + mirror_last_updated = excluded.mirror_last_updated, + last_seen_at = excluded.last_seen_at", + params![ + entry.set_id as i64, + mirror, + entry.claimed_status.as_api_str(), + if entry.has_osu_std { 1i64 } else { 0i64 }, + entry.mirror_last_updated.as_deref(), + now, + ], + )?; + Ok(()) + } + + /// One stat line: distinct sets in `mirror_discoveries`, and how many of + /// them fall short of `min_quorum` mirrors. Used by the `discover` CLI + /// summary so the operator sees the recovery shape at a glance. + pub fn aggregate_discoveries(&self, min_quorum: u32) -> Result { + let conn = self.lock(); + let distinct_sets: i64 = conn.query_row( + "SELECT COUNT(DISTINCT set_id) FROM mirror_discoveries WHERE has_osu_std = 1", + [], + |r| r.get(0), + )?; + let sub_quorum: i64 = conn.query_row( + "SELECT COUNT(*) FROM ( + SELECT set_id, COUNT(DISTINCT mirror) AS m + FROM mirror_discoveries + WHERE has_osu_std = 1 + GROUP BY set_id + HAVING m < ? + )", + params![min_quorum as i64], + |r| r.get(0), + )?; + Ok(DiscoveryAggregate { + distinct_sets: distinct_sets as u64, + sub_quorum: sub_quorum as u64, + }) + } + + /// Sets that hit the quorum threshold but aren't `wanted = 1`. These are + /// the maps the official osu! API never told us about; promote them so + /// the existing download path picks them up. The chosen `ranked_status` + /// is the one most mirrors agree on (modal); ties resolve to the + /// strictest (Ranked > Approved > Qualified > Loved is *not* a real + /// ordering — we use the first encountered claim from `MIN(...)` as a + /// stable tiebreaker). + /// + /// Returns the number of rows newly upserted with `wanted = 1`. + pub fn promote_quorum_to_wanted(&self, min_quorum: u32) -> Result { + let conn = self.lock(); + let now = unix_now(); + // We use a single SQL pass for atomicity. The subquery picks the + // status with the most votes per set; if multiple statuses tie, + // SQLite returns one deterministically (lowest text). + let rows = conn.execute( + "INSERT INTO sets(set_id, wanted, ranked_status, discovered_at, download_status) + SELECT + d.set_id, + 1, + (SELECT claimed_status FROM mirror_discoveries d2 + WHERE d2.set_id = d.set_id AND d2.has_osu_std = 1 + GROUP BY claimed_status + ORDER BY COUNT(*) DESC, claimed_status ASC + LIMIT 1), + ?, + 'pending' + FROM mirror_discoveries d + WHERE d.has_osu_std = 1 + GROUP BY d.set_id + HAVING COUNT(DISTINCT d.mirror) >= ? + AND d.set_id NOT IN (SELECT set_id FROM sets WHERE wanted = 1) + ON CONFLICT(set_id) DO UPDATE SET + wanted = 1, + ranked_status = COALESCE(sets.ranked_status, excluded.ranked_status), + discovered_at = COALESCE(sets.discovered_at, excluded.discovered_at)", + params![now, min_quorum as i64], + )?; + Ok(rows as u64) + } + + /// Set IDs that have been reported by exactly `min_quorum - 1` mirrors — + /// one shy of meeting the quorum. The verifier pass uses this list to + /// concentrate its budget where it can actually flip an outcome. + pub fn list_singleton_discoveries(&self, min_quorum: u32) -> Result> { + let conn = self.lock(); + let target = min_quorum.saturating_sub(1).max(1) as i64; + let mut stmt = conn.prepare( + "SELECT set_id FROM mirror_discoveries + WHERE has_osu_std = 1 + GROUP BY set_id + HAVING COUNT(DISTINCT mirror) = ? + ORDER BY set_id", + )?; + let rows = stmt.query_map(params![target], |r| r.get::<_, i64>(0))?; + let mut ids = Vec::new(); + for row in rows { + ids.push(row? as u64); + } + Ok(ids) + } + + /// All mirror reports for a single set. Used by `status --set ` + /// (and tests) to inspect the per-set provenance. + pub fn list_discoveries_for_set( + &self, + set_id: u64, + ) -> Result, i64)>> { + let conn = self.lock(); + let mut stmt = conn.prepare( + "SELECT mirror, claimed_status, has_osu_std, mirror_last_updated, last_seen_at + FROM mirror_discoveries + WHERE set_id = ? + ORDER BY mirror", + )?; + let rows = stmt.query_map(params![set_id as i64], |r| { + Ok(( + r.get::<_, String>(0)?, + r.get::<_, String>(1)?, + r.get::<_, i64>(2)? != 0, + r.get::<_, Option>(3)?, + r.get::<_, i64>(4)?, + )) + })?; + let mut out = Vec::new(); + for row in rows { + out.push(row?); + } + Ok(out) + } + + fn lock(&self) -> std::sync::MutexGuard<'_, Connection> { + self.inner + .lock() + .unwrap_or_else(|poison| poison.into_inner()) + } +} + +const SCHEMA_SQL: &str = r#" +CREATE TABLE IF NOT EXISTS meta ( + key TEXT PRIMARY KEY, + value TEXT NOT NULL, + updated_at INTEGER NOT NULL +); + +CREATE TABLE IF NOT EXISTS sets ( + set_id INTEGER PRIMARY KEY, + wanted INTEGER NOT NULL DEFAULT 0, -- 0 or 1 + ranked_status TEXT, -- ranked|approved|loved|qualified + artist TEXT, + title TEXT, + creator TEXT, + api_last_updated TEXT, + discovered_at INTEGER, + + download_status TEXT NOT NULL DEFAULT 'pending', + attempts INTEGER NOT NULL DEFAULT 0, + last_error TEXT, + last_mirror TEXT, + last_attempt_at INTEGER, + bytes INTEGER, + sha256 TEXT, + flavor TEXT, + saved_path TEXT, + completed_at INTEGER +); + +CREATE INDEX IF NOT EXISTS idx_sets_status ON sets(download_status); +CREATE INDEX IF NOT EXISTS idx_sets_wanted_st ON sets(wanted, download_status); + +CREATE TABLE IF NOT EXISTS mirror_attempts ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + set_id INTEGER NOT NULL, + mirror TEXT NOT NULL, + attempted_at INTEGER NOT NULL, + duration_ms INTEGER, + http_status INTEGER, + bytes INTEGER, + outcome TEXT NOT NULL, + error TEXT, + FOREIGN KEY(set_id) REFERENCES sets(set_id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_attempts_set ON mirror_attempts(set_id); +CREATE INDEX IF NOT EXISTS idx_attempts_mirror ON mirror_attempts(mirror, outcome); + +-- Schema v2: cross-mirror discovery surface. One row per (set_id, mirror) +-- claim. Aggregating by `set_id` and counting distinct `mirror` is what +-- the quorum-promotion logic in `state::promote_quorum_to_wanted` runs. +-- We deliberately don't FK to `sets`: a discovery may exist for a set the +-- official API has never seen, and we want to insert the discovery row +-- before any matching `sets` row exists. +CREATE TABLE IF NOT EXISTS mirror_discoveries ( + set_id INTEGER NOT NULL, + mirror TEXT NOT NULL, + claimed_status TEXT NOT NULL, -- ranked|approved|loved|qualified + has_osu_std INTEGER NOT NULL, -- 0 or 1 + mirror_last_updated TEXT, -- ISO 8601, mirror's claim + last_seen_at INTEGER NOT NULL, -- unix sec, when we recorded it + PRIMARY KEY(set_id, mirror) +); + +CREATE INDEX IF NOT EXISTS idx_disc_set ON mirror_discoveries(set_id); +CREATE INDEX IF NOT EXISTS idx_disc_mirror ON mirror_discoveries(mirror); +CREATE INDEX IF NOT EXISTS idx_disc_status ON mirror_discoveries(claimed_status, has_osu_std); +"#; + +fn unix_now() -> i64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs() as i64 +} + +// Suppress unused warning until further phases call into Transaction directly. +#[allow(dead_code)] +fn _unused_marker(_t: &Transaction<'_>) {} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn schema_applies_idempotently() { + let _ = StateDb::open_memory().expect("first open"); + // The same in-memory DB can't be reopened (it's lost on drop), so + // re-apply the schema via a fresh handle and confirm no errors. + let _ = StateDb::open_memory().expect("second open"); + } + + #[test] + fn upsert_wanted_then_record_present_round_trips() { + let db = StateDb::open_memory().unwrap(); + db.upsert_wanted(&WantedRow { + set_id: 1, + ranked_status: RankedStatus::Ranked, + artist: Some("a"), + title: Some("t"), + creator: Some("c"), + api_last_updated: Some("2026-01-01"), + }) + .unwrap(); + db.record_present(1, "/p/1.osz", 1234).unwrap(); + let counts = db.status_counts().unwrap(); + assert_eq!(counts.wanted, 1); + assert_eq!(counts.success, 1); + } + + #[test] + fn newer_api_revision_requeues_terminal_acquisition() { + let db = StateDb::open_memory().unwrap(); + db.upsert_wanted(&WantedRow { + set_id: 1, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: Some("2026-01-01T00:00:00Z"), + }) + .unwrap(); + db.record_present(1, "/p/1.osz", 1234).unwrap(); + + db.upsert_wanted(&WantedRow { + set_id: 1, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: Some("2026-01-02T00:00:00Z"), + }) + .unwrap(); + + let counts = db.status_counts().unwrap(); + assert_eq!(counts.pending, 1); + assert_eq!(counts.success, 0); + + let conn = db.lock(); + let (status, path, api_last_updated): (String, Option, String) = conn + .query_row( + "SELECT download_status, saved_path, api_last_updated FROM sets WHERE set_id = 1", + [], + |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)), + ) + .unwrap(); + assert_eq!(status, "pending"); + assert_eq!(path, None); + assert_eq!(api_last_updated, "2026-01-02T00:00:00Z"); + } + + #[test] + fn first_api_timestamp_for_seeded_success_does_not_requeue() { + let db = StateDb::open_memory().unwrap(); + db.record_present(1, "compact://seed/1", 0).unwrap(); + + db.upsert_wanted(&WantedRow { + set_id: 1, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: Some("2026-01-02T00:00:00Z"), + }) + .unwrap(); + + let counts = db.status_counts().unwrap(); + assert_eq!(counts.success, 1); + assert_eq!(counts.pending, 0); + } + + #[test] + fn claim_next_pending_returns_lowest_id() { + let db = StateDb::open_memory().unwrap(); + for id in [3, 1, 2] { + db.upsert_wanted(&WantedRow { + set_id: id, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + } + assert_eq!(db.claim_next_pending().unwrap(), Some(1)); + assert_eq!(db.claim_next_pending().unwrap(), Some(2)); + assert_eq!(db.claim_next_pending().unwrap(), Some(3)); + assert_eq!(db.claim_next_pending().unwrap(), None); + } + + #[test] + fn requeue_in_progress_resets_stalled_claims() { + let db = StateDb::open_memory().unwrap(); + db.upsert_wanted(&WantedRow { + set_id: 1, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + let _ = db.claim_next_pending().unwrap(); + let n = db.requeue_in_progress().unwrap(); + assert_eq!(n, 1); + assert_eq!(db.claim_next_pending().unwrap(), Some(1)); + } + + #[test] + fn finish_success_marks_completed_and_records_blob_meta() { + let db = StateDb::open_memory().unwrap(); + db.upsert_wanted(&WantedRow { + set_id: 42, + ranked_status: RankedStatus::Loved, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + let _ = db.claim_next_pending().unwrap(); + db.finish_success(&DownloadSuccess { + set_id: 42, + mirror: "test", + bytes: 1024, + sha256: "abc", + flavor: "full", + saved_path: "/p/42.osz", + }) + .unwrap(); + let counts = db.status_counts().unwrap(); + assert_eq!(counts.success, 1); + assert_eq!(counts.pending, 0); + } + + #[test] + fn enumerate_high_water_persists_and_clears() { + let db = StateDb::open_memory().unwrap(); + assert_eq!( + db.get_enumerate_high_water(RankedStatus::Ranked).unwrap(), + None + ); + db.set_enumerate_high_water(RankedStatus::Ranked, Some("2026-04-26T12:34:56Z")) + .unwrap(); + assert_eq!( + db.get_enumerate_high_water(RankedStatus::Ranked).unwrap(), + Some("2026-04-26T12:34:56Z".into()) + ); + // Independent across statuses. + assert_eq!( + db.get_enumerate_high_water(RankedStatus::Loved).unwrap(), + None + ); + // Clearing. + db.set_enumerate_high_water(RankedStatus::Ranked, None) + .unwrap(); + assert_eq!( + db.get_enumerate_high_water(RankedStatus::Ranked).unwrap(), + None + ); + } + + #[test] + fn record_discovery_is_idempotent_per_mirror() { + // Recording the same (set, mirror) twice updates the row instead of + // double-counting it. This matters: an operator running `discover` + // back-to-back must not inflate the quorum count. + let db = StateDb::open_memory().unwrap(); + let entry = DiscoveryEntry { + set_id: 100, + claimed_status: RankedStatus::Loved, + has_osu_std: true, + mirror_last_updated: Some("2026-01-01T00:00:00Z".into()), + }; + db.record_discovery("nerinyan", &entry).unwrap(); + db.record_discovery("nerinyan", &entry).unwrap(); + let rows = db.list_discoveries_for_set(100).unwrap(); + assert_eq!(rows.len(), 1); + } + + #[test] + fn aggregate_counts_distinct_sets_and_sub_quorum() { + let db = StateDb::open_memory().unwrap(); + // set 1: 2 mirrors → meets quorum (>= 2) + // set 2: 1 mirror only → sub-quorum + // set 3: 3 mirrors → meets quorum + for (set_id, mirror) in [ + (1, "nerinyan"), + (1, "osudirect"), + (2, "nerinyan"), + (3, "nerinyan"), + (3, "osudirect"), + (3, "sayobot"), + ] { + db.record_discovery( + mirror, + &DiscoveryEntry { + set_id, + claimed_status: RankedStatus::Ranked, + has_osu_std: true, + mirror_last_updated: None, + }, + ) + .unwrap(); + } + let agg = db.aggregate_discoveries(2).unwrap(); + assert_eq!(agg.distinct_sets, 3); + assert_eq!(agg.sub_quorum, 1); + } + + #[test] + fn promote_quorum_to_wanted_only_promotes_above_threshold() { + let db = StateDb::open_memory().unwrap(); + // set 100 has 2 mirrors agreeing → should promote + // set 200 has 1 mirror only → should NOT promote + for (set_id, mirror) in [(100, "nerinyan"), (100, "osudirect"), (200, "nerinyan")] { + db.record_discovery( + mirror, + &DiscoveryEntry { + set_id, + claimed_status: RankedStatus::Loved, + has_osu_std: true, + mirror_last_updated: None, + }, + ) + .unwrap(); + } + let promoted = db.promote_quorum_to_wanted(2).unwrap(); + assert_eq!(promoted, 1); + let counts = db.status_counts().unwrap(); + assert_eq!(counts.wanted, 1); + assert_eq!(counts.pending, 1); + } + + #[test] + fn promote_picks_modal_status_when_mirrors_disagree() { + // Two mirrors say "loved", one says "ranked". The promoted row + // should carry the modal claim (loved). This is the only place + // we synthesize a status from disagreement, so a regression here + // would silently misclassify recovered sets. + let db = StateDb::open_memory().unwrap(); + for (mirror, status) in [ + ("nerinyan", RankedStatus::Loved), + ("osudirect", RankedStatus::Loved), + ("sayobot", RankedStatus::Ranked), + ] { + db.record_discovery( + mirror, + &DiscoveryEntry { + set_id: 7, + claimed_status: status, + has_osu_std: true, + mirror_last_updated: None, + }, + ) + .unwrap(); + } + db.promote_quorum_to_wanted(2).unwrap(); + + // Read back the upserted row. + let conn = db.lock(); + let st: String = conn + .query_row("SELECT ranked_status FROM sets WHERE set_id = 7", [], |r| { + r.get(0) + }) + .unwrap(); + assert_eq!(st, "loved"); + } + + #[test] + fn promote_does_not_overwrite_existing_wanted_row() { + // If the official enumerate already classified set X as ranked, + // the discovery aggregator must NOT downgrade the row to whatever + // a few mirrors happen to claim. Quorum promotion is for *new* + // sets; existing ones are managed by enumerate. + let db = StateDb::open_memory().unwrap(); + db.upsert_wanted(&WantedRow { + set_id: 42, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + for mirror in ["nerinyan", "osudirect"] { + db.record_discovery( + mirror, + &DiscoveryEntry { + set_id: 42, + claimed_status: RankedStatus::Loved, + has_osu_std: true, + mirror_last_updated: None, + }, + ) + .unwrap(); + } + let promoted = db.promote_quorum_to_wanted(2).unwrap(); + assert_eq!(promoted, 0, "existing wanted row must not be re-promoted"); + + let conn = db.lock(); + let st: String = conn + .query_row( + "SELECT ranked_status FROM sets WHERE set_id = 42", + [], + |r| r.get(0), + ) + .unwrap(); + assert_eq!(st, "ranked", "existing status must not be overwritten"); + } + + #[test] + fn singleton_list_returns_sets_one_short_of_quorum() { + // For min_quorum=2, sets seen on exactly 1 mirror are the candidates + // a verifier pass should target — the verifier's confirmation can + // push them to quorum. + let db = StateDb::open_memory().unwrap(); + for (set_id, mirror) in [ + (1, "nerinyan"), // singleton + (2, "nerinyan"), + (2, "osudirect"), // already at quorum + (3, "sayobot"), // singleton + ] { + db.record_discovery( + mirror, + &DiscoveryEntry { + set_id, + claimed_status: RankedStatus::Ranked, + has_osu_std: true, + mirror_last_updated: None, + }, + ) + .unwrap(); + } + let singletons = db.list_singleton_discoveries(2).unwrap(); + assert_eq!(singletons, vec![1, 3]); + } + + #[test] + fn discoveries_with_taiko_only_are_excluded_from_aggregation() { + // The aggregator gates on `has_osu_std = 1`; a taiko-only set + // recorded with has_osu_std=0 must not contribute to quorum even + // if multiple mirrors claim it. + let db = StateDb::open_memory().unwrap(); + for mirror in ["nerinyan", "osudirect", "sayobot"] { + db.record_discovery( + mirror, + &DiscoveryEntry { + set_id: 99, + claimed_status: RankedStatus::Ranked, + has_osu_std: false, + mirror_last_updated: None, + }, + ) + .unwrap(); + } + let agg = db.aggregate_discoveries(2).unwrap(); + assert_eq!(agg.distinct_sets, 0); + let promoted = db.promote_quorum_to_wanted(2).unwrap(); + assert_eq!(promoted, 0); + } + + #[test] + fn enumerate_cursor_persists() { + let db = StateDb::open_memory().unwrap(); + assert_eq!(db.get_enumerate_cursor(RankedStatus::Ranked).unwrap(), None); + db.set_enumerate_cursor(RankedStatus::Ranked, Some("abc123")) + .unwrap(); + assert_eq!( + db.get_enumerate_cursor(RankedStatus::Ranked).unwrap(), + Some("abc123".into()) + ); + db.set_enumerate_cursor(RankedStatus::Ranked, None).unwrap(); + assert_eq!(db.get_enumerate_cursor(RankedStatus::Ranked).unwrap(), None); + } +} diff --git a/crates/osu_fetcher/src/verify.rs b/crates/osu_fetcher/src/verify.rs new file mode 100644 index 0000000000000000000000000000000000000000..fb01c5c1171977815c3ece535fb2b40d6cf94993 --- /dev/null +++ b/crates/osu_fetcher/src/verify.rs @@ -0,0 +1,706 @@ +//! `.osz` archive validation. +//! +//! Two levels: +//! +//! * [`verify_bytes`] — cheap, in-memory check that the buffer is a real ZIP +//! and contains at least one `.osu` file. Used right after a download to +//! reject HTML error pages and truncated downloads before we write to disk. +//! +//! * [`verify_path`] — opens an on-disk archive and runs the same check. +//! Used by the `verify` subcommand to audit existing `archives/` content. +//! +//! * [`run_adaptive`] — bulk verification of every `.osz` in a directory with +//! an adaptive worker pool that hill-climbs concurrency to find the I/O +//! sweet spot for the underlying disk (especially HDDs, where too many +//! concurrent reads cause seek thrash and one-or-two workers may already be +//! saturating). + +use std::collections::VecDeque; +use std::fs::File; +use std::io::{Cursor, Read, Seek}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex as StdMutex}; +use std::time::{Duration, Instant}; + +use anyhow::{Context, Result}; +use indicatif::{HumanBytes, HumanDuration, ProgressBar, ProgressDrawTarget, ProgressStyle}; +use thiserror::Error; +use tokio::sync::Semaphore; +use tokio_util::sync::CancellationToken; +use zip::ZipArchive; + +use crate::scan::parse_set_id_from_filename; +use crate::state::StateDb; + +#[derive(Debug, Error)] +pub enum VerifyError { + #[error("archive bytes are empty")] + Empty, + + #[error("archive does not start with a ZIP magic")] + NotZip, + + #[error("ZIP open failed: {0}")] + OpenFailed(String), + + #[error("ZIP contains no `.osu` files (likely a wrong-payload mirror response)")] + NoOsuFiles, + + #[error("ZIP read I/O error: {0}")] + Io(#[from] std::io::Error), +} + +/// Quick magic-byte check + archive open + entry walk for at least one `.osu`. +/// +/// Doesn't try to fully decode every entry; we just need confidence that the +/// payload is a real beatmapset archive before committing it to disk. +pub fn verify_bytes(bytes: &[u8]) -> Result { + if bytes.is_empty() { + return Err(VerifyError::Empty); + } + if !is_zip_magic(bytes) { + return Err(VerifyError::NotZip); + } + let mut archive = + ZipArchive::new(Cursor::new(bytes)).map_err(|e| VerifyError::OpenFailed(e.to_string()))?; + walk(&mut archive) +} + +pub fn verify_path(path: &Path) -> Result { + let f = File::open(path) + .context("opening archive") + .map_err(|e| VerifyError::OpenFailed(format!("{}: {e}", path.display())))?; + let mut archive = ZipArchive::new(f).map_err(|e| VerifyError::OpenFailed(e.to_string()))?; + walk(&mut archive) +} + +#[derive(Clone, Debug, Default)] +pub struct ArchiveInfo { + pub osu_count: u32, + pub osb_count: u32, + pub other_count: u32, +} + +fn walk(archive: &mut ZipArchive) -> Result { + let mut info = ArchiveInfo::default(); + for i in 0..archive.len() { + // We deliberately swallow individual-entry decode errors so a single + // malformed filename doesn't fail the whole archive. The test for + // "is this a valid beatmapset" is "does it have `.osu` files". + let entry = match archive.by_index(i) { + Ok(e) => e, + Err(_) => continue, + }; + let name = entry.name().to_ascii_lowercase(); + if name.ends_with(".osu") { + info.osu_count += 1; + } else if name.ends_with(".osb") { + info.osb_count += 1; + } else { + info.other_count += 1; + } + } + if info.osu_count == 0 { + return Err(VerifyError::NoOsuFiles); + } + Ok(info) +} + +fn is_zip_magic(bytes: &[u8]) -> bool { + if bytes.len() < 4 { + return false; + } + let head = &bytes[..4]; + head == b"PK\x03\x04" || head == b"PK\x05\x06" || head == b"PK\x07\x08" +} + +// ===================================================================== +// Adaptive bulk verification +// ===================================================================== + +/// CLI-facing knobs for [`run_adaptive`]. +#[derive(Clone, Debug)] +pub struct AdaptiveVerifyOptions { + /// Lower bound on concurrent workers. The controller will not shrink + /// below this. Must be ≥ 1. + pub min_workers: usize, + /// Upper bound on concurrent workers. The controller will not grow + /// above this. Must be ≥ `min_workers`. + pub max_workers: usize, + /// If `Some(N)`, disables auto-tuning and pins the pool at `N`. + pub fixed_workers: Option, + /// Reset bad rows back to `pending` so the next `download` overwrites them. + pub fix: bool, + /// Render the live progress bar. Disable for CI / log redirection. + pub progress: bool, +} + +impl Default for AdaptiveVerifyOptions { + fn default() -> Self { + Self { + min_workers: 1, + max_workers: 8, + fixed_workers: None, + fix: false, + progress: true, + } + } +} + +#[derive(Clone, Debug, Default)] +pub struct VerifyStats { + pub total: u64, + pub bad: u64, + /// Files left unverified because the user hit Ctrl-C. + pub aborted_remaining: u64, +} + +#[derive(Default)] +struct VerifyCounters { + verified: AtomicU64, + bad: AtomicU64, + bytes: AtomicU64, +} + +/// Walk `archives_dir`, verify every `.osz`, and report bad ones. +/// +/// Spawns `max_workers` worker tasks; the live concurrency is gated by a +/// shared [`Semaphore`] whose available permits represent the current target +/// level. A controller task hill-climbs that level once every 5 s, raising +/// concurrency while throughput improves and reverting otherwise. After a +/// rejected grow the controller alternates to a shrink probe so the pool can +/// also discover lower local optima — useful on cold HDDs where 1–2 workers +/// often beats 4+. +/// +/// On Ctrl-C the [`CancellationToken`] fires; workers finish their current +/// file and exit, the partial summary is printed, and the function returns +/// normally with `aborted_remaining > 0`. +pub async fn run_adaptive( + state: Arc, + archives_dir: &Path, + opts: AdaptiveVerifyOptions, +) -> Result { + if opts.min_workers == 0 { + anyhow::bail!("min_workers must be ≥ 1"); + } + if opts.max_workers < opts.min_workers { + anyhow::bail!( + "max_workers ({}) must be ≥ min_workers ({})", + opts.max_workers, + opts.min_workers + ); + } + + if !archives_dir.exists() { + anyhow::bail!( + "archives directory does not exist: {}", + archives_dir.display() + ); + } + + // 1. Collect work. + let files = collect_archives(archives_dir).await?; + let total_files = files.len() as u64; + let queue = Arc::new(StdMutex::new(VecDeque::from(files))); + let counters = Arc::new(VerifyCounters::default()); + + // 2. Concurrency gate. We start by holding (max - start_level) permits in + // a "throttle pool" so only `start_level` workers can run at once; + // grow == add a permit, shrink == acquire-and-forget a permit. + let start_level = opts + .fixed_workers + .unwrap_or(2) + .clamp(opts.min_workers, opts.max_workers); + let sem = Arc::new(Semaphore::new(opts.max_workers)); + for _ in 0..(opts.max_workers - start_level) { + // We hold these permits forever (forget) until the controller + // chooses to release them by adding equivalent permits back. + sem.clone() + .acquire_owned() + .await + .expect("semaphore not closed") + .forget(); + } + let level = Arc::new(AtomicUsize::new(start_level)); + + // 3. Progress. + let pb = build_progress_bar(total_files, opts.progress); + + let cancel = CancellationToken::new(); + + // 4. Workers. + let mut handles = Vec::with_capacity(opts.max_workers); + for _ in 0..opts.max_workers { + let s = sem.clone(); + let q = queue.clone(); + let c = counters.clone(); + let st = state.clone(); + let cx = cancel.clone(); + let pbx = pb.clone(); + let fix = opts.fix; + handles.push(tokio::spawn(async move { + worker_loop(s, q, c, st, cx, pbx, fix).await; + })); + } + + // 5. Controller (only when adaptive). + let controller_handle = if opts.fixed_workers.is_none() && opts.min_workers != opts.max_workers + { + let s = sem.clone(); + let l = level.clone(); + let c = counters.clone(); + let cx = cancel.clone(); + Some(tokio::spawn(controller_loop( + s, + l, + c, + cx, + opts.min_workers, + opts.max_workers, + ))) + } else { + None + }; + + // 6. Ctrl-C → cancel. + let cancel_for_signal = cancel.clone(); + let signal_handle = tokio::spawn(async move { + let _ = tokio::signal::ctrl_c().await; + cancel_for_signal.cancel(); + }); + + // 7. Progress refresh. + let refresh_handle = { + let pbx = pb.clone(); + let lvl = level.clone(); + let cnt = counters.clone(); + let cx = cancel.clone(); + let started = Instant::now(); + tokio::spawn(async move { + let mut interval = tokio::time::interval(Duration::from_millis(250)); + interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); + let active = Arc::new(AtomicBool::new(true)); + while active.load(Ordering::Relaxed) { + tokio::select! { + _ = cx.cancelled() => { active.store(false, Ordering::Relaxed); } + _ = interval.tick() => {} + } + if let Some(pb) = &pbx { + refresh_progress(pb, &cnt, lvl.load(Ordering::Relaxed), started, total_files); + } + } + }) + }; + + // 8. Wait for workers (they exit when queue empties or cancel fires). + for h in handles { + let _ = h.await; + } + + // Workers done; tear down the helpers. + cancel.cancel(); + if let Some(h) = controller_handle { + let _ = h.await; + } + let _ = refresh_handle.await; + signal_handle.abort(); + let _ = signal_handle.await; + + let verified = counters.verified.load(Ordering::Relaxed); + let bad = counters.bad.load(Ordering::Relaxed); + let remaining = total_files.saturating_sub(verified); + + if let Some(pb) = &pb { + pb.finish_and_clear(); + } + + if remaining > 0 { + println!("verified {verified} archives ({bad} bad); {remaining} skipped due to abort"); + } else { + println!("verified {verified} archives ({bad} bad)"); + } + + Ok(VerifyStats { + total: verified, + bad, + aborted_remaining: remaining, + }) +} + +async fn collect_archives(archives_dir: &Path) -> Result> { + let mut out = Vec::new(); + let mut entries = tokio::fs::read_dir(archives_dir) + .await + .context("read archives_dir")?; + while let Some(entry) = entries.next_entry().await? { + let path = entry.path(); + if let Some(set_id) = parse_set_id_from_filename(&path) { + out.push((set_id, path)); + } + } + Ok(out) +} + +async fn worker_loop( + sem: Arc, + queue: Arc>>, + counters: Arc, + state: Arc, + cancel: CancellationToken, + pb: Option, + fix: bool, +) { + loop { + let permit = tokio::select! { + _ = cancel.cancelled() => return, + p = sem.clone().acquire_owned() => match p { + Ok(p) => p, + Err(_) => return, + }, + }; + + let next = { + let mut q = queue.lock().unwrap_or_else(|e| e.into_inner()); + q.pop_front() + }; + let Some((set_id, path)) = next else { + // Queue drained; dropping the permit lets siblings exit too. + return; + }; + + if cancel.is_cancelled() { + return; + } + + let p_for_thread = path.clone(); + let result = tokio::task::spawn_blocking(move || verify_path(&p_for_thread)).await; + + let bytes = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0); + match result { + Ok(Ok(_info)) => { + counters.verified.fetch_add(1, Ordering::Relaxed); + counters.bytes.fetch_add(bytes, Ordering::Relaxed); + } + Ok(Err(e)) => { + counters.verified.fetch_add(1, Ordering::Relaxed); + counters.bad.fetch_add(1, Ordering::Relaxed); + let line = format!("BAD {set_id} {}: {e}", path.display()); + if let Some(pb) = &pb { + pb.println(line); + } else { + println!("{line}"); + } + if fix { + if let Err(e) = state.mark_archive_corrupt(set_id) { + let warn = format!("warn: mark_archive_corrupt({set_id}) failed: {e}"); + if let Some(pb) = &pb { + pb.println(warn); + } else { + eprintln!("{warn}"); + } + } + } + } + Err(join_err) => { + let line = format!( + "WARN verify task panicked for {set_id} at {}: {join_err}", + path.display() + ); + if let Some(pb) = &pb { + pb.println(line); + } else { + eprintln!("{line}"); + } + } + } + + if let Some(pb) = &pb { + pb.inc(1); + } + + drop(permit); + } +} + +// ----- adaptive controller ----- + +/// What happened in the last completed probe. Drives the *next* probe +/// direction so we don't endlessly retry an already-rejected change. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +enum LastOutcome { + /// First probe of the run. + Initial, + GrowKept, + GrowReverted, + ShrinkKept, + ShrinkReverted, +} + +#[derive(Clone, Copy, Debug)] +enum ControllerState { + /// Sit idle until `until`; build a baseline rate measurement, then probe. + Cooldown { until: Instant, last: LastOutcome }, + /// Just applied +1 worker; decide on next tick whether it helped. + ProbingGrow { baseline_rate: f64 }, + /// Just applied -1 worker; decide on next tick whether it cost throughput. + ProbingShrink { baseline_rate: f64 }, +} + +const TICK: Duration = Duration::from_secs(5); +const COOLDOWN: Duration = Duration::from_secs(60); +const GROW_THRESHOLD: f64 = 1.05; // need ≥ +5% rate to keep an extra worker +const SHRINK_THRESHOLD: f64 = 0.98; // accept shrink that loses ≤ 2% throughput + +async fn controller_loop( + sem: Arc, + level: Arc, + counters: Arc, + cancel: CancellationToken, + min: usize, + max: usize, +) { + let mut interval = tokio::time::interval(TICK); + interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay); + // Skip the immediate first tick so we have a real measurement window. + interval.tick().await; + + let mut last_count = counters.verified.load(Ordering::Relaxed); + let mut last_at = Instant::now(); + let mut state = ControllerState::Cooldown { + until: Instant::now() + Duration::from_secs(15), + last: LastOutcome::Initial, + }; + + loop { + tokio::select! { + _ = cancel.cancelled() => return, + _ = interval.tick() => {} + } + + let now = Instant::now(); + let count = counters.verified.load(Ordering::Relaxed); + let elapsed = now.saturating_duration_since(last_at).as_secs_f64(); + let rate = if elapsed > 0.0 { + (count - last_count) as f64 / elapsed + } else { + 0.0 + }; + last_count = count; + last_at = now; + + match state { + ControllerState::Cooldown { until, last } if now < until => { + // Building rate baseline; nothing to do. + let _ = (until, last); + } + ControllerState::Cooldown { last, .. } => { + // Cooldown elapsed → choose the next probe direction. + let cur = level.load(Ordering::Relaxed); + let prefer_shrink = + matches!(last, LastOutcome::GrowReverted | LastOutcome::ShrinkKept); + if prefer_shrink && cur > min { + apply_shrink(&sem); + level.store(cur - 1, Ordering::Relaxed); + state = ControllerState::ProbingShrink { + baseline_rate: rate, + }; + } else if cur < max { + sem.add_permits(1); + level.store(cur + 1, Ordering::Relaxed); + state = ControllerState::ProbingGrow { + baseline_rate: rate, + }; + } else if cur > min { + apply_shrink(&sem); + level.store(cur - 1, Ordering::Relaxed); + state = ControllerState::ProbingShrink { + baseline_rate: rate, + }; + } else { + // Pinned (min == max); just keep cooling down. + state = ControllerState::Cooldown { + until: now + COOLDOWN, + last, + }; + } + } + ControllerState::ProbingGrow { baseline_rate } => { + if rate > baseline_rate * GROW_THRESHOLD { + // Win: try to keep climbing on the next tick. + let cur = level.load(Ordering::Relaxed); + if cur < max { + sem.add_permits(1); + level.store(cur + 1, Ordering::Relaxed); + state = ControllerState::ProbingGrow { + baseline_rate: rate, + }; + } else { + state = ControllerState::Cooldown { + until: now + COOLDOWN, + last: LastOutcome::GrowKept, + }; + } + } else { + // No improvement → revert. + apply_shrink(&sem); + let cur = level.load(Ordering::Relaxed); + level.store(cur.saturating_sub(1).max(min), Ordering::Relaxed); + state = ControllerState::Cooldown { + until: now + COOLDOWN, + last: LastOutcome::GrowReverted, + }; + } + } + ControllerState::ProbingShrink { baseline_rate } => { + if rate >= baseline_rate * SHRINK_THRESHOLD { + // Throughput held → keep the lower level. + let cur = level.load(Ordering::Relaxed); + if cur > min { + apply_shrink(&sem); + level.store(cur - 1, Ordering::Relaxed); + state = ControllerState::ProbingShrink { + baseline_rate: rate, + }; + } else { + state = ControllerState::Cooldown { + until: now + COOLDOWN, + last: LastOutcome::ShrinkKept, + }; + } + } else { + // Lost too much throughput → revert. + sem.add_permits(1); + let cur = level.load(Ordering::Relaxed); + level.store((cur + 1).min(max), Ordering::Relaxed); + state = ControllerState::Cooldown { + until: now + COOLDOWN, + last: LastOutcome::ShrinkReverted, + }; + } + } + } + } +} + +fn apply_shrink(sem: &Arc) { + // Acquire-and-forget pulls one permit out of circulation. Spawned so the + // controller never blocks waiting for an in-use permit. + let s = sem.clone(); + tokio::spawn(async move { + if let Ok(p) = s.acquire_owned().await { + p.forget(); + } + }); +} + +// ----- progress ----- + +fn build_progress_bar(total: u64, enabled: bool) -> Option { + if !enabled { + return None; + } + let pb = ProgressBar::with_draw_target(Some(total), ProgressDrawTarget::stderr()); + pb.set_style( + ProgressStyle::with_template( + " [{bar:40.cyan/blue}] {pos:>6}/{len:<6} {percent:>3}% · {msg}", + ) + .unwrap() + .progress_chars("█▉▊▋▌▍▎▏ "), + ); + pb.set_message("starting…"); + Some(pb) +} + +fn refresh_progress( + pb: &ProgressBar, + counters: &VerifyCounters, + workers: usize, + started: Instant, + total: u64, +) { + let verified = counters.verified.load(Ordering::Relaxed); + let bad = counters.bad.load(Ordering::Relaxed); + let bytes = counters.bytes.load(Ordering::Relaxed); + let elapsed = started.elapsed(); + let secs = elapsed.as_secs_f64().max(0.001); + let fps = verified as f64 / secs; + let bps = (bytes as f64 / secs) as u64; + let eta = if fps > 0.05 && total > verified { + let remaining_secs = ((total - verified) as f64 / fps) as u64; + format!("{}", HumanDuration(Duration::from_secs(remaining_secs))) + } else { + "—".to_string() + }; + pb.set_position(verified); + pb.set_message(format!( + "{:>5.1} files/s · {}/s · workers {workers} · ETA {eta} · bad {bad}", + fps, + HumanBytes(bps), + )); +} + +#[cfg(test)] +mod tests { + use super::*; + use std::io::Write; + + fn make_minimal_osz() -> Vec { + let mut buf = Vec::new(); + { + let mut zw = zip::ZipWriter::new(Cursor::new(&mut buf)); + zw.start_file::<&str, ()>( + "Artist - Title (Mapper) [Easy].osu", + zip::write::SimpleFileOptions::default(), + ) + .unwrap(); + zw.write_all(b"osu file format v14\n").unwrap(); + zw.finish().unwrap(); + } + buf + } + + #[test] + fn verify_bytes_accepts_minimal_osz() { + let bytes = make_minimal_osz(); + let info = verify_bytes(&bytes).unwrap(); + assert_eq!(info.osu_count, 1); + assert_eq!(info.osb_count, 0); + } + + #[test] + fn verify_bytes_rejects_empty() { + assert!(matches!(verify_bytes(&[]), Err(VerifyError::Empty))); + } + + #[test] + fn verify_bytes_rejects_html_error_page() { + let html = b"error"; + assert!(matches!(verify_bytes(html), Err(VerifyError::NotZip))); + } + + #[test] + fn verify_bytes_rejects_zip_without_osu_files() { + // Minimal ZIP containing a single non-.osu entry. + let mut buf = Vec::new(); + { + let mut zw = zip::ZipWriter::new(Cursor::new(&mut buf)); + zw.start_file::<&str, ()>("background.jpg", zip::write::SimpleFileOptions::default()) + .unwrap(); + zw.write_all(b"\xff\xd8\xff").unwrap(); + zw.finish().unwrap(); + } + assert!(matches!(verify_bytes(&buf), Err(VerifyError::NoOsuFiles))); + } + + #[test] + fn verify_bytes_rejects_truncated_zip() { + // First 4 bytes are valid magic but the rest is garbage. + let truncated = b"PK\x03\x04garbage_truncated_archive"; + let err = verify_bytes(truncated).expect_err("expected error on truncated zip"); + assert!(matches!( + err, + VerifyError::OpenFailed(_) | VerifyError::NoOsuFiles + )); + } +} diff --git a/crates/osu_fetcher/tests/classify_response.rs b/crates/osu_fetcher/tests/classify_response.rs new file mode 100644 index 0000000000000000000000000000000000000000..d9dcb7cd7456365282ea7b9cd791cc4d7208c37b --- /dev/null +++ b/crates/osu_fetcher/tests/classify_response.rs @@ -0,0 +1,176 @@ +//! Failure-mode test: a mirror that returns 200 with garbage must NOT be +//! treated as success — `classify_response` must reject the body via deep +//! `verify_bytes` and surface `MirrorError::InvalidArchive`. +//! +//! Without this guard, the very first mirror in the pool's order can poison +//! the run: 200-OK + non-osz bytes would be written to disk and committed +//! to the state DB as `success`. Re-running download would skip the row, +//! so the bad file would persist until manually purged. This test exercises +//! the production path end-to-end via wiremock. + +use std::io::Write; + +use osu_fetcher::mirrors::{build_client, MirrorError}; +use wiremock::matchers::{method, path}; +use wiremock::{Mock, MockServer, ResponseTemplate}; + +fn make_minimal_osz() -> Vec { + let mut buf = Vec::new(); + { + let mut zw = zip::ZipWriter::new(std::io::Cursor::new(&mut buf)); + zw.start_file::<&str, ()>( + "Stub - X (Y) [N].osu", + zip::write::SimpleFileOptions::default(), + ) + .unwrap(); + zw.write_all(b"osu file format v14\n").unwrap(); + zw.finish().unwrap(); + } + buf +} + +fn make_zip_without_osu_files() -> Vec { + let mut buf = Vec::new(); + { + let mut zw = zip::ZipWriter::new(std::io::Cursor::new(&mut buf)); + zw.start_file::<&str, ()>("bg.jpg", zip::write::SimpleFileOptions::default()) + .unwrap(); + zw.write_all(b"\xff\xd8\xff\xe0").unwrap(); + zw.finish().unwrap(); + } + buf +} + +#[tokio::test] +async fn pool_rejects_200_with_html_error_page() { + // We can't fully redirect the mirror's hardcoded base URL, so instead + // we exercise the `classify_response` helper through a custom Mirror + // impl that constructs a full reqwest::Response from the wiremock URL. + let server = MockServer::start().await; + Mock::given(method("GET")) + .and(path("/d/123")) + .respond_with( + ResponseTemplate::new(200).set_body_bytes(b"oops"), + ) + .mount(&server) + .await; + + let client = build_client().unwrap(); + let resp = client + .get(format!("{}/d/123", server.uri())) + .send() + .await + .unwrap(); + let result = osu_fetcher::mirrors::classify_response("test-mirror", resp).await; + let err = result.expect_err("expected InvalidArchive"); + assert!( + matches!(err, MirrorError::InvalidArchive { .. }), + "expected InvalidArchive, got {err:?}" + ); +} + +#[tokio::test] +async fn pool_rejects_200_with_truncated_zip() { + let server = MockServer::start().await; + // Valid PK\x03\x04 magic but truncated body — opens fail or no .osu inside. + Mock::given(method("GET")) + .and(path("/d/456")) + .respond_with(ResponseTemplate::new(200).set_body_bytes(b"PK\x03\x04truncated_bytes")) + .mount(&server) + .await; + + let client = build_client().unwrap(); + let resp = client + .get(format!("{}/d/456", server.uri())) + .send() + .await + .unwrap(); + let err = osu_fetcher::mirrors::classify_response("test-mirror", resp) + .await + .expect_err("expected InvalidArchive"); + assert!(matches!(err, MirrorError::InvalidArchive { .. })); +} + +#[tokio::test] +async fn pool_rejects_200_with_zip_lacking_osu_files() { + let server = MockServer::start().await; + Mock::given(method("GET")) + .and(path("/d/789")) + .respond_with(ResponseTemplate::new(200).set_body_bytes(make_zip_without_osu_files())) + .mount(&server) + .await; + + let client = build_client().unwrap(); + let resp = client + .get(format!("{}/d/789", server.uri())) + .send() + .await + .unwrap(); + let err = osu_fetcher::mirrors::classify_response("test-mirror", resp) + .await + .expect_err("expected InvalidArchive"); + assert!(matches!(err, MirrorError::InvalidArchive { .. })); +} + +#[tokio::test] +async fn pool_accepts_minimal_real_osz() { + let server = MockServer::start().await; + Mock::given(method("GET")) + .and(path("/d/100")) + .respond_with(ResponseTemplate::new(200).set_body_bytes(make_minimal_osz())) + .mount(&server) + .await; + + let client = build_client().unwrap(); + let resp = client + .get(format!("{}/d/100", server.uri())) + .send() + .await + .unwrap(); + let bytes = osu_fetcher::mirrors::classify_response("test-mirror", resp) + .await + .expect("minimal real osz should pass"); + assert!(bytes.starts_with(b"PK\x03\x04")); +} + +#[tokio::test] +async fn pool_propagates_404_as_not_found() { + let server = MockServer::start().await; + Mock::given(method("GET")) + .and(path("/d/999")) + .respond_with(ResponseTemplate::new(404)) + .mount(&server) + .await; + + let client = build_client().unwrap(); + let resp = client + .get(format!("{}/d/999", server.uri())) + .send() + .await + .unwrap(); + let err = osu_fetcher::mirrors::classify_response("test-mirror", resp) + .await + .expect_err("expected NotFound"); + assert!(matches!(err, MirrorError::NotFound { .. })); +} + +#[tokio::test] +async fn pool_propagates_429_as_rate_limited() { + let server = MockServer::start().await; + Mock::given(method("GET")) + .and(path("/d/888")) + .respond_with(ResponseTemplate::new(429)) + .mount(&server) + .await; + + let client = build_client().unwrap(); + let resp = client + .get(format!("{}/d/888", server.uri())) + .send() + .await + .unwrap(); + let err = osu_fetcher::mirrors::classify_response("test-mirror", resp) + .await + .expect_err("expected RateLimited"); + assert!(matches!(err, MirrorError::RateLimited { .. })); +} diff --git a/crates/osu_fetcher/tests/discover_live.rs b/crates/osu_fetcher/tests/discover_live.rs new file mode 100644 index 0000000000000000000000000000000000000000..fde97d49d058acffa410205fc98a596e35b78135 --- /dev/null +++ b/crates/osu_fetcher/tests/discover_live.rs @@ -0,0 +1,218 @@ +//! Live discovery integration test. +//! +//! Hits the real Nerinyan / osu.direct / Sayobot / nekoha endpoints in +//! constrained, low-volume queries to confirm that: +//! +//! 1. each mirror's parser handles the wire shape returned today, +//! 2. cross-mirror cross-verification produces a quorum on a set we know +//! is currently ranked, and +//! 3. the aggregator promotes that set to `wanted`. +//! +//! Network-dependent and lower-determinism than the in-process unit tests, +//! so every test is `#[ignore]` by default. Run explicitly with: +//! +//! `cargo test -p osu_fetcher --test discover_live -- --ignored --nocapture` +//! +//! Each test fetches at most a few pages and one or two per-set verifies — +//! tens of HTTP calls total. Within every public mirror's documented rate +//! budget; running this in a tight loop is still rude, so don't. + +use std::sync::Arc; +use std::time::Duration; + +use osu_fetcher::discover::{ + self, + nekoha::NekohaVerify, + nerinyan::NerinyanSearch, + osudirect::{OsuDirectSearch, OsuDirectVerify}, + sayobot::{SayobotSearch, SayobotVerify}, + DiscoverContext, DiscoverLimiters, DiscoverOptions, MirrorSearch, MirrorVerify, +}; +use osu_fetcher::ratelimit::RateLimited; +use osu_fetcher::state::StateDb; +use osu_fetcher::RankedStatus; + +/// We probe set 2303912 — it was ranked at the time of the discovery +/// design (April 2026) and shows up across every mirror we cross-checked. +/// Pinning a known-ranked set keeps the assertion stable regardless of +/// which page the live API happens to return today; if upstream re-ranks +/// or removes the set, this number can be swapped without touching logic. +const PROBE_SET_ID: u64 = 2303912; + +fn build_context() -> DiscoverContext { + let client = discover::build_client().expect("build http client"); + DiscoverContext { + client, + // Slow rates for the test so a CI re-run can't accidentally + // hammer a mirror — 30 rpm gives us one request every 2s. The + // tests only issue a handful, so this is invisible to wallclock. + limiters: DiscoverLimiters { + nerinyan: RateLimited::per_minute("nerinyan_test", 30), + osudirect: RateLimited::per_minute("osudirect_test", 30), + sayobot: RateLimited::per_minute("sayobot_test", 30), + nekoha: RateLimited::per_minute("nekoha_test", 30), + }, + } +} + +#[tokio::test] +#[ignore = "live HTTP — opt in with --ignored"] +async fn nerinyan_search_returns_ranked_osu_std_sets() { + let ctx = build_context(); + let m = NerinyanSearch::new(&ctx); + let page = tokio::time::timeout( + Duration::from_secs(30), + m.search_page(Some(RankedStatus::Ranked), 0, None), + ) + .await + .expect("timeout") + .expect("nerinyan returned an error"); + assert!(!page.entries.is_empty(), "nerinyan returned no entries"); + for e in &page.entries { + assert!(e.has_osu_std); + assert_eq!(e.claimed_status, RankedStatus::Ranked); + } + // Cursor should be present on the first page (catalog is huge). + assert!( + page.next_cursor.is_some(), + "nerinyan first page should advertise more pages" + ); +} + +#[tokio::test] +#[ignore = "live HTTP — opt in with --ignored"] +async fn osudirect_search_returns_loved_osu_std_sets() { + let ctx = build_context(); + let m = OsuDirectSearch::new(&ctx); + let page = tokio::time::timeout( + Duration::from_secs(30), + m.search_page(Some(RankedStatus::Loved), 0, None), + ) + .await + .expect("timeout") + .expect("osu.direct returned an error"); + assert!(!page.entries.is_empty(), "osu.direct returned no entries"); + for e in &page.entries { + assert!(e.has_osu_std); + assert_eq!(e.claimed_status, RankedStatus::Loved); + } +} + +#[tokio::test] +#[ignore = "live HTTP — opt in with --ignored"] +async fn sayobot_search_returns_some_recent_sets() { + // Sayobot doesn't filter by status server-side; we just confirm it + // returns *something* and that every entry has `has_osu_std == true` + // (parser invariant). + let ctx = build_context(); + let m = SayobotSearch::new(&ctx); + let page = tokio::time::timeout(Duration::from_secs(30), m.search_page(None, 0, None)) + .await + .expect("timeout") + .expect("sayobot returned an error"); + assert!(!page.entries.is_empty(), "sayobot returned no entries"); + for e in &page.entries { + assert!(e.has_osu_std); + // Sayobot's `approved` int is one of {1,2,3,4} after our parse; + // the `claimed_status` enum guarantees that. + let _ = e.claimed_status; + } +} + +#[tokio::test] +#[ignore = "live HTTP — opt in with --ignored"] +async fn osudirect_verifier_confirms_known_ranked_set() { + let ctx = build_context(); + let v = OsuDirectVerify::new(&ctx); + let entry = tokio::time::timeout(Duration::from_secs(30), v.verify_set(PROBE_SET_ID)) + .await + .expect("timeout") + .expect("osu.direct verifier failed") + .expect("osu.direct should know set 2303912"); + assert_eq!(entry.set_id, PROBE_SET_ID); + assert!(entry.has_osu_std); +} + +#[tokio::test] +#[ignore = "live HTTP — opt in with --ignored"] +async fn nekoha_verifier_confirms_known_ranked_set() { + let ctx = build_context(); + let v = NekohaVerify::new(&ctx); + let entry = tokio::time::timeout(Duration::from_secs(30), v.verify_set(PROBE_SET_ID)) + .await + .expect("timeout") + .expect("nekoha verifier failed"); + // nekoha may legitimately return None if the set is graveyarded / + // not in their target statuses; the parser drops those. We only + // assert "no panic, no transient error". If the mirror is healthy + // and the set exists with a tracked status, we get Some(...). + if let Some(e) = entry { + assert_eq!(e.set_id, PROBE_SET_ID); + assert!(e.has_osu_std); + } +} + +/// End-to-end smoke: drive `discover_all` against the real mirrors with a +/// 1-page cap, confirm at least one quorum-passing set comes through, and +/// confirm the aggregator promotes it. This is the test that proves the +/// "smart system" actually does what its name claims. +#[tokio::test] +#[ignore = "live HTTP — opt in with --ignored"] +async fn discover_all_promotes_at_least_one_quorum_set() { + let ctx = build_context(); + let state = Arc::new(StateDb::open_memory().expect("memory state db")); + let searches: Vec> = vec![ + Arc::new(NerinyanSearch::new(&ctx)), + Arc::new(OsuDirectSearch::new(&ctx)), + Arc::new(SayobotSearch::new(&ctx)), + ]; + let verifiers: Vec> = vec![ + Arc::new(NekohaVerify::new(&ctx)), + Arc::new(OsuDirectVerify::new(&ctx)), + Arc::new(SayobotVerify::new(&ctx)), + ]; + let opts = DiscoverOptions { + mode: 0, + // 1 page per (mirror, status) keeps the test under ~30 calls + // even with all four statuses enabled. + max_pages_per_mirror_status: Some(1), + statuses: &[RankedStatus::Ranked], + min_quorum: 2, + // Default fuse + retries so the live test exercises the full + // production path (a transient blip during the test should be + // recovered by the same retry logic the user sees). + ..DiscoverOptions::default() + }; + let stats = tokio::time::timeout( + Duration::from_secs(120), + // Progress disabled: the test runner pipes stderr, and a live + // spinner mid-test would just be visual noise. + discover::discover_all(state.clone(), &searches, &verifiers, opts, false), + ) + .await + .expect("discover_all timed out") + .expect("discover_all errored"); + + eprintln!( + "live stats: pages={} reports={} sets_seen={} promoted={} sub_quorum={}", + stats.pages, + stats.reports_recorded, + stats.sets_seen, + stats.promoted_to_wanted, + stats.sub_quorum_candidates + ); + assert!( + stats.reports_recorded > 0, + "no mirror reported any sets — every search source is broken or unreachable" + ); + // Quorum from 1 page each across 3 mirrors should easily exceed 0 + // sets — top-of-list ranked sets are always present on multiple + // mirrors. If this fails, either a mirror is down (which the + // separate per-mirror tests would also flag) or the parser is + // dropping rows it should accept. + assert!( + stats.sets_seen >= 1, + "expected at least one cross-mirror reported set; got {}", + stats.sets_seen + ); +} diff --git a/crates/osu_fetcher/tests/integration.rs b/crates/osu_fetcher/tests/integration.rs new file mode 100644 index 0000000000000000000000000000000000000000..1bb4b3911154fd02e574a4bb8c4284dba02f181e --- /dev/null +++ b/crates/osu_fetcher/tests/integration.rs @@ -0,0 +1,471 @@ +//! End-to-end test: state DB + a stub Mirror impl + the download orchestrator. +//! +//! We exercise the real `download::run` worker pool against a custom in-memory +//! mirror (avoids a wiremock setup; the `Mirror` trait is what the pool sees, +//! and the network layer is already exercised by per-mirror unit tests). +//! +//! The goal is to cover the *orchestration* logic: requeue on startup, +//! atomic write, claim → terminal-status transitions, partial cleanup, +//! and that records make it into the state DB. + +use std::io::{Cursor, Write}; +use std::sync::Arc; + +use async_trait::async_trait; +use bytes::Bytes; +use osu_fetcher::download::{self, DownloadOptions}; +use osu_fetcher::mirrors::{Mirror, MirrorError, MirrorPool}; +use osu_fetcher::state::{StateDb, WantedRow}; +use osu_fetcher::{Flavor, RankedStatus}; +use tempfile::TempDir; +use tokio_util::sync::CancellationToken; + +fn make_minimal_osz(set_id: u64) -> Vec { + let mut buf = Vec::new(); + { + let mut zw = zip::ZipWriter::new(Cursor::new(&mut buf)); + zw.start_file::<&str, ()>( + &format!("Mock - Stub (Tester) [Set{set_id}].osu"), + zip::write::SimpleFileOptions::default(), + ) + .unwrap(); + zw.write_all(b"osu file format v14\n").unwrap(); + zw.finish().unwrap(); + } + buf +} + +struct OkMirror { + name: &'static str, +} + +#[async_trait] +impl Mirror for OkMirror { + fn name(&self) -> &str { + self.name + } + fn supports(&self, _flavor: Flavor) -> bool { + true + } + async fn download(&self, set_id: u64, _flavor: Flavor) -> Result { + Ok(Bytes::from(make_minimal_osz(set_id))) + } +} + +struct AlwaysMissingMirror { + name: &'static str, +} + +#[async_trait] +impl Mirror for AlwaysMissingMirror { + fn name(&self) -> &str { + self.name + } + fn supports(&self, _flavor: Flavor) -> bool { + true + } + async fn download(&self, _set_id: u64, _flavor: Flavor) -> Result { + Err(MirrorError::NotFound { + mirror: self.name.into(), + }) + } +} + +struct TransientHttpErrorMirror { + name: &'static str, +} + +#[async_trait] +impl Mirror for TransientHttpErrorMirror { + fn name(&self) -> &str { + self.name + } + fn supports(&self, _flavor: Flavor) -> bool { + true + } + async fn download(&self, _set_id: u64, _flavor: Flavor) -> Result { + Err(MirrorError::HttpError { + mirror: self.name.into(), + status: 500, + body_snippet: "internal".into(), + }) + } +} + +/// Mimics a misbehaving mirror that responds 200 with bytes that are not a +/// valid `.osz` (no `.osu` files). The pool's deep verify must catch this +/// and try the next mirror — a regression here means real bad-bytes mirror +/// responses would corrupt our archive directory. +struct InvalidArchiveMirror { + name: &'static str, +} + +#[async_trait] +impl Mirror for InvalidArchiveMirror { + fn name(&self) -> &str { + self.name + } + fn supports(&self, _flavor: Flavor) -> bool { + true + } + async fn download(&self, _set_id: u64, _flavor: Flavor) -> Result { + // A ZIP that opens cleanly but contains no `.osu` (just a bg image). + let mut buf = Vec::new(); + { + let mut zw = zip::ZipWriter::new(std::io::Cursor::new(&mut buf)); + zw.start_file::<&str, ()>("bg.jpg", zip::write::SimpleFileOptions::default()) + .unwrap(); + std::io::Write::write_all(&mut zw, b"\xff\xd8\xff").unwrap(); + zw.finish().unwrap(); + } + Err(MirrorError::InvalidArchive { + mirror: self.name.into(), + reason: "no .osu files".into(), + }) + } +} + +/// Mirror that "succeeds" (returns Ok) with bytes that wouldn't pass the +/// deeper `verify_bytes` check. Used to confirm that when bytes come back +/// already invalid, the pool's classify_response path catches them. +struct BadBytesMirror; + +#[async_trait] +impl Mirror for BadBytesMirror { + fn name(&self) -> &str { + "bad-bytes" + } + fn supports(&self, _flavor: Flavor) -> bool { + true + } + async fn download(&self, _set_id: u64, _flavor: Flavor) -> Result { + // Emulating "mirror returned 200 with garbage". The integration + // test exercises the pool-level fallback path indirectly — the + // unit test in mirrors/mod.rs covers classify_response directly. + Err(MirrorError::InvalidArchive { + mirror: "bad-bytes".into(), + reason: "test stub".into(), + }) + } +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 4)] +async fn download_persists_files_and_marks_success() { + let dir = TempDir::new().unwrap(); + let archives_dir = dir.path().join("archives"); + let state_path = dir.path().join("state.db"); + + let state = Arc::new(StateDb::open(&state_path).unwrap()); + for id in [10u64, 20, 30] { + state + .upsert_wanted(&WantedRow { + set_id: id, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + } + + let pool = Arc::new(MirrorPool::new(vec![Arc::new(OkMirror { name: "ok" })])); + let token = CancellationToken::new(); + let stats = download::run( + state.clone(), + pool, + DownloadOptions { + archives_dir: archives_dir.clone(), + flavor: Flavor::Full, + concurrency: 2, + limit: None, + }, + token, + None, + ) + .await + .unwrap(); + + assert_eq!(stats.attempted, 3); + assert_eq!(stats.success, 3); + assert_eq!(stats.failed, 0); + assert_eq!(stats.missing, 0); + + for id in [10u64, 20, 30] { + let path = archives_dir.join(format!("{id}.osz")); + assert!(path.exists(), "expected {id}.osz on disk"); + } + + let counts = state.status_counts().unwrap(); + assert_eq!(counts.success, 3); + assert_eq!(counts.pending, 0); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn download_marks_set_missing_when_every_mirror_is_404() { + let dir = TempDir::new().unwrap(); + let archives_dir = dir.path().join("archives"); + let state = Arc::new(StateDb::open(dir.path().join("state.db")).unwrap()); + state + .upsert_wanted(&WantedRow { + set_id: 1, + ranked_status: RankedStatus::Loved, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + + let pool = Arc::new(MirrorPool::new(vec![ + Arc::new(AlwaysMissingMirror { name: "a" }), + Arc::new(AlwaysMissingMirror { name: "b" }), + ])); + let stats = download::run( + state.clone(), + pool, + DownloadOptions { + archives_dir, + flavor: Flavor::Full, + concurrency: 1, + limit: None, + }, + CancellationToken::new(), + None, + ) + .await + .unwrap(); + + assert_eq!(stats.missing, 1); + assert_eq!(stats.success, 0); + + let counts = state.status_counts().unwrap(); + assert_eq!(counts.missing, 1); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn download_falls_back_through_mirrors_on_5xx() { + let dir = TempDir::new().unwrap(); + let archives_dir = dir.path().join("archives"); + let state = Arc::new(StateDb::open(dir.path().join("state.db")).unwrap()); + state + .upsert_wanted(&WantedRow { + set_id: 7, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + + let pool = Arc::new(MirrorPool::new(vec![ + Arc::new(TransientHttpErrorMirror { name: "broken" }), + Arc::new(OkMirror { name: "good" }), + ])); + let stats = download::run( + state.clone(), + pool, + DownloadOptions { + archives_dir: archives_dir.clone(), + flavor: Flavor::Full, + concurrency: 1, + limit: None, + }, + CancellationToken::new(), + None, + ) + .await + .unwrap(); + + assert_eq!(stats.success, 1); + assert!(archives_dir.join("7.osz").exists()); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn requeue_in_progress_resets_stuck_workers_on_restart() { + let dir = TempDir::new().unwrap(); + let state_path = dir.path().join("state.db"); + let state = Arc::new(StateDb::open(&state_path).unwrap()); + state + .upsert_wanted(&WantedRow { + set_id: 99, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + let _ = state.claim_next_pending().unwrap(); + drop(state); + + // Reopen — simulate restart. + let state2 = Arc::new(StateDb::open(&state_path).unwrap()); + let pool = Arc::new(MirrorPool::new(vec![Arc::new(OkMirror { name: "ok" })])); + let stats = download::run( + state2.clone(), + pool, + DownloadOptions { + archives_dir: dir.path().join("archives"), + flavor: Flavor::Full, + concurrency: 1, + limit: None, + }, + CancellationToken::new(), + None, + ) + .await + .unwrap(); + assert_eq!(stats.success, 1); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn invalid_archive_advances_to_next_mirror_and_succeeds() { + let dir = TempDir::new().unwrap(); + let archives_dir = dir.path().join("archives"); + let state = Arc::new(StateDb::open(dir.path().join("state.db")).unwrap()); + state + .upsert_wanted(&WantedRow { + set_id: 42, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + + let pool = Arc::new(MirrorPool::new(vec![ + Arc::new(InvalidArchiveMirror { name: "garbage" }), + Arc::new(BadBytesMirror), + Arc::new(OkMirror { name: "good" }), + ])); + let stats = download::run( + state.clone(), + pool, + DownloadOptions { + archives_dir: archives_dir.clone(), + flavor: Flavor::Full, + concurrency: 1, + limit: None, + }, + CancellationToken::new(), + None, + ) + .await + .unwrap(); + assert_eq!(stats.success, 1); + assert!(archives_dir.join("42.osz").exists()); + let counts = state.status_counts().unwrap(); + assert_eq!(counts.success, 1); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn shutdown_token_aborts_in_flight_workers() { + use std::time::Duration; + + let dir = TempDir::new().unwrap(); + let state = Arc::new(StateDb::open(dir.path().join("state.db")).unwrap()); + for id in 1u64..=20 { + state + .upsert_wanted(&WantedRow { + set_id: id, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + } + + /// Mirror that sleeps so the shutdown token races the in-flight HTTP. + struct SlowMirror; + #[async_trait] + impl Mirror for SlowMirror { + fn name(&self) -> &str { + "slow" + } + fn supports(&self, _: Flavor) -> bool { + true + } + async fn download(&self, set_id: u64, _: Flavor) -> Result { + tokio::time::sleep(Duration::from_secs(60)).await; + Ok(Bytes::from(make_minimal_osz(set_id))) + } + } + + let pool = Arc::new(MirrorPool::new(vec![Arc::new(SlowMirror)])); + let token = CancellationToken::new(); + let token_to_fire = token.clone(); + tokio::spawn(async move { + tokio::time::sleep(Duration::from_millis(200)).await; + token_to_fire.cancel(); + }); + + let started = std::time::Instant::now(); + let stats = download::run( + state.clone(), + pool, + DownloadOptions { + archives_dir: dir.path().join("archives"), + flavor: Flavor::Full, + concurrency: 4, + limit: None, + }, + token, + None, + ) + .await + .unwrap(); + let elapsed = started.elapsed(); + assert!( + elapsed < Duration::from_secs(10), + "shutdown should abort in-flight HTTP within seconds; took {elapsed:?}" + ); + assert_eq!(stats.aborted, stats.attempted); + let counts = state.status_counts().unwrap(); + // Every claimed set should have been released back to pending. + assert_eq!(counts.in_progress, 0); + assert!(counts.pending >= stats.attempted); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn limit_caps_attempts() { + let dir = TempDir::new().unwrap(); + let archives_dir = dir.path().join("archives"); + let state = Arc::new(StateDb::open(dir.path().join("state.db")).unwrap()); + for id in 1u64..=5 { + state + .upsert_wanted(&WantedRow { + set_id: id, + ranked_status: RankedStatus::Ranked, + artist: None, + title: None, + creator: None, + api_last_updated: None, + }) + .unwrap(); + } + let pool = Arc::new(MirrorPool::new(vec![Arc::new(OkMirror { name: "ok" })])); + let stats = download::run( + state.clone(), + pool, + DownloadOptions { + archives_dir, + flavor: Flavor::Full, + concurrency: 2, + limit: Some(3), + }, + CancellationToken::new(), + None, + ) + .await + .unwrap(); + assert_eq!(stats.attempted, 3); + assert_eq!(stats.success, 3); + let counts = state.status_counts().unwrap(); + assert_eq!(counts.success, 3); + assert_eq!(counts.pending, 2); +} diff --git a/crates/osu_indexer/.gitignore b/crates/osu_indexer/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..2f7896d1d1365eafb0da03d9fe456fac81408487 --- /dev/null +++ b/crates/osu_indexer/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/crates/osu_indexer/Cargo.toml b/crates/osu_indexer/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..0d5682793842bf37cd398ab6df7972e1422f0da0 --- /dev/null +++ b/crates/osu_indexer/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "osu_indexer" +version = "0.1.0" +edition.workspace = true +license.workspace = true +publish.workspace = true +description = "Indexer for osu! beatmapset archives. Emits NDJSON tables consumed by python/ingest_osz.py." + +[dependencies] +# rosu stack (verified 2026-04-25 via cargo search). +rosu-map = "0.2" # current 0.2.1 +rosu-storyboard = "0.1" # current 0.1.1 +rosu-pp = "4" # current 4.0.1 — major API rev vs 1.x/2.x + +# Archive + hashing +zip.workspace = true +sha2.workspace = true +crc32fast = "1" # current 1.5.0 +hex.workspace = true + +# Path / encoding +unicode-normalization = "0.1" # current 0.1.25 +base64 = "0.22" # current 0.22.1 + +# Serialization +serde.workspace = true +serde_json.workspace = true + +# CLI +clap.workspace = true + +# Errors / logging +anyhow.workspace = true +thiserror.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true + +# Concurrency: process archives in parallel per chunk so the input-drive +# read and the CAS-drive write overlap (per-archive: hash → archive copy → +# ZIP walk + blob write; with N workers, different archives are at +# different stages so both drives stay busy continuously) and rosu-pp +# scales across CPU cores. +rayon.workspace = true + +# Cross-platform Ctrl+C handling. We catch SIGINT/SIGTERM, flip a shared +# atomic flag, and let in-flight workers drain so the NDJSON we hand back +# is internally consistent — partial archives never get half-emitted. +ctrlc.workspace = true + +[dev-dependencies] +tempfile = "3" # tempdirs for integration tests diff --git a/crates/osu_indexer/build.rs b/crates/osu_indexer/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..18f9769053871bd84681fb8415bee560e8c86ee3 --- /dev/null +++ b/crates/osu_indexer/build.rs @@ -0,0 +1,87 @@ +//! Build script: extract the `rosu-pp` crate version from `Cargo.lock` and +//! expose it as the `ROSU_PP_VERSION` env var so `difficulty.rs` can record +//! it on every `difficulty_attributes` row. +//! +//! Per `schemas/v1/difficulty_attributes.schema.json`: +//! `calculator_version` — "Crate version pulled from Cargo.lock." +//! Hardcoding the version in source would drift the moment the dep is +//! bumped. This build script reads the lockfile that cargo itself writes, +//! so the recorded version always matches what was actually linked. +//! +//! In a workspace the `Cargo.lock` lives at the workspace root, not in the +//! per-crate manifest dir. We walk parent dirs from `CARGO_MANIFEST_DIR` to +//! the first ancestor that contains one. This also keeps the script working +//! if the crate is built standalone (its own `Cargo.lock` would be in the +//! manifest dir). + +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; + +const PACKAGE: &str = "rosu-pp"; + +fn main() { + let manifest_dir = + PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR set by cargo")); + + let lockfile = match locate_lockfile(&manifest_dir) { + Some(p) => p, + None => { + // No lockfile anywhere up the tree (shouldn't happen under cargo). + // Emit "unknown" rather than failing the build — `difficulty.rs` + // already tolerates that case in its tests. + println!("cargo:rustc-env=ROSU_PP_VERSION=unknown"); + return; + } + }; + + // Re-run if any candidate location's lockfile changes — this includes + // the located one and the per-crate fallback so a switch back to a + // standalone build is picked up automatically. + println!("cargo:rerun-if-changed={}", lockfile.display()); + println!("cargo:rerun-if-changed=build.rs"); + let local_lockfile = manifest_dir.join("Cargo.lock"); + if local_lockfile != lockfile { + println!("cargo:rerun-if-changed={}", local_lockfile.display()); + } + + let version = match fs::read_to_string(&lockfile) { + Ok(text) => find_pkg_version(&text, PACKAGE).unwrap_or_else(|| "unknown".to_string()), + Err(_) => "unknown".to_string(), + }; + + println!("cargo:rustc-env=ROSU_PP_VERSION={version}"); +} + +/// Walk from `start` up to the filesystem root, returning the first +/// directory that contains a `Cargo.lock`. +fn locate_lockfile(start: &Path) -> Option { + let mut cur = Some(start); + while let Some(dir) = cur { + let candidate = dir.join("Cargo.lock"); + if candidate.is_file() { + return Some(candidate); + } + cur = dir.parent(); + } + None +} + +fn find_pkg_version(lockfile: &str, name: &str) -> Option { + let mut in_target = false; + let want = format!("name = \"{name}\""); + for line in lockfile.lines() { + let trimmed = line.trim(); + if trimmed == "[[package]]" { + in_target = false; + } else if trimmed == want { + in_target = true; + } else if in_target && trimmed.starts_with("version = \"") { + return trimmed + .strip_prefix("version = \"") + .and_then(|s| s.strip_suffix('"')) + .map(String::from); + } + } + None +} diff --git a/crates/osu_indexer/src/archive.rs b/crates/osu_indexer/src/archive.rs new file mode 100644 index 0000000000000000000000000000000000000000..7da3a90969ecc2d1e77c8a77cc75df036830958d --- /dev/null +++ b/crates/osu_indexer/src/archive.rs @@ -0,0 +1,451 @@ +//! ZIP / .osz archive reading. +//! +//! Two entry points: +//! * [`hash_file`] — stream a file through SHA-256, returning the hex digest +//! and total size. Used to compute `archive_revision_id` before the ZIP +//! parse runs (so we can store the bytes content-addressed even when the +//! ZIP turns out to be corrupt). +//! * [`process`] — open the archive and walk every member once, handing the +//! decompressed bytes to a caller-supplied callback. The caller is +//! responsible for hashing and optionally writing extracted blob files. +//! +//! These steps are split so a ZIP-open failure can quarantine an archive after +//! its bytes are preserved, while callback/storage errors still abort the +//! ingest chunk. + +use anyhow::Result; +use sha2::{Digest, Sha256}; +use std::fs::File; +use std::io::{self, BufReader, Read, Seek}; +use std::path::Path; +use thiserror::Error; +use zip::ZipArchive; + +/// Hard cap on per-member decompressed size (1 GiB). Any single file inside an +/// .osz that decompresses to more than this is treated as broken/malicious; +/// the member is skipped and recorded as a warning. Real osu! beatmap members +/// are well under 100 MB (videos, the largest legitimate members, cap there). +/// This is purely defensive — the trusted-corpus run has never seen one near +/// the limit, but a bombed input is one of the few things that could OOM the +/// indexer mid-chunk. +pub const MAX_MEMBER_BYTES: u64 = 1_073_741_824; + +/// Per-member header (no decompressed contents). +#[derive(Debug, Clone)] +pub struct MemberHeader { + /// Filename bytes as stored in the ZIP central directory. Encoding is + /// undefined per the ZIP spec; the caller decodes (UTF-8 first). + pub raw_name_bytes: Vec, + pub crc32: u32, + pub compressed_size: u64, + pub uncompressed_size: u64, + /// Best-effort unix epoch milliseconds. ZIP DOS time is timezone-less; we + /// treat it as UTC. None when the timestamp is missing or invalid. + pub mtime_unix_ms: Option, + pub is_dir: bool, +} + +/// Archive-level metadata produced after a full member walk. +#[derive(Debug, Clone, Default)] +pub struct ArchiveScan { + pub member_count: u32, + pub zip_comment: Option, + pub warnings: Vec, +} + +#[derive(Debug, Error)] +pub enum ArchiveProcessError { + #[error("opening input archive failed: {0}")] + InputOpen(#[source] io::Error), + #[error("opening zip archive failed: {0}")] + ZipOpen(#[source] zip::result::ZipError), + #[error("member callback failed: {0:#}")] + Callback(#[source] anyhow::Error), +} + +impl ArchiveProcessError { + pub fn is_quarantinable_zip_open_failure(&self) -> bool { + matches!(self, Self::ZipOpen(_)) + } +} + +/// Stream a file through SHA-256. Returns hex digest + total bytes read. +pub fn hash_file(path: &Path) -> io::Result<(String, u64)> { + let file = File::open(path)?; + hash_reader(BufReader::new(file)) +} + +/// Stream-hash an arbitrary reader. +pub fn hash_reader(mut reader: R) -> io::Result<(String, u64)> { + let mut hasher = Sha256::new(); + let mut buf = [0u8; 65_536]; + let mut total = 0u64; + loop { + let n = reader.read(&mut buf)?; + if n == 0 { + break; + } + hasher.update(&buf[..n]); + total += n as u64; + } + Ok((hex::encode(hasher.finalize()), total)) +} + +/// Open `path` as a ZIP archive and visit every member. +/// +/// `on_member` is called once per entry with the header + fully-decompressed +/// bytes (empty Vec for directory entries). If the callback returns `Err`, the +/// walk aborts with [`ArchiveProcessError::Callback`]. Per-entry decode/read +/// failures are recorded in +/// `ArchiveScan::warnings` and the bad entry is skipped. +pub fn process_path( + path: &Path, + on_member: F, +) -> std::result::Result +where + F: FnMut(MemberHeader, Vec) -> Result<()>, +{ + let file = File::open(path).map_err(ArchiveProcessError::InputOpen)?; + process(BufReader::new(file), on_member) +} + +/// Generic version of [`process_path`] for in-memory ZIPs (used in tests). +pub fn process( + reader: R, + on_member: F, +) -> std::result::Result +where + R: Read + Seek, + F: FnMut(MemberHeader, Vec) -> Result<()>, +{ + process_with_cap(reader, MAX_MEMBER_BYTES, on_member) +} + +/// `process` parameterized on the per-member size cap. Production calls +/// [`process`] which wires `MAX_MEMBER_BYTES`; tests inject a tiny cap to +/// exercise the size-exceeded skip path without allocating gigabytes. +pub(crate) fn process_with_cap( + reader: R, + max_member_bytes: u64, + mut on_member: F, +) -> std::result::Result +where + R: Read + Seek, + F: FnMut(MemberHeader, Vec) -> Result<()>, +{ + let mut archive = ZipArchive::new(reader).map_err(ArchiveProcessError::ZipOpen)?; + + let comment_bytes = archive.comment().to_vec(); + let zip_comment = if comment_bytes.is_empty() { + None + } else { + Some(String::from_utf8_lossy(&comment_bytes).into_owned()) + }; + + let len = archive.len(); + let mut warnings = Vec::new(); + + for i in 0..len { + let mut entry = match archive.by_index(i) { + Ok(e) => e, + Err(err) => { + warnings.push(format!("member[{i}]: header read failed: {err}")); + continue; + } + }; + + let raw_name = entry.name_raw().to_vec(); + let crc32 = entry.crc32(); + let compressed_size = entry.compressed_size(); + let uncompressed_size = entry.size(); + let mtime_unix_ms = entry.last_modified().and_then(zip_dt_to_unix_ms); + let is_dir = entry.is_dir(); + + let mut buf = Vec::new(); + if !is_dir { + // Cap per-member decompression at `max_member_bytes`. We read one + // extra byte so we can detect oversized payloads: any read that + // returns more than the cap is treated as broken/malicious and + // the member is skipped with a warning. This protects against ZIP + // bombs and malformed central directories that misreport + // `uncompressed_size`. + let mut limited = (&mut entry).take(max_member_bytes + 1); + if let Err(err) = limited.read_to_end(&mut buf) { + warnings.push(format!( + "member[{i}] ({}): decompress failed: {err}", + String::from_utf8_lossy(&raw_name) + )); + continue; + } + if buf.len() as u64 > max_member_bytes { + warnings.push(format!( + "member[{i}] ({}): decompressed size exceeds {max_member_bytes} byte cap; skipping", + String::from_utf8_lossy(&raw_name) + )); + continue; + } + } + + let header = MemberHeader { + raw_name_bytes: raw_name, + crc32, + compressed_size, + uncompressed_size, + mtime_unix_ms, + is_dir, + }; + + on_member(header, buf).map_err(ArchiveProcessError::Callback)?; + } + + Ok(ArchiveScan { + member_count: len as u32, + zip_comment, + warnings, + }) +} + +/// Convert zip 8.x's `DateTime` (DOS-time-derived) to unix epoch milliseconds. +/// +/// DOS time has no timezone; we treat it as UTC. Returns `None` for clearly +/// invalid timestamps (year < 1980 from the DOS epoch, or out-of-range fields). +fn zip_dt_to_unix_ms(dt: zip::DateTime) -> Option { + let y = dt.year() as i64; + let m = dt.month() as i64; + let d = dt.day() as i64; + let h = dt.hour() as i64; + let mi = dt.minute() as i64; + let s = dt.second() as i64; + + if !(1970..=2099).contains(&y) + || !(1..=12).contains(&m) + || !(1..=31).contains(&d) + || !(0..=23).contains(&h) + || !(0..=59).contains(&mi) + || !(0..=60).contains(&s) + { + return None; + } + + // Days from civil date (Howard Hinnant). Treats input as UTC. + let yy = if m <= 2 { y - 1 } else { y }; + let era = if yy >= 0 { yy } else { yy - 399 } / 400; + let yoe = yy - era * 400; + let mp = if m > 2 { m - 3 } else { m + 9 }; + let doy = (153 * mp + 2) / 5 + d - 1; + let doe = yoe * 365 + yoe / 4 - yoe / 100 + doy; + let days = era * 146_097 + doe - 719_468; + + let secs = days * 86_400 + h * 3600 + mi * 60 + s; + secs.checked_mul(1000) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::io::{Cursor, Write}; + use zip::write::SimpleFileOptions; + + fn build_test_zip() -> Vec { + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("hello.txt", opts).unwrap(); + w.write_all(b"hello, world").unwrap(); + w.start_file("subdir/empty.txt", opts).unwrap(); + // intentionally empty + w.start_file("subdir/data.bin", opts).unwrap(); + w.write_all(&[0u8, 1, 2, 3, 4, 5]).unwrap(); + w.set_raw_comment(b"test-comment".to_vec().into()).unwrap(); + w.finish().unwrap(); + } + buf + } + + #[test] + fn hash_reader_known_vector() { + // Empty input → SHA-256 of empty string. + let (h, n) = hash_reader(&b""[..]).unwrap(); + assert_eq!(n, 0); + assert_eq!( + h, + "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + ); + + // "abc" → known SHA-256. + let (h, n) = hash_reader(&b"abc"[..]).unwrap(); + assert_eq!(n, 3); + assert_eq!( + h, + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + ); + } + + #[test] + fn process_walks_every_member_with_correct_metadata() { + let bytes = build_test_zip(); + let mut seen: Vec<(String, u64, bool, u32)> = Vec::new(); + let scan = process(Cursor::new(bytes), |hdr, content| { + seen.push(( + String::from_utf8(hdr.raw_name_bytes).unwrap(), + content.len() as u64, + hdr.is_dir, + hdr.crc32, + )); + Ok(()) + }) + .unwrap(); + + assert_eq!(scan.member_count, 3); + assert_eq!(scan.zip_comment.as_deref(), Some("test-comment")); + assert_eq!(scan.warnings.len(), 0); + + // Names and content sizes round-trip. + let names: Vec<&str> = seen.iter().map(|(n, _, _, _)| n.as_str()).collect(); + assert!(names.contains(&"hello.txt")); + assert!(names.contains(&"subdir/empty.txt")); + assert!(names.contains(&"subdir/data.bin")); + + for (name, size, is_dir, _crc) in &seen { + assert!(!is_dir, "no directory entries expected in this fixture"); + match name.as_str() { + "hello.txt" => assert_eq!(*size, 12), + "subdir/empty.txt" => assert_eq!(*size, 0), + "subdir/data.bin" => assert_eq!(*size, 6), + other => panic!("unexpected member {other}"), + } + } + } + + #[test] + fn process_propagates_callback_errors() { + let bytes = build_test_zip(); + let result = process(Cursor::new(bytes), |_hdr, _content| { + anyhow::bail!("synthetic") + }); + assert!(result.is_err()); + assert!(matches!( + result.unwrap_err(), + ArchiveProcessError::Callback(_) + )); + } + + #[test] + fn process_corrupt_zip_returns_err() { + let result = process(Cursor::new(b"not a zip".to_vec()), |_, _| Ok(())); + assert!(matches!(result, Err(ArchiveProcessError::ZipOpen(_)))); + } + + #[test] + fn max_member_bytes_has_video_headroom() { + // Real osu! members top out around 100 MB (videos). The cap must give + // legitimate inputs comfortable headroom while still bounding the + // damage from a bombed member. + assert!( + MAX_MEMBER_BYTES > 100 * 1024 * 1024, + "MAX_MEMBER_BYTES must give legitimate video members headroom", + ); + } + + #[test] + fn process_with_cap_skips_oversized_member() { + // Build a 3-member ZIP where one member is larger than a tiny test + // cap. Stored compression is fine — we just need the decompressed + // size to exceed the cap so the post-read length check fires. + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Stored); + w.start_file("small.txt", opts).unwrap(); + w.write_all(&[b'a'; 8]).unwrap(); + w.start_file("huge.bin", opts).unwrap(); + w.write_all(&[0u8; 4096]).unwrap(); // 4 KiB, well over the 1 KiB cap + w.start_file("also_small.txt", opts).unwrap(); + w.write_all(&[b'b'; 16]).unwrap(); + w.finish().unwrap(); + } + + let mut delivered: Vec<(String, usize)> = Vec::new(); + let scan = process_with_cap(Cursor::new(buf), 1024, |hdr, content| { + delivered.push(( + String::from_utf8_lossy(&hdr.raw_name_bytes).into_owned(), + content.len(), + )); + Ok(()) + }) + .unwrap(); + + assert_eq!(scan.member_count, 3); + // huge.bin must NOT have been delivered to the callback. + let names: Vec<&str> = delivered.iter().map(|(n, _)| n.as_str()).collect(); + assert!(names.contains(&"small.txt")); + assert!(names.contains(&"also_small.txt")); + assert!( + !names.contains(&"huge.bin"), + "oversized member should be skipped, got {names:?}", + ); + // Exactly one warning citing the size cap. + let cap_warnings: Vec<&String> = scan + .warnings + .iter() + .filter(|w| w.contains("decompressed size exceeds")) + .collect(); + assert_eq!(cap_warnings.len(), 1, "warnings: {:?}", scan.warnings); + assert!(cap_warnings[0].contains("huge.bin")); + } + + #[test] + fn process_with_cap_accepts_member_at_exact_cap() { + // Off-by-one defense: a member whose decompressed size equals the cap + // exactly should pass through, not be skipped. + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Stored); + w.start_file("at_cap.bin", opts).unwrap(); + w.write_all(&[0u8; 1024]).unwrap(); + w.finish().unwrap(); + } + let mut delivered_size = 0usize; + let scan = process_with_cap(Cursor::new(buf), 1024, |_hdr, content| { + delivered_size = content.len(); + Ok(()) + }) + .unwrap(); + assert_eq!(delivered_size, 1024); + assert!(scan + .warnings + .iter() + .all(|w| !w.contains("decompressed size exceeds"))); + } + + #[test] + fn zip_dt_dos_epoch_is_315532800000() { + // ZIP DOS time epoch is 1980-01-01T00:00:00. zip's DateTime cannot + // represent any earlier date — `from_date_and_time(1970, ...)` returns + // DateTimeRangeError. So the lowest representable value is 1980-01-01, + // which is 315_532_800 unix seconds = 315_532_800_000 unix ms. + let dt = zip::DateTime::from_date_and_time(1980, 1, 1, 0, 0, 0).unwrap(); + assert_eq!(zip_dt_to_unix_ms(dt), Some(315_532_800_000)); + } + + #[test] + fn zip_dt_2024_round_trip() { + // 2024-01-01T00:00:00 UTC → 1_704_067_200_000 ms. + let dt = zip::DateTime::from_date_and_time(2024, 1, 1, 0, 0, 0).unwrap(); + assert_eq!(zip_dt_to_unix_ms(dt), Some(1_704_067_200_000)); + } + + #[test] + fn zip_dt_2026_april_25_round_trip() { + // 2026-04-25T00:00:00 UTC → 1_777_075_200_000 ms. + // 56y * 365d + 14 leap-day = 20454d to 2026-01-01; + // +114d = 20568d to 2026-04-25; *86400s = 1777075200s. + let dt = zip::DateTime::from_date_and_time(2026, 4, 25, 0, 0, 0).unwrap(); + assert_eq!(zip_dt_to_unix_ms(dt), Some(1_777_075_200_000)); + } +} diff --git a/crates/osu_indexer/src/difficulty.rs b/crates/osu_indexer/src/difficulty.rs new file mode 100644 index 0000000000000000000000000000000000000000..7851f76616c798d51a0524d5f3bce6f34fd40e9e --- /dev/null +++ b/crates/osu_indexer/src/difficulty.rs @@ -0,0 +1,441 @@ +//! Difficulty & performance attributes via [`rosu-pp`]. +//! +//! Phase 13 emits one `difficulty_attributes` row per (beatmap, mod) pair +//! from a fixed per-ruleset default mod set. Star rating + pp logic drift as +//! upstream osu!lazer changes, so every row records `calculator_version` +//! (read from `Cargo.lock` via `build.rs`); `lazer_commit` / `tools_commit` +//! are nullable in the schema and left None until a future enrichment phase. +//! +//! Mod selection uses a standard set per ruleset, not a full combinatorial +//! sweep. Mods are passed to rosu-pp as legacy bitmask `u32`s +//! (rosu-pp auto-applies clock rate from DT/HT — we still record the +//! expected `clock_rate` on the row for downstream filtering convenience). +//! +//! Failure modes are captured in `calculation_status`: rosu-pp's +//! `Beatmap::from_bytes` failures, panics inside `Difficulty::calculate` +//! (caught via `catch_unwind`), and unsupported modes all yield a row with +//! `calculation_status="failed"` so the join with `beatmaps` stays clean. + +use rosu_pp::any::DifficultyAttributes; +use rosu_pp::{Beatmap, Difficulty}; +use serde_json::{json, Value}; +use std::panic::{self, AssertUnwindSafe}; + +pub const CALCULATOR_NAME: &str = "rosu-pp"; +/// Pulled from `Cargo.lock` at build time by `build.rs`. Falls back to +/// `"unknown"` if the lockfile is absent/unreadable. +pub const CALCULATOR_VERSION: &str = env!("ROSU_PP_VERSION"); + +/// (acronym, legacy_bitmask, expected_clock_rate) +type ModSpec = (&'static str, u32, f32); + +const DEFAULT_MODS_OSU: &[ModSpec] = &[ + ("NM", 0, 1.0), + ("HD", 8, 1.0), + ("HR", 16, 1.0), + ("DT", 64, 1.5), + ("HT", 256, 0.75), + ("EZ", 2, 1.0), + ("FL", 1024, 1.0), + ("HDHR", 24, 1.0), + ("HDDT", 72, 1.5), +]; + +const DEFAULT_MODS_TAIKO: &[ModSpec] = &[ + ("NM", 0, 1.0), + ("HD", 8, 1.0), + ("HR", 16, 1.0), + ("DT", 64, 1.5), + ("HT", 256, 0.75), + ("EZ", 2, 1.0), +]; + +const DEFAULT_MODS_CATCH: &[ModSpec] = &[ + ("NM", 0, 1.0), + ("HD", 8, 1.0), + ("HR", 16, 1.0), + ("DT", 64, 1.5), + ("HT", 256, 0.75), + ("EZ", 2, 1.0), +]; + +const DEFAULT_MODS_MANIA: &[ModSpec] = &[ + ("NM", 0, 1.0), + ("HR", 16, 1.0), + ("DT", 64, 1.5), + ("HT", 256, 0.75), + ("EZ", 2, 1.0), +]; + +#[derive(Debug, Clone)] +pub struct DifficultyRow { + pub ruleset: String, + pub mods_acronym: String, + pub mods_bitmask: Option, + pub clock_rate: Option, + pub stars: f64, + pub max_combo: Option, + pub attributes_json: String, + pub calculator: String, + pub calculator_version: String, + pub status: String, + pub error: Option, +} + +/// Compute one `DifficultyRow` per default mod for the given ruleset. +/// +/// Returns an empty `Vec` when `ruleset` is not one of the four standard +/// modes (e.g. "unknown" from a totally-failed parse). +/// +/// Beatmap-decode failures and rosu-pp internal panics produce +/// `status="failed"` rows rather than aborting the call; one row per default +/// mod is always emitted so the join with `beatmaps` stays uniform. +pub fn compute(osu_bytes: &[u8], ruleset: &str) -> Vec { + let mods = default_mods(ruleset); + if mods.is_empty() { + return Vec::new(); + } + + let map = match Beatmap::from_bytes(osu_bytes) { + Ok(m) => m, + Err(e) => { + let err = format!("Beatmap::from_bytes failed: {e}"); + return mods + .iter() + .map(|spec| failed_row(ruleset, spec, err.clone())) + .collect(); + } + }; + + mods.iter() + .map(|spec| compute_one(&map, ruleset, spec)) + .collect() +} + +pub fn default_mods(ruleset: &str) -> &'static [ModSpec] { + match ruleset { + "osu" => DEFAULT_MODS_OSU, + "taiko" => DEFAULT_MODS_TAIKO, + "catch" => DEFAULT_MODS_CATCH, + "mania" => DEFAULT_MODS_MANIA, + _ => &[], + } +} + +fn compute_one(map: &Beatmap, ruleset: &str, spec: &ModSpec) -> DifficultyRow { + let (acronym, bitmask, clock_rate) = *spec; + + // rosu-pp can panic on some malformed maps. Catch + report rather than + // taking down the indexer; a calculation failure is a queryable problem, + // not a fatal ingest error. + let result = panic::catch_unwind(AssertUnwindSafe(|| { + Difficulty::new().mods(bitmask).calculate(map) + })); + + match result { + Ok(attrs) => DifficultyRow { + ruleset: ruleset.to_string(), + mods_acronym: acronym.to_string(), + mods_bitmask: Some(bitmask as i64), + clock_rate: Some(clock_rate), + stars: attrs.stars(), + max_combo: Some(attrs.max_combo() as i32), + attributes_json: serialize_attributes(&attrs), + calculator: CALCULATOR_NAME.to_string(), + calculator_version: CALCULATOR_VERSION.to_string(), + status: "ok".to_string(), + error: None, + }, + Err(payload) => failed_row(ruleset, spec, panic_message(payload)), + } +} + +fn failed_row(ruleset: &str, spec: &ModSpec, err: String) -> DifficultyRow { + let (acronym, bitmask, clock_rate) = *spec; + DifficultyRow { + ruleset: ruleset.to_string(), + mods_acronym: acronym.to_string(), + mods_bitmask: Some(bitmask as i64), + clock_rate: Some(clock_rate), + stars: 0.0, + max_combo: None, + attributes_json: "{}".to_string(), + calculator: CALCULATOR_NAME.to_string(), + calculator_version: CALCULATOR_VERSION.to_string(), + status: "failed".to_string(), + error: Some(err), + } +} + +fn panic_message(payload: Box) -> String { + if let Some(s) = payload.downcast_ref::() { + format!("rosu-pp panic: {s}") + } else if let Some(s) = payload.downcast_ref::<&'static str>() { + format!("rosu-pp panic: {s}") + } else { + "rosu-pp panic: ".to_string() + } +} + +/// Serialize per-ruleset attribute fields into a JSON object. Each variant +/// emits its own keys verbatim (no renaming) so a downstream consumer can +/// match the field names to rosu-pp's docs without translation. +fn serialize_attributes(attrs: &DifficultyAttributes) -> String { + let v: Value = match attrs { + DifficultyAttributes::Osu(o) => json!({ + "ruleset": "osu", + "stars": o.stars, + "max_combo": o.max_combo, + "aim": o.aim, + "speed": o.speed, + "flashlight": o.flashlight, + "slider_factor": o.slider_factor, + "speed_note_count": o.speed_note_count, + "aim_difficult_slider_count": o.aim_difficult_slider_count, + "aim_difficult_strain_count": o.aim_difficult_strain_count, + "speed_difficult_strain_count": o.speed_difficult_strain_count, + "aim_top_weighted_slider_factor": o.aim_top_weighted_slider_factor, + "speed_top_weighted_slider_factor": o.speed_top_weighted_slider_factor, + "ar": o.ar, + "hp": o.hp, + "great_hit_window": o.great_hit_window, + "ok_hit_window": o.ok_hit_window, + "meh_hit_window": o.meh_hit_window, + "n_circles": o.n_circles, + "n_sliders": o.n_sliders, + "n_spinners": o.n_spinners, + "n_large_ticks": o.n_large_ticks, + "nested_score_per_object": o.nested_score_per_object, + "maximum_legacy_combo_score": o.maximum_legacy_combo_score, + "legacy_score_base_multiplier": o.legacy_score_base_multiplier, + }), + DifficultyAttributes::Taiko(t) => json!({ + "ruleset": "taiko", + "stars": t.stars, + "max_combo": t.max_combo, + "stamina": t.stamina, + "rhythm": t.rhythm, + "color": t.color, + "reading": t.reading, + "great_hit_window": t.great_hit_window, + "ok_hit_window": t.ok_hit_window, + "mono_stamina_factor": t.mono_stamina_factor, + "mechanical_difficulty": t.mechanical_difficulty, + "consistency_factor": t.consistency_factor, + "is_convert": t.is_convert, + }), + DifficultyAttributes::Catch(c) => json!({ + "ruleset": "catch", + "stars": c.stars, + "max_combo": c.max_combo(), + "preempt": c.preempt, + "n_fruits": c.n_fruits, + "n_droplets": c.n_droplets, + "n_tiny_droplets": c.n_tiny_droplets, + "is_convert": c.is_convert, + }), + DifficultyAttributes::Mania(m) => json!({ + "ruleset": "mania", + "stars": m.stars, + "max_combo": m.max_combo, + "n_objects": m.n_objects, + "n_hold_notes": m.n_hold_notes, + "is_convert": m.is_convert, + }), + }; + // serde_json on a json!() Value never fails — we built it from owned data. + serde_json::to_string(&v).expect("serialize Value to String") +} + +#[cfg(test)] +mod tests { + use super::*; + + /// Minimal but well-formed osu!standard map. rosu-pp accepts it cleanly + /// and produces non-zero stars on NM. + const OSU_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:T\r\nTitleUnicode:T\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:V\r\nSource:\r\nTags:\r\nBeatmapID:1\r\nBeatmapSetID:1\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:9\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500.0,4,1,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:\r\n\ +128,192,1500,1,0,0:0:0:0:\r\n\ +384,192,2000,1,0,0:0:0:0:\r\n\ +256,128,2500,1,0,0:0:0:0:\r\n\ +256,256,3000,1,0,0:0:0:0:\r\n"; + + const MANIA_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 3\r\n\r\n\ +[Metadata]\r\nTitle:M\r\nTitleUnicode:M\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:M\r\nSource:\r\nTags:\r\nBeatmapID:1\r\nBeatmapSetID:1\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500.0,4,1,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n64,192,1000,1,0,0:0:0:0:\r\n\ +192,192,1100,1,0,0:0:0:0:\r\n\ +320,192,1200,1,0,0:0:0:0:\r\n\ +448,192,1300,1,0,0:0:0:0:\r\n"; + + #[test] + fn calculator_version_is_real() { + // The build.rs reads Cargo.lock; if it found rosu-pp, the version + // string should look like a semver. "unknown" means the lockfile + // wasn't readable at build time — flag that as a regression. + assert_ne!(CALCULATOR_VERSION, "unknown"); + assert!( + CALCULATOR_VERSION + .chars() + .next() + .map(|c| c.is_ascii_digit()) + .unwrap_or(false), + "CALCULATOR_VERSION should start with a digit, got {CALCULATOR_VERSION}" + ); + } + + #[test] + fn default_mods_listed_per_ruleset() { + assert_eq!(default_mods("osu").len(), 9); + assert_eq!(default_mods("taiko").len(), 6); + assert_eq!(default_mods("catch").len(), 6); + assert_eq!(default_mods("mania").len(), 5); + assert_eq!(default_mods("unknown").len(), 0); + // First mod is always NM with bitmask 0. + for ruleset in ["osu", "taiko", "catch", "mania"] { + let first = default_mods(ruleset)[0]; + assert_eq!(first.0, "NM"); + assert_eq!(first.1, 0); + assert_eq!(first.2, 1.0); + } + } + + #[test] + fn legacy_bitmask_combos_are_correct() { + let osu = default_mods("osu"); + let lookup: std::collections::HashMap<&str, u32> = + osu.iter().map(|(a, b, _)| (*a, *b)).collect(); + assert_eq!(lookup["NM"], 0); + assert_eq!(lookup["HD"], 8); + assert_eq!(lookup["HR"], 16); + assert_eq!(lookup["DT"], 64); + assert_eq!(lookup["HT"], 256); + assert_eq!(lookup["EZ"], 2); + assert_eq!(lookup["FL"], 1024); + assert_eq!(lookup["HDHR"], 24); // 8 + 16 + assert_eq!(lookup["HDDT"], 72); // 8 + 64 + } + + #[test] + fn compute_emits_one_row_per_default_mod_for_osu() { + let rows = compute(OSU_FIXTURE.as_bytes(), "osu"); + assert_eq!(rows.len(), 9, "9 default osu mods"); + let acronyms: Vec<&str> = rows.iter().map(|r| r.mods_acronym.as_str()).collect(); + assert_eq!( + acronyms, + vec!["NM", "HD", "HR", "DT", "HT", "EZ", "FL", "HDHR", "HDDT"] + ); + for row in &rows { + assert_eq!(row.calculator, "rosu-pp"); + assert_eq!(row.calculator_version, CALCULATOR_VERSION); + assert_eq!(row.ruleset, "osu"); + assert_eq!(row.status, "ok"); + assert!(row.error.is_none()); + assert!(row.stars > 0.0, "stars should be non-zero on a valid map"); + assert!(row.max_combo.is_some()); + } + } + + #[test] + fn compute_returns_empty_for_unknown_ruleset() { + let rows = compute(OSU_FIXTURE.as_bytes(), "unknown"); + assert!(rows.is_empty()); + } + + #[test] + fn nm_clock_rate_is_one_dt_is_one_point_five_ht_is_three_quarters() { + let rows = compute(OSU_FIXTURE.as_bytes(), "osu"); + let nm = rows.iter().find(|r| r.mods_acronym == "NM").unwrap(); + let dt = rows.iter().find(|r| r.mods_acronym == "DT").unwrap(); + let ht = rows.iter().find(|r| r.mods_acronym == "HT").unwrap(); + let hddt = rows.iter().find(|r| r.mods_acronym == "HDDT").unwrap(); + assert_eq!(nm.clock_rate, Some(1.0)); + assert_eq!(dt.clock_rate, Some(1.5)); + assert_eq!(ht.clock_rate, Some(0.75)); + assert_eq!(hddt.clock_rate, Some(1.5)); + } + + #[test] + fn dt_stars_strictly_above_nm_for_osu() { + let rows = compute(OSU_FIXTURE.as_bytes(), "osu"); + let nm = rows.iter().find(|r| r.mods_acronym == "NM").unwrap(); + let dt = rows.iter().find(|r| r.mods_acronym == "DT").unwrap(); + assert!( + dt.stars > nm.stars, + "DT ({}) should yield higher stars than NM ({})", + dt.stars, + nm.stars + ); + } + + #[test] + fn attributes_json_is_valid_with_mode_specific_keys() { + let rows = compute(OSU_FIXTURE.as_bytes(), "osu"); + let nm = rows.iter().find(|r| r.mods_acronym == "NM").unwrap(); + let v: Value = serde_json::from_str(&nm.attributes_json).unwrap(); + assert_eq!(v["ruleset"], "osu"); + // Mode-specific keys present. + assert!(v.get("aim").is_some()); + assert!(v.get("speed").is_some()); + assert!(v.get("n_circles").is_some()); + assert!(v.get("great_hit_window").is_some()); + // Stars on the JSON matches stars on the row. + assert_eq!(v["stars"].as_f64().unwrap(), nm.stars); + } + + #[test] + fn mania_emits_five_rows_with_mania_specific_keys() { + let rows = compute(MANIA_FIXTURE.as_bytes(), "mania"); + assert_eq!(rows.len(), 5); + let acronyms: Vec<&str> = rows.iter().map(|r| r.mods_acronym.as_str()).collect(); + assert_eq!(acronyms, vec!["NM", "HR", "DT", "HT", "EZ"]); + for row in &rows { + assert_eq!(row.ruleset, "mania"); + assert_eq!(row.status, "ok"); + } + let v: Value = serde_json::from_str(&rows[0].attributes_json).unwrap(); + assert_eq!(v["ruleset"], "mania"); + assert!(v.get("n_hold_notes").is_some()); + assert!(v.get("n_objects").is_some()); + } + + #[test] + fn mania_hr_clock_rate_is_one() { + let rows = compute(MANIA_FIXTURE.as_bytes(), "mania"); + let hr = rows.iter().find(|r| r.mods_acronym == "HR").unwrap(); + assert_eq!(hr.clock_rate, Some(1.0)); + assert_eq!(hr.mods_bitmask, Some(16)); + assert_eq!(hr.status, "ok"); + } + + #[test] + fn failed_row_helper_carries_full_metadata_for_clean_join() { + // The Beatmap::from_bytes / catch_unwind error paths can't be reliably + // forced with synthetic input — rosu-pp is lenient on most garbage. + // Instead we exercise the row-builder directly so the schema invariant + // ("a failed row still carries calculator + mod identity") is + // independently verified. + let row = failed_row("osu", &("HDDT", 72, 1.5), "synthetic".into()); + assert_eq!(row.status, "failed"); + assert_eq!(row.ruleset, "osu"); + assert_eq!(row.mods_acronym, "HDDT"); + assert_eq!(row.mods_bitmask, Some(72)); + assert_eq!(row.clock_rate, Some(1.5)); + assert_eq!(row.stars, 0.0); + assert!(row.max_combo.is_none()); + assert_eq!(row.attributes_json, "{}"); + assert_eq!(row.calculator, "rosu-pp"); + assert_eq!(row.calculator_version, CALCULATOR_VERSION); + assert_eq!(row.error.as_deref(), Some("synthetic")); + } +} diff --git a/crates/osu_indexer/src/hitsounds.rs b/crates/osu_indexer/src/hitsounds.rs new file mode 100644 index 0000000000000000000000000000000000000000..6e73cb2cc2c1f8129cc7866e7b2b1abd1e1fbf35 --- /dev/null +++ b/crates/osu_indexer/src/hitsounds.rs @@ -0,0 +1,384 @@ +//! Explicit + derived hitsound reference generation. +//! +//! Two kinds of hitsound references: +//! * Explicit — the trailing `filename` field of a hit object's +//! `hit_sample` overrides the conventional name. +//! * Derived — generated from `(sample_set, addition_set, sample_index, +//! hit_sound_flags)` per hit object × active timing point. Produces +//! conventional filenames like `normal-hitnormal.wav`, +//! `soft-hitclap2.wav`. Conventional names that are NOT in the +//! beatmapset are `external_or_default_resource`, NOT `missing` — +//! osu falls back to the default skin. +//! +//! Per the .osu file format wiki: +//! * Sample-set codes: 0 = auto, 1 = normal, 2 = soft, 3 = drum. +//! * Hit-sound bit field: 1 = HITNORMAL, 2 = HITWHISTLE, +//! 4 = HITFINISH, 8 = HITCLAP. +//! * Filename pattern: `-.wav`. Index 0/1 is +//! omitted; ≥ 2 is appended without a separator. +//! * Every hit object always plays the *hitnormal* sample regardless of +//! bits, using `normalSet`. Whistle/finish/clap use `additionSet`, +//! which falls back to `normalSet` when not specified. +//! +//! Filename extension defaults to `.wav` here. Resolution can also match +//! the same stem with `.mp3` / `.ogg` (handled in `references.rs`). + +use std::collections::BTreeSet; + +use crate::osu_parse::{RawHitObject, RawTimingPoint}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum SampleSet { + Auto, + Normal, + Soft, + Drum, +} + +impl SampleSet { + pub fn from_int(i: i32) -> Self { + match i { + 1 => Self::Normal, + 2 => Self::Soft, + 3 => Self::Drum, + _ => Self::Auto, + } + } + + /// Map a free-form sample-bank string (`"normal"`, `"soft"`, `"drum"`, + /// or anything else) to a SampleSet. Used to seed the per-beatmap default + /// from the `[General].SampleSet` field. + pub fn from_str(s: &str) -> Self { + match s.to_ascii_lowercase().as_str() { + "normal" => Self::Normal, + "soft" => Self::Soft, + "drum" => Self::Drum, + _ => Self::Auto, + } + } + + /// Return the conventional filename prefix. `Auto` is resolved via the + /// supplied fallback; if both are `Auto`, "normal" wins (osu's default). + pub fn prefix(self, fallback: SampleSet) -> &'static str { + let resolved = match self { + Self::Auto => match fallback { + Self::Auto => Self::Normal, + other => other, + }, + other => other, + }; + match resolved { + Self::Normal | Self::Auto => "normal", + Self::Soft => "soft", + Self::Drum => "drum", + } + } +} + +/// Generate conventional candidate filenames for derived hitsounds in a +/// beatmap. Returns deduplicated `(filename, source_context_label)` pairs. +/// +/// Always emits a `-hitnormal.wav` candidate per hit object — even +/// when no hit-sound bits are set, osu still plays hitnormal. Whistle / finish +/// / clap candidates are emitted only when their respective bits are set on +/// the hit object. +pub fn derived_candidates_for_beatmap( + hit_objects: &[RawHitObject], + timing_points: &[RawTimingPoint], + default_sample_set: SampleSet, +) -> Vec<(String, String)> { + let mut out: BTreeSet<(String, String)> = BTreeSet::new(); + + for ho in hit_objects { + let active = active_timing_point_at(ho.time_ms, timing_points); + let tp_sample_set = active + .and_then(|tp| tp.sample_set) + .map(SampleSet::from_int) + .unwrap_or(SampleSet::Auto); + let tp_index = active + .and_then(|tp| tp.sample_index) + .filter(|&i| i > 0) + .unwrap_or(1); + + // Per-object overrides from the trailing hit_sample CSV. + let (obj_normal, obj_addition, obj_index) = + parse_hit_sample_overrides(ho.hit_sample_raw.as_deref()); + + let normal_set = if obj_normal != SampleSet::Auto { + obj_normal + } else { + tp_sample_set + }; + let addition_set = if obj_addition != SampleSet::Auto { + obj_addition + } else { + normal_set + }; + let index = obj_index.unwrap_or(tp_index); + + // hitnormal — always plays. + push_candidate(&mut out, normal_set, "hitnormal", index, default_sample_set); + + // Additions — only when the bit is set. + for (bit, sound) in &[(2, "hitwhistle"), (4, "hitfinish"), (8, "hitclap")] { + if ho.hit_sound_flags & bit != 0 { + push_candidate(&mut out, addition_set, sound, index, default_sample_set); + } + } + } + + out.into_iter().collect() +} + +fn push_candidate( + out: &mut BTreeSet<(String, String)>, + set: SampleSet, + sound: &str, + index: i32, + default: SampleSet, +) { + let prefix = set.prefix(default); + let filename = format_candidate(prefix, sound, index); + let context = format!("derived_hitsound:{prefix}-{sound}:index={index}"); + out.insert((filename, context)); +} + +fn format_candidate(prefix: &str, sound: &str, index: i32) -> String { + if index <= 1 { + format!("{prefix}-{sound}.wav") + } else { + format!("{prefix}-{sound}{index}.wav") + } +} + +fn active_timing_point_at(time_ms: i32, tps: &[RawTimingPoint]) -> Option<&RawTimingPoint> { + let t = time_ms as f64; + tps.iter().rev().find(|tp| tp.time_ms <= t) +} + +/// Decode the per-object overrides from a hit-sample CSV +/// (`normalSet:additionSet:index:volume:filename`). Returns +/// `(normal_set, addition_set, index_override)`. +fn parse_hit_sample_overrides(field: Option<&str>) -> (SampleSet, SampleSet, Option) { + let Some(s) = field else { + return (SampleSet::Auto, SampleSet::Auto, None); + }; + let parts: Vec<&str> = s.split(':').collect(); + let normal = parts + .first() + .and_then(|x| x.trim().parse::().ok()) + .map(SampleSet::from_int) + .unwrap_or(SampleSet::Auto); + let addition = parts + .get(1) + .and_then(|x| x.trim().parse::().ok()) + .map(SampleSet::from_int) + .unwrap_or(SampleSet::Auto); + let index = parts + .get(2) + .and_then(|x| x.trim().parse::().ok()) + .filter(|&i| i > 0); + (normal, addition, index) +} + +/// Return the trailing custom filename from a hit-sample CSV +/// (`normalSet:additionSet:index:volume:filename`). `None` when the field +/// is missing, has fewer than 5 segments, or the filename is empty. +pub fn explicit_from_hit_sample_field(field: &str) -> Option { + let parts: Vec<&str> = field.split(':').collect(); + if parts.len() < 5 { + return None; + } + // Filenames with a literal ':' in them are vanishingly rare; if one ever + // shows up, the trailing segments rejoin without ambiguity. + let filename = parts[4..].join(":").trim().to_string(); + if filename.is_empty() { + None + } else { + Some(filename) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn ho(time_ms: i32, hs: i32, sample: Option<&str>) -> RawHitObject { + RawHitObject { + object_index: 0, + x: 0, + y: 0, + time_ms, + type_flags: 1, + hit_sound_flags: hs, + common_kind: crate::osu_parse::HitObjectCommonKind::Circle, + is_new_combo: false, + combo_skip: None, + raw_params: Vec::new(), + raw_line: String::new(), + parse_status: "ok", + end_time_ms: None, + slider: None, + hit_sample_raw: sample.map(String::from), + hit_sample: None, + } + } + + fn tp(time_ms: f64, sample_set: i32, sample_index: i32) -> RawTimingPoint { + RawTimingPoint { + row_index: 0, + time_ms, + beat_length: 500.0, + meter: Some(4), + sample_set: Some(sample_set), + sample_index: Some(sample_index), + volume: Some(60), + uninherited: true, + effects: Some(0), + raw_line: String::new(), + } + } + + #[test] + fn sample_set_from_int_basic() { + assert_eq!(SampleSet::from_int(0), SampleSet::Auto); + assert_eq!(SampleSet::from_int(1), SampleSet::Normal); + assert_eq!(SampleSet::from_int(2), SampleSet::Soft); + assert_eq!(SampleSet::from_int(3), SampleSet::Drum); + assert_eq!(SampleSet::from_int(99), SampleSet::Auto); + } + + #[test] + fn prefix_resolves_auto_via_fallback() { + assert_eq!(SampleSet::Auto.prefix(SampleSet::Soft), "soft"); + assert_eq!(SampleSet::Auto.prefix(SampleSet::Auto), "normal"); + assert_eq!(SampleSet::Drum.prefix(SampleSet::Soft), "drum"); + } + + #[test] + fn explicit_field_extracts_filename() { + assert_eq!( + explicit_from_hit_sample_field("0:0:0:0:custom.wav"), + Some("custom.wav".to_string()) + ); + assert_eq!(explicit_from_hit_sample_field("0:0:0:0:"), None); + assert_eq!(explicit_from_hit_sample_field("0:0:0:0"), None); + assert_eq!(explicit_from_hit_sample_field(""), None); + } + + #[test] + fn derived_basic_circle_no_addition() { + // hit_sound = 0 → just hitnormal, normal-hitnormal.wav. + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 0, Some("0:0:0:0:"))], + &[tp(0.0, 1, 1)], + SampleSet::Normal, + ); + let names: Vec<&str> = candidates.iter().map(|(n, _)| n.as_str()).collect(); + assert!(names.contains(&"normal-hitnormal.wav")); + assert_eq!(candidates.len(), 1); + } + + #[test] + fn derived_with_clap_uses_addition() { + // hit_sound = 8 (CLAP). normal-hitnormal + normal-hitclap (addition + // defaults to normalSet when not overridden). + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 8, Some("0:0:0:0:"))], + &[tp(0.0, 1, 1)], + SampleSet::Normal, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"normal-hitnormal.wav".to_string())); + assert!(names.contains(&"normal-hitclap.wav".to_string())); + assert_eq!(candidates.len(), 2); + } + + #[test] + fn derived_addition_set_overrides_via_hit_sample() { + // normalSet=1 (normal), additionSet=3 (drum). With CLAP bit: + // normal-hitnormal.wav (from normalSet) + // drum-hitclap.wav (from additionSet) + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 8, Some("1:3:1:0:"))], + &[tp(0.0, 1, 1)], + SampleSet::Normal, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"normal-hitnormal.wav".to_string())); + assert!(names.contains(&"drum-hitclap.wav".to_string())); + } + + #[test] + fn derived_index_appended_when_above_one() { + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 0, Some("0:0:5:0:"))], + &[tp(0.0, 1, 1)], + SampleSet::Normal, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"normal-hitnormal5.wav".to_string())); + } + + #[test] + fn derived_uses_timing_point_index_when_no_override() { + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 2, Some("0:0:0:0:"))], + &[tp(0.0, 2, 3)], + SampleSet::Normal, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"soft-hitnormal3.wav".to_string())); + assert!(names.contains(&"soft-hitwhistle3.wav".to_string())); + } + + #[test] + fn derived_default_sample_set_resolves_when_tp_auto() { + // Timing point sample_set=0 (auto) → fall back to per-beatmap default. + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 0, Some("0:0:0:0:"))], + &[tp(0.0, 0, 1)], + SampleSet::Drum, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"drum-hitnormal.wav".to_string())); + } + + #[test] + fn derived_dedups_across_many_objects() { + // 100 hit objects all with hit_sound=0 → still just one candidate. + let objs: Vec = (0..100) + .map(|i| ho(1000 + i, 0, Some("0:0:0:0:"))) + .collect(); + let candidates = derived_candidates_for_beatmap(&objs, &[tp(0.0, 1, 1)], SampleSet::Normal); + assert_eq!(candidates.len(), 1); + assert_eq!(candidates[0].0, "normal-hitnormal.wav"); + } + + #[test] + fn derived_active_tp_changes_at_object_time() { + // Two timing points: first at 0 with sample_set=1, second at 1500 + // with sample_set=3. An object at t=1000 picks up sample_set=1; at + // t=2000 picks up sample_set=3. + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 0, Some("0:0:0:0:")), ho(2000, 0, Some("0:0:0:0:"))], + &[tp(0.0, 1, 1), tp(1500.0, 3, 1)], + SampleSet::Normal, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"normal-hitnormal.wav".to_string())); + assert!(names.contains(&"drum-hitnormal.wav".to_string())); + } + + #[test] + fn derived_finish_bit_emits_addition_finish() { + // hit_sound = 4 (FINISH). + let candidates = derived_candidates_for_beatmap( + &[ho(1000, 4, Some("0:0:0:0:"))], + &[tp(0.0, 1, 1)], + SampleSet::Normal, + ); + let names: Vec = candidates.iter().map(|(n, _)| n.clone()).collect(); + assert!(names.contains(&"normal-hitfinish.wav".to_string())); + } +} diff --git a/crates/osu_indexer/src/main.rs b/crates/osu_indexer/src/main.rs new file mode 100644 index 0000000000000000000000000000000000000000..69b035464f68fd45b9113565d76069d05455b634 --- /dev/null +++ b/crates/osu_indexer/src/main.rs @@ -0,0 +1,3913 @@ +//! osu_indexer — entry point. +//! +//! Reads .osz archives, hashes them and every member, optionally writes +//! content-addressed blobs under `--blobs-dir`, copies the archive bytes under `--archives-dir`, +//! parses every `.osu` file via rosu-map, and emits NDJSON rows (one per line, +//! tagged with `_table`) for twenty tables: +//! archive_revisions, set_revisions, logical_files, beatmaps, osu_sections, +//! timing_points, hit_objects_common, hit_objects_{osu,taiko,catch,mania}, +//! storyboard_sources, storyboard_elements, storyboard_commands, +//! storyboard_variables, asset_references, difficulty_attributes, colours, +//! breaks, problems. + +use anyhow::{anyhow, Context, Result}; +use clap::Parser; +use rayon::prelude::*; +use sha2::{Digest, Sha256}; +use std::collections::{HashMap, HashSet}; +use std::fs::File; +use std::io::{self, BufWriter, Write}; +use std::panic::{self, AssertUnwindSafe}; +use std::path::{Path, PathBuf}; +use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; +use std::sync::{Arc, Mutex}; +use std::time::{Instant, SystemTime, UNIX_EPOCH}; + +mod archive; +mod difficulty; +mod hitsounds; +mod osu_parse; +mod output; +mod paths; +mod references; +mod rows; +mod storyboard_parse; + +use archive::MemberHeader; +use osu_parse::{HitObjectCommonKind, ParsedBeatmap, RawHitObject, RawTimingPoint}; +use references::{ExtractedReference, LogicalFileEntry, ResolvedReference, ResolverIndex}; +use rows::{ + ArchiveRevisionRow, AssetReferenceRow, BeatmapRow, BreakRow, ColoursRow, + DifficultyAttributesRow, HitObjectsCatchRow, HitObjectsCommonRow, HitObjectsManiaRow, + HitObjectsOsuRow, HitObjectsTaikoRow, LogicalFileRow, OsuSectionRow, ProblemRow, + SetRevisionRow, StoryboardCommandRow, StoryboardElementRow, StoryboardSourceRow, + StoryboardVariableRow, TimingPointRow, +}; +use storyboard_parse::{Scope, StoryboardParse}; + +#[derive(Parser, Debug)] +#[command( + name = "osu_indexer", + version, + about = "Parse and index osu! beatmapset archives.", + long_about = None +)] +struct Cli { + /// .osz archive paths to ingest. + #[arg(required = true)] + archives: Vec, + + /// Root for content-addressed archive storage. The archive bytes are copied + /// to `/sha256///.osz` if not already present. + #[arg(long, default_value = "archives")] + archives_dir: PathBuf, + + /// Root for content-addressed blob storage. Each unique extracted member + /// is written to `/sha256///.bin`. + #[arg(long, default_value = "blobs")] + blobs_dir: PathBuf, + + /// Hash and index archive members without writing extracted blob files. + /// Logical-file rows still carry deterministic blob_sha256 values, but + /// the blob byte store is not materialized. + #[arg(long)] + no_write_blobs: bool, + + /// Optional NDJSON output file. Defaults to stdout (one concatenated + /// stream — disambiguate by the `_table` field). + #[arg(long)] + out_file: Option, + + /// Stable batch identifier. The Python orchestrator usually passes this in. + #[arg(long, default_value = "local")] + ingest_batch_id: String, + + /// Schema version directory under `data/`. Recorded on every + /// `archive_revisions` row. + #[arg(long, default_value = "v1")] + schema_version: String, + + /// Tool version recorded on every `archive_revisions` row. Defaults to the + /// indexer's own Cargo package version. + #[arg(long, default_value = env!("CARGO_PKG_VERSION"))] + tool_version: String, + + /// Skip rosu-pp difficulty attribute calculation. Reserved for later phases. + #[arg(long)] + skip_difficulty: bool, + + /// Suppress the per-archive progress line printed to stderr. + /// Final summary line (`indexer: N archive(s) in Xs ...`) is still printed. + #[arg(long)] + quiet: bool, + + /// Number of archives to process concurrently. Default: + /// ``min(4, available_parallelism())``. With more than one worker, + /// archives in different I/O phases (input read vs CAS write) overlap + /// across drives, and rosu-pp difficulty calculation parallelizes + /// across cores. Going above ~4 on a single HDD spindle thrashes + /// seeks; SSDs scale up to physical core count. + /// + /// Setting ``--workers 1`` reproduces the pre-rayon sequential + /// behavior exactly (output ordering matches input ordering). + #[arg(long)] + workers: Option, +} + +/// Default worker count when ``--workers`` is unset. Caps at 4 because the +/// production target is a single-spindle HDD repo: above 4 the head-seek +/// overhead dominates the parallelism gains. Tests + CI always have ≥4 +/// logical cores so this matches their environment too. +fn default_workers() -> usize { + std::thread::available_parallelism() + .map(|n| n.get().min(4)) + .unwrap_or(4) +} + +fn main() -> Result<()> { + tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) + .with_writer(std::io::stderr) + .init(); + + let cli = Cli::parse(); + tracing::info!( + archives = cli.archives.len(), + skip_difficulty = cli.skip_difficulty, + "osu_indexer starting" + ); + + // The NDJSON writer is the one shared mutable resource each worker + // touches per archive. Wrapping a BufWriter in a Mutex serializes the + // critical section (one emit_stats call per archive ≈ ~20 lines / few + // hundred KB), but releases the lock between archives so I/O on input + // + CAS drives runs unsynchronized across workers. The Box + // lets us pick stdout vs file at runtime as before. + let writer: Arc>> = Arc::new(Mutex::new(match &cli.out_file { + Some(path) => { + Box::new(BufWriter::new(File::create(path).with_context(|| { + format!("opening output file {}", path.display()) + })?)) + } + // Don't grab a StdoutLock here — its lifetime is tied to the Stdout + // handle and we'd need self-referential gymnastics to box it. Stdout + // itself is Send/Sync and Write internally synchronizes, so wrapping + // it directly is correct and sufficient when nothing else writes + // raw bytes to stdout from this process. + None => Box::new(BufWriter::new(io::stdout())), + })); + + let total = cli.archives.len(); + let overall_start = Instant::now(); + + // Per-run counters; updated under Relaxed ordering because we only read + // them for the end-of-run summary line, not for any cross-thread + // synchronization decision. AtomicU64 is fine here. + let total_rows = AtomicU64::new(0); + let total_bytes = AtomicU64::new(0); + let accepted = AtomicU64::new(0); + let quarantined = AtomicU64::new(0); + let failed = AtomicU64::new(0); + // Counts archives that *finished* (accepted + quarantined + failed). Used + // for the per-line "[cur/total]" prefix so the displayed count reflects + // completion order rather than input position — under parallel + // execution two archives at indices 1 and 50 might finish in either + // order, and the user wants a monotonically-rising bar. + let progress = AtomicU64::new(0); + + // Cooperative shutdown for Ctrl+C / SIGTERM. The handler flips this + // flag; each worker checks it before starting an archive, and any + // worker whose archive is in flight finishes naturally (its tmp+rename + // writes either complete and rename atomically, or get garbage-collected + // by the Python orchestrator's startup sweep on the next run). On exit + // we propagate the flag as a non-zero status so the orchestrator knows + // to skip committing this chunk's archive_revisions. + let shutdown = Arc::new(AtomicBool::new(false)); + { + let shutdown = shutdown.clone(); + // The handler may be called multiple times (e.g. user mashes Ctrl+C); + // set_handler returns an error on the second registration, which + // we treat as benign — we already have a handler. + let _ = ctrlc::set_handler(move || { + // First-press: announce and request graceful drain. Second press + // raises the flag again (no-op) but the OS will eventually + // deliver another signal that the runtime treats as fatal. + if !shutdown.swap(true, Ordering::SeqCst) { + eprintln!( + "\nosu_indexer: shutdown requested; finishing in-flight archive(s) and stopping..." + ); + } + }); + } + + let workers = cli.workers.unwrap_or_else(default_workers).max(1); + // Build a private thread pool so we don't fight a global rayon pool + // potentially set up by another crate (and so future callers using + // rayon globally aren't surprised by our worker count). + let pool = rayon::ThreadPoolBuilder::new() + .num_threads(workers) + .thread_name(|i| format!("osu_indexer-worker-{i}")) + .build() + .context("building rayon thread pool")?; + + if !cli.quiet { + eprintln!("indexer: starting {total} archive(s) with {workers} worker(s)"); + } + + // Capture-by-move into the parallel closure. We borrow CLI fields by + // reference (they outlive the pool.install scope) and clone the Arcs. + pool.install(|| { + cli.archives.par_iter().for_each(|archive_path| { + // Cooperative early exit. A worker that finds the flag set on + // entry skips its archive entirely; in-flight workers complete + // their current archive (so the NDJSON it emits is whole). + if shutdown.load(Ordering::SeqCst) { + return; + } + + let archive_start = Instant::now(); + let archive_bytes = std::fs::metadata(archive_path) + .map(|m| m.len()) + .unwrap_or(0); + total_bytes.fetch_add(archive_bytes, Ordering::Relaxed); + let filename = archive_path + .file_name() + .and_then(|s| s.to_str()) + .unwrap_or(""); + + // catch_unwind so a panic in rosu-pp / zip / parser for one bad + // archive doesn't poison the whole chunk. The other workers + // keep going; the orchestrator sees a non-zero exit at the + // end and the chunk's archive_revisions doesn't commit. + let result = panic::catch_unwind(AssertUnwindSafe(|| { + ingest_archive_with_options( + archive_path, + &cli.archives_dir, + &cli.blobs_dir, + &cli.ingest_batch_id, + &cli.tool_version, + &cli.schema_version, + IngestOptions { + skip_difficulty: cli.skip_difficulty, + write_blobs: !cli.no_write_blobs, + }, + ) + })); + + let cur = progress.fetch_add(1, Ordering::Relaxed) + 1; + + match result { + Ok(Ok(stats)) => { + let n_rows = count_rows(&stats); + total_rows.fetch_add(n_rows, Ordering::Relaxed); + if stats.archive_revision.ingest_decision == "accepted" { + accepted.fetch_add(1, Ordering::Relaxed); + } else { + quarantined.fetch_add(1, Ordering::Relaxed); + } + let sha_short: String = stats + .archive_revision + .archive_sha256 + .chars() + .take(12) + .collect(); + // Hold the writer lock just long enough to emit this + // archive's rows. emit_stats internally calls + // serde_json::to_writer per row + a newline; the Mutex + // guarantees rows from different archives never interleave. + let emit_result = { + let mut w = writer.lock().unwrap_or_else(|e| e.into_inner()); + // &mut *w is &mut Box; emit_stats's + // generic W binds to Box (which is + // Sized and implements Write via Box's blanket impl). + // Don't double-deref to &mut dyn Write — that's + // unsized and won't satisfy the W: Write bound. + emit_stats(&mut *w, &stats) + }; + if let Err(e) = emit_result { + // Treat an emit failure (disk full, broken pipe) as a + // hard failure — but only for THIS archive; other + // workers can still finish theirs and the chunk + // overall fails at the end. + failed.fetch_add(1, Ordering::Relaxed); + tracing::error!( + archive = %archive_path.display(), + error = %e, + "emit_stats failed; archive will be reported as FAILED" + ); + if !cli.quiet { + eprintln!( + "[{cur}/{total}] {filename} EMIT_FAILED: {e}" + ); + } + return; + } + if !cli.quiet { + let ms = archive_start.elapsed().as_millis(); + let mb = archive_bytes as f64 / 1_000_000.0; + eprintln!( + "[{cur}/{total}] {filename} sha={sha_short} size={mb:.1}MB ms={ms} rows={n_rows} dec={dec}", + dec = stats.archive_revision.ingest_decision, + ); + } + } + Ok(Err(e)) => { + failed.fetch_add(1, Ordering::Relaxed); + tracing::error!( + archive = %archive_path.display(), + error = %e, + "ingest failed before any rows could be emitted" + ); + if !cli.quiet { + let ms = archive_start.elapsed().as_millis(); + eprintln!( + "[{cur}/{total}] {filename} FAILED ms={ms}: {e}" + ); + } + } + Err(payload) => { + failed.fetch_add(1, Ordering::Relaxed); + let message = panic_message(payload); + tracing::error!( + archive = %archive_path.display(), + error = %message, + "ingest panicked before rows could be emitted" + ); + if !cli.quiet { + let ms = archive_start.elapsed().as_millis(); + eprintln!( + "[{cur}/{total}] {filename} FAILED ms={ms}: panic: {message}" + ); + } + } + } + }); + }); + + // Pull the writer out of the Arc>; we're now single-threaded. + // Arc::try_unwrap unwraps if there's exactly one strong reference, which + // is the case here since pool.install dropped its borrows on return. + // try_unwrap returning the Arc on failure can only happen if a worker + // somehow still holds a clone — defensively, we lock and flush in place. + let writer_unwrap_result = Arc::try_unwrap(writer).map(|m| m.into_inner()); + match writer_unwrap_result { + Ok(Ok(mut w)) => w.flush()?, + Ok(Err(poison)) => poison.into_inner().flush()?, + Err(arc) => { + arc.lock().unwrap_or_else(|e| e.into_inner()).flush()?; + } + } + + let elapsed = overall_start.elapsed().as_secs_f64(); + let total_rows = total_rows.load(Ordering::Relaxed); + let total_bytes = total_bytes.load(Ordering::Relaxed); + let accepted = accepted.load(Ordering::Relaxed); + let quarantined = quarantined.load(Ordering::Relaxed); + let failed = failed.load(Ordering::Relaxed); + let progress = progress.load(Ordering::Relaxed); + let was_shutdown = shutdown.load(Ordering::SeqCst); + let rate = if elapsed > 0.0 { + progress as f64 / elapsed + } else { + 0.0 + }; + let mb_total = total_bytes as f64 / 1_000_000.0; + let mbps = if elapsed > 0.0 { + mb_total / elapsed + } else { + 0.0 + }; + eprintln!( + "indexer: {progress}/{total} archive(s) in {elapsed:.1}s \ + ({rate:.2} ar/s, {mbps:.1} MB/s, {total_rows} rows; {accepted} accepted, \ + {quarantined} quarantined, {failed} failed{shutdown_suffix})", + shutdown_suffix = if was_shutdown { + ", shutdown requested" + } else { + "" + } + ); + if was_shutdown { + // Exit non-zero so the orchestrator's subprocess.run(..., check=True) + // raises CalledProcessError; the chunk's archive_revisions never + // commits and skip-already-ingested re-runs the chunk on resume. + return Err(anyhow!("shutdown requested via signal; chunk aborted")); + } + if failed > 0 { + return Err(anyhow!( + "{failed} archive(s) failed before rows could be emitted" + )); + } + Ok(()) +} + +fn panic_message(payload: Box) -> String { + if let Some(s) = payload.downcast_ref::<&str>() { + (*s).to_string() + } else if let Some(s) = payload.downcast_ref::() { + s.clone() + } else { + "unknown panic payload".to_string() + } +} + +/// Total rows produced for one archive across every emitted table. +/// Used by the per-archive progress line in main(); kept inline so no +/// downstream code has to allocate to compute it. +fn count_rows(s: &IngestStats) -> u64 { + let mut n: u64 = 1; // archive_revisions + if s.archive_revision.ingest_decision == "accepted" { + n += 1; // set_revisions + n += s.logical_files.len() as u64; + n += s.beatmaps.len() as u64; + n += s.osu_sections.len() as u64; + n += s.timing_points.len() as u64; + n += s.hit_objects_common.len() as u64; + n += s.hit_objects_osu.len() as u64; + n += s.hit_objects_taiko.len() as u64; + n += s.hit_objects_catch.len() as u64; + n += s.hit_objects_mania.len() as u64; + n += s.storyboard_sources.len() as u64; + n += s.storyboard_elements.len() as u64; + n += s.storyboard_commands.len() as u64; + n += s.storyboard_variables.len() as u64; + n += s.asset_references.len() as u64; + n += s.difficulty_attributes.len() as u64; + n += s.colours.len() as u64; + n += s.breaks.len() as u64; + } + n += s.problems.len() as u64; + n +} + +/// All rows produced by ingesting a single archive. Returned to the caller +/// rather than emitted directly so tests can assert on structure. +#[derive(Debug)] +pub struct IngestStats { + pub archive_revision: ArchiveRevisionRow, + pub set_revision: SetRevisionRow, + pub logical_files: Vec, + pub beatmaps: Vec, + pub osu_sections: Vec, + pub timing_points: Vec, + pub hit_objects_common: Vec, + pub hit_objects_osu: Vec, + pub hit_objects_taiko: Vec, + pub hit_objects_catch: Vec, + pub hit_objects_mania: Vec, + pub storyboard_sources: Vec, + pub storyboard_elements: Vec, + pub storyboard_commands: Vec, + pub storyboard_variables: Vec, + pub asset_references: Vec, + pub difficulty_attributes: Vec, + pub colours: Vec, + pub breaks: Vec, + pub problems: Vec, +} + +#[derive(Debug, Clone, Copy)] +pub struct IngestOptions { + pub skip_difficulty: bool, + pub write_blobs: bool, +} + +/// Ingest one .osz: hash, copy to content-addressed storage, walk every +/// member (optionally writing extracted blob files and parsing every `.osu` +/// file), resolve `set_revision_id` from any `BeatmapSetID` we found, then +/// materialize all compact v1 row types. +/// +/// Returns Err only for failures that prevent producing an +/// `archive_revisions` row at all (file unreadable, destination unwritable). +/// Failures inside the ZIP are captured as `problems` rows plus a +/// non-`accepted` `ingest_decision`. +/// +/// `skip_difficulty` skips the rosu-pp pass — useful for fast iteration on +/// upstream phases. The `difficulty_attributes` field is empty when set. +pub fn ingest_archive( + archive_path: &Path, + archives_dir: &Path, + blobs_dir: &Path, + ingest_batch_id: &str, + tool_version: &str, + schema_version: &str, + skip_difficulty: bool, +) -> Result { + ingest_archive_with_options( + archive_path, + archives_dir, + blobs_dir, + ingest_batch_id, + tool_version, + schema_version, + IngestOptions { + skip_difficulty, + write_blobs: true, + }, + ) +} + +pub fn ingest_archive_with_options( + archive_path: &Path, + archives_dir: &Path, + blobs_dir: &Path, + ingest_batch_id: &str, + tool_version: &str, + schema_version: &str, + options: IngestOptions, +) -> Result { + // 1. Hash archive bytes (independent of ZIP parsing). + let (archive_sha256, archive_size) = archive::hash_file(archive_path) + .with_context(|| format!("hashing {}", archive_path.display()))?; + let archive_revision_id = archive_sha256.clone(); + let now_ms = unix_now_ms(); + + // 2. Compute content-addressed storage location and copy the bytes if not + // already there. Done BEFORE attempting to open the ZIP so even + // quarantined archives are preserved. + let (aa, bb) = paths::shard(&archive_sha256); + let archive_dest = archives_dir + .join("sha256") + .join(&aa) + .join(&bb) + .join(format!("{archive_sha256}.osz")); + let archive_path_repo = format!("archives/sha256/{aa}/{bb}/{archive_sha256}.osz"); + atomic_copy_if_absent(archive_path, &archive_dest) + .with_context(|| format!("storing archive at {}", archive_dest.display()))?; + + // 3. Per-archive accumulators. set_revision_id is "unknown:" during + // the walk; once we've parsed all .osu files we resolve the real value + // from any non-zero BeatmapSetID and rewrite the placeholder rows. + let placeholder_set_revision_id = format!("unknown:{archive_sha256}"); + let original_filename = archive_path + .file_name() + .and_then(|s| s.to_str()) + .map(String::from); + + let mut acc = MemberAcc { + archive_revision_id: &archive_revision_id, + set_revision_id: &placeholder_set_revision_id, + ingest_batch_id, + blobs_dir, + write_blobs: options.write_blobs, + logical_files: Vec::new(), + problems: Vec::new(), + osu_parses: Vec::new(), + osb_parses: Vec::new(), + path_key_counts: HashMap::new(), + first_nfc_by_path_key: HashMap::new(), + problem_seq: 0, + }; + + // 4. Walk the ZIP. .osu files are parsed inline; everything else is just + // blob-written + tracked. + let scan_outcome = + archive::process_path(archive_path, |hdr, content| acc.on_member(hdr, content)); + + let (ingest_decision, ingest_decision_reason, scan) = match scan_outcome { + Ok(scan) => ("accepted".to_string(), None, Some(scan)), + Err(e) if e.is_quarantinable_zip_open_failure() => { + acc.add_problem("fatal", "zip", &format!("could not open zip: {e:#}"), None); + ("quarantined".to_string(), Some(format!("{e:#}")), None) + } + Err(e) => { + return Err(e).with_context(|| { + format!("walking archive members for {}", archive_path.display()) + }); + } + }; + + let (member_count, zip_comment, zip_warnings) = match scan { + Some(s) => (s.member_count as i32, s.zip_comment, s.warnings), + None => (0, None, Vec::new()), + }; + + // Per-member decode/decompress warnings get flattened into one + // archive-level zip_warning string AND a problem row each (so they're + // queryable by category). + let zip_warning = if zip_warnings.is_empty() { + None + } else { + for w in &zip_warnings { + acc.add_problem("warning", "zip", w, None); + } + Some(zip_warnings.join("; ")) + }; + + // Move accumulator contents out so we can stop borrowing the placeholder. + let MemberAcc { + mut logical_files, + mut problems, + osu_parses, + osb_parses, + problem_seq, + .. + } = acc; + let mut problem_seq = problem_seq; + + // 5. Resolve set identity from any successfully-parsed .osu file. Falls + // back to a fingerprint hash of the .osu blob shas, then to "unknown" + // when there are no .osu files at all. + let filename_stem = archive_path.file_stem().and_then(|s| s.to_str()); + let set_identity = resolve_set_identity(&osu_parses, &archive_sha256, filename_stem); + + // 6. Rewrite the placeholder set_revision_id everywhere it leaked. + // logical_file_id contains it as a prefix so that's recomputed too. + rewrite_placeholder_ids( + &mut logical_files, + &mut problems, + &placeholder_set_revision_id, + &set_identity, + ); + + // 7. Build the Phase 10 row types. + let has_osb = logical_files + .iter() + .any(|r| r.extension.as_deref() == Some("osb")); + + let mut beatmaps: Vec = osu_parses + .iter() + .map(|p| build_beatmap_row(p, &set_identity, &archive_revision_id, has_osb)) + .collect(); + for (parsed, bm) in osu_parses.iter().zip(beatmaps.iter()) { + if let Some(err) = parsed.parse_error.as_ref() { + let severity = match parsed.parse_status { + osu_parse::ParseStatus::Failed => "error", + _ => "warning", + }; + push_problem( + &mut problems, + &mut problem_seq, + ingest_batch_id, + &archive_revision_id, + &set_identity.set_revision_id, + Some(bm.beatmap_uid.clone()), + Some(bm.osu_logical_file_id.clone()), + severity, + "parse", + &format!(".osu parse_status={}", bm.parse_status), + Some(err.clone()), + Some(osu_parse::PARSER_NAME.to_string()), + Some(osu_parse::PARSER_VERSION.to_string()), + ); + } + } + + // 7b. Build the Phase 11 storyboard rows (sources + elements + commands + + // variables) for both shared_set (.osb) and difficulty_local (.osu + // [Events]) scopes. Done AFTER rewrite_placeholder_ids so every + // storyboard_source_id / element_id / command_id is built against the + // final set_revision_id and beatmap_uid. + let mut storyboard_sources: Vec = Vec::new(); + let mut storyboard_elements: Vec = Vec::new(); + let mut storyboard_commands: Vec = Vec::new(); + let mut storyboard_variables: Vec = Vec::new(); + for osb in &osb_parses { + build_storyboard_rows( + &osb.parsed, + Scope::SharedSet, + &set_identity.set_revision_id, + None, + &osb.logical_file_id_suffix, + osb.path_posix + .clone() + .unwrap_or_else(|| osb.path_key.clone()), + osb.blob_sha256.clone(), + &mut storyboard_sources, + &mut storyboard_elements, + &mut storyboard_commands, + &mut storyboard_variables, + ); + } + for (parsed, bm) in osu_parses.iter().zip(beatmaps.iter()) { + if !bm.has_local_storyboard { + continue; + } + let Some(events_section) = parsed + .sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")) + else { + continue; + }; + let local = storyboard_parse::parse_difficulty_local(&events_section.raw_text); + // Even when the section had a storyboard marker (`has_local_storyboard + // = true`), our raw scan may produce no element rows — old maps + // sometimes have `[Events]` lines we skip on purpose (Background, + // Break, Color). Only emit a source row when there's actually + // something to point at. + if local.elements.is_empty() && local.commands.is_empty() { + continue; + } + build_storyboard_rows( + &local, + Scope::DifficultyLocal, + &set_identity.set_revision_id, + Some(bm.beatmap_uid.clone()), + &parsed.osu_logical_file_id_suffix, + parsed + .osu_path_posix + .clone() + .unwrap_or_else(|| parsed.osu_path_key.clone()), + parsed.osu_blob_sha256.clone(), + &mut storyboard_sources, + &mut storyboard_elements, + &mut storyboard_commands, + &mut storyboard_variables, + ); + } + backfill_beatmap_storyboard_flags( + &mut beatmaps, + &storyboard_sources, + &storyboard_elements, + &storyboard_commands, + ); + for source in &storyboard_sources { + if let Some(err) = source.parse_error.as_ref() { + push_problem( + &mut problems, + &mut problem_seq, + ingest_batch_id, + &archive_revision_id, + &set_identity.set_revision_id, + source.beatmap_uid.clone(), + Some(source.source_logical_file_id.clone()), + "warning", + "parse", + &format!("storyboard parse_status={}", source.parse_status), + Some(err.clone()), + Some(storyboard_parse::PARSER_NAME.to_string()), + Some(storyboard_parse::PARSER_VERSION.to_string()), + ); + } + } + + let mut osu_sections: Vec = Vec::new(); + let mut timing_points: Vec = Vec::new(); + let mut hit_objects_common: Vec = Vec::new(); + let mut hit_objects_osu: Vec = Vec::new(); + let mut hit_objects_taiko: Vec = Vec::new(); + let mut hit_objects_catch: Vec = Vec::new(); + let mut hit_objects_mania: Vec = Vec::new(); + let mut colours_rows: Vec = Vec::new(); + let mut breaks_rows: Vec = Vec::new(); + for (parsed, bm) in osu_parses.iter().zip(beatmaps.iter()) { + if let Some(c) = parsed.colours.as_ref() { + // Skip rows for empty [Colours] sections — they're metadata-free + // noise that adds nothing for ML and just bloats the table. + if !c.combo_colors.is_empty() + || c.slider_track_override.is_some() + || c.slider_border.is_some() + { + let raw_section_text = parsed + .sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Colours]")) + .map(|s| s.raw_text.clone()) + .unwrap_or_default(); + colours_rows.push(build_colours_row(c, bm, raw_section_text)); + } + } + for (idx, br) in parsed.breaks.iter().enumerate() { + // `parsed.breaks` already carries break_index in declared order; + // re-stamp from the iter index defensively in case parser ordering + // ever drifts. + breaks_rows.push(BreakRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + break_index: idx as i32, + start_time_ms: br.start_time_ms, + end_time_ms: br.end_time_ms, + // Saturating sub: real breaks fit comfortably in i32 (audio + // length, ms), but a hostile [Events] line with extreme i32 + // start/end values would overflow plain `-`. Defensive only. + duration_ms: br.end_time_ms.saturating_sub(br.start_time_ms), + raw_line: br.raw_line.clone(), + }); + } + for sec in &parsed.sections { + osu_sections.push(OsuSectionRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: set_identity.set_revision_id.clone(), + section_name: sec.section_name.clone(), + line_index_start: sec.line_index_start, + line_index_end: sec.line_index_end, + byte_start: sec.byte_start, + byte_end: sec.byte_end, + raw_text: sec.raw_text.clone(), + parse_status: sec.parse_status.clone(), + }); + } + for tp in &parsed.timing_points { + let bpm = if tp.uninherited && tp.beat_length > 0.0 { + Some(60_000.0 / tp.beat_length) + } else { + None + }; + let svm = if !tp.uninherited && tp.beat_length < 0.0 { + Some(-100.0 / tp.beat_length) + } else { + None + }; + let is_kiai = tp.effects.map(|e| e & 1 != 0).unwrap_or(false); + timing_points.push(TimingPointRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: set_identity.set_revision_id.clone(), + row_index: tp.row_index, + time_ms: tp.time_ms, + beat_length: tp.beat_length, + meter: tp.meter, + sample_set: tp.sample_set, + sample_index: tp.sample_index, + volume: tp.volume, + uninherited: tp.uninherited, + effects: tp.effects, + bpm, + slider_velocity_multiplier: svm, + is_kiai, + raw_line: tp.raw_line.clone(), + }); + } + for ho in &parsed.hit_objects { + hit_objects_common.push(build_hit_objects_common_row(ho, bm)); + // Route per-ruleset rows by `bm.mode`. Keep mode 0 routing + // explicit so that an unknown/garbage mode falls through to + // common-only (no per-ruleset row). + match bm.mode { + 0 => hit_objects_osu.push(build_hit_objects_osu_row(ho, bm)), + 1 => hit_objects_taiko.push(build_hit_objects_taiko_row( + ho, + bm, + &parsed.timing_points, + )), + 2 => hit_objects_catch.push(build_hit_objects_catch_row(ho, bm)), + 3 => hit_objects_mania.push(build_hit_objects_mania_row(ho, bm)), + _ => {} + } + } + } + + // 7c. Phase 12: extract references from .osu + .osb sources, resolve + // against the logical_files index, and emit asset_references rows. + // Then backfill blob refs into beatmaps + storyboard_elements + the + // is_referenced flag on logical_files. + let resolver_entries: Vec = logical_files + .iter() + .map(|r| LogicalFileEntry { + logical_file_id: r.logical_file_id.clone(), + blob_sha256: r.blob_sha256.clone(), + path_raw: r.path_raw.clone(), + path_posix: r.path_posix.clone(), + path_nfc: r.path_nfc.clone(), + path_key: r.path_key.clone(), + }) + .collect(); + let resolver_index = ResolverIndex::build(&resolver_entries); + + let mut extracted: Vec = Vec::new(); + for (parsed, bm) in osu_parses.iter().zip(beatmaps.iter()) { + extracted.extend(references::extract_from_beatmap( + parsed, + &set_identity.set_revision_id, + &bm.beatmap_uid, + )); + } + for osb in &osb_parses { + let source_path = osb + .path_posix + .clone() + .unwrap_or_else(|| osb.path_key.clone()); + extracted.extend(references::extract_from_osb( + &osb.parsed, + &set_identity.set_revision_id, + &osb.logical_file_id_suffix, + &source_path, + )); + } + + let resolved = references::resolve(extracted, &resolver_index); + let asset_references = build_asset_reference_rows(&resolved, &set_identity.set_revision_id); + for r in &asset_references { + if r.is_missing || r.is_ambiguous || r.resolution_status == "invalid_path" { + let severity = if r.is_ambiguous { "error" } else { "warning" }; + push_problem( + &mut problems, + &mut problem_seq, + ingest_batch_id, + &archive_revision_id, + &set_identity.set_revision_id, + r.beatmap_uid.clone(), + Some(r.source_logical_file_id.clone()), + severity, + "reference", + &format!("{} reference {}", r.reference_kind, r.resolution_status), + Some(r.raw_reference.clone()), + None, + None, + ); + } + } + backfill_beatmaps_from_references(&mut beatmaps, &asset_references); + backfill_storyboard_elements_from_references( + &mut storyboard_elements, + &storyboard_sources, + &asset_references, + ); + backfill_logical_files_from_references(&mut logical_files, &asset_references); + let num_missing_references = asset_references.iter().filter(|r| r.is_missing).count() as i32; + + // 7d. Phase 13: rosu-pp difficulty attributes. One row per (beatmap, mod) + // in the per-ruleset default mod set. Skip beatmaps with + // parse_status="failed" (no ruleset is even known) and mode strings + // that aren't one of the four standards. rosu-pp parses the .osu + // bytes itself, so partial-rosu-map maps still get a shot at + // difficulty if rosu-pp tolerates them. + let difficulty_attributes = if options.skip_difficulty { + Vec::new() + } else { + build_difficulty_attribute_rows(&osu_parses, &beatmaps) + }; + for row in &difficulty_attributes { + if row.calculation_status != "ok" { + push_problem( + &mut problems, + &mut problem_seq, + ingest_batch_id, + &archive_revision_id, + &set_identity.set_revision_id, + Some(row.beatmap_uid.clone()), + None, + "warning", + "rosu_pp", + &format!( + "difficulty calculation failed for mods={}", + row.mods_acronym + ), + row.calculation_error.clone(), + Some(row.calculator.clone()), + Some(row.calculator_version.clone()), + ); + } + } + + // 8. set_revisions row (one per archive). Stable set-level metadata is + // picked from the first parsed beatmap; mode_set and tags are unions + // across every difficulty. + let representative = beatmaps.first(); + let mode_set: Vec = { + let mut seen = HashSet::new(); + let mut out = Vec::new(); + for b in &beatmaps { + if seen.insert(b.ruleset.clone()) { + out.push(b.ruleset.clone()); + } + } + out + }; + let tag_union: Option> = { + let mut seen = HashSet::new(); + let mut out = Vec::new(); + for b in &beatmaps { + if let Some(tags) = b.tags.as_ref() { + for tag in tags { + if seen.insert(tag.clone()) { + out.push(tag.clone()); + } + } + } + } + if out.is_empty() { + None + } else { + Some(out) + } + }; + let unique_blob_count = logical_files + .iter() + .map(|r| r.blob_sha256.as_str()) + .collect::>() + .len() as i32; + + let set_revision = SetRevisionRow { + set_revision_id: set_identity.set_revision_id.clone(), + archive_revision_id: archive_revision_id.clone(), + beatmapset_id: set_identity.beatmapset_id, + beatmapset_id_source: set_identity.beatmapset_id_source.to_string(), + title: representative.and_then(|b| b.title.clone()), + title_unicode: representative.and_then(|b| b.title_unicode.clone()), + artist: representative.and_then(|b| b.artist.clone()), + artist_unicode: representative.and_then(|b| b.artist_unicode.clone()), + creator: representative.and_then(|b| b.creator.clone()), + source: representative.and_then(|b| b.source.clone()), + tags: tag_union, + mode_set, + num_beatmaps: beatmaps.len() as i32, + num_files: logical_files.len() as i32, + num_blobs: unique_blob_count, + num_missing_references, + }; + + let archive_revision = ArchiveRevisionRow { + archive_revision_id: archive_revision_id.clone(), + archive_sha256, + archive_path: archive_path_repo, + original_filename, + size_bytes: archive_size as i64, + member_count, + zip_comment, + zip_warning, + source_kind: None, + source_url: None, + ingested_at: now_ms, + ingest_batch_id: ingest_batch_id.to_string(), + ingest_tool_version: tool_version.to_string(), + schema_version: schema_version.to_string(), + ingest_decision, + ingest_decision_reason, + ingest_decision_at: now_ms, + }; + + Ok(IngestStats { + archive_revision, + set_revision, + logical_files, + beatmaps, + osu_sections, + timing_points, + hit_objects_common, + hit_objects_osu, + hit_objects_taiko, + hit_objects_catch, + hit_objects_mania, + storyboard_sources, + storyboard_elements, + storyboard_commands, + storyboard_variables, + asset_references, + difficulty_attributes, + colours: colours_rows, + breaks: breaks_rows, + problems, + }) +} + +fn emit_stats(w: &mut W, stats: &IngestStats) -> Result<()> { + output::emit("archive_revisions", &stats.archive_revision, w)?; + if stats.archive_revision.ingest_decision == "accepted" { + output::emit("set_revisions", &stats.set_revision, w)?; + for row in &stats.logical_files { + output::emit("logical_files", row, w)?; + } + for row in &stats.beatmaps { + output::emit("beatmaps", row, w)?; + } + for row in &stats.osu_sections { + output::emit("osu_sections", row, w)?; + } + for row in &stats.timing_points { + output::emit("timing_points", row, w)?; + } + for row in &stats.hit_objects_common { + output::emit("hit_objects_common", row, w)?; + } + for row in &stats.hit_objects_osu { + output::emit("hit_objects_osu", row, w)?; + } + for row in &stats.hit_objects_taiko { + output::emit("hit_objects_taiko", row, w)?; + } + for row in &stats.hit_objects_catch { + output::emit("hit_objects_catch", row, w)?; + } + for row in &stats.hit_objects_mania { + output::emit("hit_objects_mania", row, w)?; + } + for row in &stats.storyboard_sources { + output::emit("storyboard_sources", row, w)?; + } + for row in &stats.storyboard_elements { + output::emit("storyboard_elements", row, w)?; + } + for row in &stats.storyboard_commands { + output::emit("storyboard_commands", row, w)?; + } + for row in &stats.storyboard_variables { + output::emit("storyboard_variables", row, w)?; + } + for row in &stats.asset_references { + output::emit("asset_references", row, w)?; + } + for row in &stats.difficulty_attributes { + output::emit("difficulty_attributes", row, w)?; + } + for row in &stats.colours { + output::emit("colours", row, w)?; + } + for row in &stats.breaks { + output::emit("breaks", row, w)?; + } + } + for row in &stats.problems { + output::emit("problems", row, w)?; + } + Ok(()) +} + +struct MemberAcc<'a> { + archive_revision_id: &'a str, + set_revision_id: &'a str, + ingest_batch_id: &'a str, + blobs_dir: &'a Path, + write_blobs: bool, + logical_files: Vec, + problems: Vec, + osu_parses: Vec, + osb_parses: Vec, + path_key_counts: HashMap, + first_nfc_by_path_key: HashMap>, + problem_seq: u32, +} + +/// A parsed `.osb` member, with the path/blob info we need to build a +/// `storyboard_sources` row once `set_revision_id` is resolved. +struct OsbParseRecord { + path_posix: Option, + path_key: String, + logical_file_id_suffix: String, + blob_sha256: String, + parsed: StoryboardParse, +} + +impl<'a> MemberAcc<'a> { + fn on_member(&mut self, hdr: MemberHeader, content: Vec) -> Result<()> { + let norm = paths::normalize(&hdr.raw_name_bytes); + + // Directory entries: nothing to store. + if hdr.is_dir || norm.is_dir_marker { + return Ok(()); + } + + // Junk filter. + if let Some(pattern) = output::match_junk(&norm.key) { + self.add_problem( + "info", + "junk", + &format!( + "skipped junk member: {} (pattern={pattern})", + display_path(&norm) + ), + Some(&norm.key), + ); + return Ok(()); + } + + // Zero-byte filter. + if content.is_empty() { + self.add_problem( + "info", + "junk", + &format!("skipped zero-byte member: {}", display_path(&norm)), + Some(&norm.key), + ); + return Ok(()); + } + + // Hash + optionally write blob. + let blob_sha256 = sha256_hex(&content); + let (aa, bb) = paths::shard(&blob_sha256); + let blob_dest = self + .blobs_dir + .join("sha256") + .join(&aa) + .join(&bb) + .join(format!("{blob_sha256}.bin")); + if self.write_blobs { + atomic_write_if_absent(&blob_dest, &content) + .with_context(|| format!("writing blob {}", blob_dest.display()))?; + } + + // Track duplicate/case-colliding path_key values within this archive. + // path_key remains the lookup key, but logical_file_id needs a stable + // member suffix for duplicate keys so the logical_files primary key + // stays unique and joins do not collapse distinct archive members. + let mut warnings: Vec<&'static str> = norm.warnings.clone(); + let path_key = norm.key.clone(); + let occurrence = { + let count = self.path_key_counts.entry(path_key.clone()).or_insert(0); + *count += 1; + *count + }; + if occurrence == 1 { + self.first_nfc_by_path_key + .insert(path_key.clone(), norm.nfc.clone()); + } else { + warnings.push("duplicate_path_key"); + if self + .first_nfc_by_path_key + .get(&path_key) + .is_some_and(|first| first != &norm.nfc) + { + warnings.push("case_collision"); + } + } + let logical_file_suffix = if occurrence == 1 { + path_key.clone() + } else { + format!("{path_key}::member{occurrence:04}") + }; + + // `norm.extension` is recovered even when `posix` is None (Shift-JIS + // paths on 2008-era beatmaps), so .osu/.osb/.mp3 still classify + // correctly. + let extension = norm.extension.clone(); + let media_kind = output::classify_media_kind(extension.as_deref()).to_string(); + let roles = output::classify_roles(extension.as_deref()); + + // Parse .osu inline. Done BEFORE building the LogicalFileRow so the + // norm fields can be cloned cheaply (vs. read-after-move). + if extension.as_deref() == Some("osu") { + let parsed = osu_parse::parse( + &content, + blob_sha256.clone(), + norm.raw.clone(), + norm.posix.clone(), + norm.key.clone(), + logical_file_suffix.clone(), + ); + self.osu_parses.push(parsed); + } + + // Parse .osb inline. Same rationale as .osu. + if extension.as_deref() == Some("osb") { + let parsed = storyboard_parse::parse_osb(&content); + self.osb_parses.push(OsbParseRecord { + path_posix: norm.posix.clone(), + path_key: norm.key.clone(), + logical_file_id_suffix: logical_file_suffix.clone(), + blob_sha256: blob_sha256.clone(), + parsed, + }); + } + + let path_warning = if warnings.is_empty() { + None + } else { + Some(warnings.join(";")) + }; + + let row = LogicalFileRow { + logical_file_id: format!("{}::{}", self.set_revision_id, logical_file_suffix), + set_revision_id: self.set_revision_id.to_string(), + archive_revision_id: self.archive_revision_id.to_string(), + beatmapset_id: None, + path_raw: norm.raw, + path_posix: norm.posix, + path_nfc: norm.nfc, + path_key: norm.key, + path_raw_bytes_base64: Some(norm.raw_bytes_base64), + blob_sha256, + size_bytes: content.len() as i64, + extension, + mime_guess: None, + media_kind, + roles, + // Reference resolution lands in Phase 12 — defaults conservative. + is_referenced: false, + is_unreferenced_extra: true, + crc32: Some(format!("{:08x}", hdr.crc32)), + compressed_size: Some(hdr.compressed_size as i64), + uncompressed_size: Some(hdr.uncompressed_size as i64), + zip_mtime: hdr.mtime_unix_ms, + path_warning, + }; + + self.logical_files.push(row); + Ok(()) + } + + fn add_problem( + &mut self, + severity: &str, + category: &str, + message: &str, + raw_context: Option<&str>, + ) { + self.problem_seq += 1; + self.problems.push(ProblemRow { + problem_id: format!( + "{}::{}::{:08}", + self.ingest_batch_id, self.archive_revision_id, self.problem_seq + ), + set_revision_id: self.set_revision_id.to_string(), + beatmap_uid: None, + logical_file_id: None, + severity: severity.to_string(), + category: category.to_string(), + message: message.to_string(), + raw_context: raw_context.map(String::from), + parser_name: None, + parser_version: None, + ingest_batch_id: self.ingest_batch_id.to_string(), + }); + } +} + +#[allow(clippy::too_many_arguments)] +fn push_problem( + problems: &mut Vec, + problem_seq: &mut u32, + ingest_batch_id: &str, + archive_revision_id: &str, + set_revision_id: &str, + beatmap_uid: Option, + logical_file_id: Option, + severity: &str, + category: &str, + message: &str, + raw_context: Option, + parser_name: Option, + parser_version: Option, +) { + *problem_seq += 1; + problems.push(ProblemRow { + problem_id: format!( + "{ingest_batch_id}::{archive_revision_id}::{:08}", + *problem_seq + ), + set_revision_id: set_revision_id.to_string(), + beatmap_uid, + logical_file_id, + severity: severity.to_string(), + category: category.to_string(), + message: message.to_string(), + raw_context, + parser_name, + parser_version, + ingest_batch_id: ingest_batch_id.to_string(), + }); +} + +/// Resolves identity for the beatmapset this archive represents. +struct SetIdentity { + set_revision_id: String, + beatmapset_id: Option, + beatmapset_id_source: &'static str, +} + +fn resolve_set_identity( + parses: &[ParsedBeatmap], + archive_sha256: &str, + archive_filename_stem: Option<&str>, +) -> SetIdentity { + // Strategy 1: any successfully-parsed .osu with BeatmapSetID > 0. + let from_header = parses + .iter() + .filter_map(|p| p.fields.as_ref()) + .find(|f| f.beatmapset_id > 0) + .map(|f| f.beatmapset_id as i64); + if let Some(id) = from_header { + return SetIdentity { + set_revision_id: format!("{id}:{archive_sha256}"), + beatmapset_id: Some(id), + beatmapset_id_source: "osu_header", + }; + } + + // Strategy 2: numeric archive filename. The local corpus is named by + // beatmapset id (`12345.osz`). Older maps often carry BeatmapSetID:-1 in + // the .osu header; using the filename when it is a plain positive integer + // keeps those known sets in the same logical identity as later known-ID + // revisions. + if let Some(stem) = archive_filename_stem { + if stem.chars().all(|c| c.is_ascii_digit()) { + if let Ok(id) = stem.parse::() { + if id > 0 { + return SetIdentity { + set_revision_id: format!("{id}:{archive_sha256}"), + beatmapset_id: Some(id), + beatmapset_id_source: "filename", + }; + } + } + } + } + + // Strategy 3: canonical_set_fingerprint = sha256 of sorted .osu blob shas. + if !parses.is_empty() { + let mut hashes: Vec<&str> = parses.iter().map(|p| p.osu_blob_sha256.as_str()).collect(); + hashes.sort(); + let mut h = Sha256::new(); + for s in &hashes { + h.update(s.as_bytes()); + h.update(b"\n"); + } + let fp = hex::encode(h.finalize()); + let fp_short: String = fp.chars().take(16).collect(); + return SetIdentity { + set_revision_id: format!("fingerprint:{fp_short}:{archive_sha256}"), + beatmapset_id: None, + beatmapset_id_source: "fingerprint", + }; + } + + // Strategy 4: nothing to fingerprint (no .osu files). + SetIdentity { + set_revision_id: format!("unknown:{archive_sha256}"), + beatmapset_id: None, + beatmapset_id_source: "unknown", + } +} + +fn rewrite_placeholder_ids( + logical_files: &mut [LogicalFileRow], + problems: &mut [ProblemRow], + placeholder: &str, + set_identity: &SetIdentity, +) { + for r in logical_files.iter_mut() { + if r.set_revision_id == placeholder { + r.set_revision_id = set_identity.set_revision_id.clone(); + let old_prefix = format!("{placeholder}::"); + let suffix = r + .logical_file_id + .strip_prefix(&old_prefix) + .map(str::to_string) + .unwrap_or_else(|| r.path_key.clone()); + r.logical_file_id = format!("{}::{}", set_identity.set_revision_id, suffix); + r.beatmapset_id = set_identity.beatmapset_id; + } + } + for p in problems.iter_mut() { + if p.set_revision_id == placeholder { + p.set_revision_id = set_identity.set_revision_id.clone(); + } + } +} + +fn build_beatmap_row( + parsed: &ParsedBeatmap, + set_identity: &SetIdentity, + archive_revision_id: &str, + has_osb: bool, +) -> BeatmapRow { + let beatmap_uid = compute_beatmap_uid(parsed); + let osu_logical_file_id = format!( + "{}::{}", + set_identity.set_revision_id, parsed.osu_logical_file_id_suffix + ); + + let beatmap_id = parsed.fields.as_ref().and_then(|f| { + if f.beatmap_id > 0 { + Some(f.beatmap_id as i64) + } else { + None + } + }); + let f = parsed.fields.as_ref(); + + BeatmapRow { + beatmap_uid, + beatmap_id, + beatmapset_id: set_identity.beatmapset_id, + set_revision_id: set_identity.set_revision_id.clone(), + archive_revision_id: archive_revision_id.to_string(), + osu_logical_file_id, + osu_blob_sha256: parsed.osu_blob_sha256.clone(), + osu_path_raw: parsed.osu_path_raw.clone(), + osu_path_posix: parsed.osu_path_posix.clone(), + + format_version: f.map(|x| x.format_version), + mode: f.map(|x| x.mode as i8).unwrap_or(0), + ruleset: f + .map(|x| x.ruleset.clone()) + .unwrap_or_else(|| "unknown".to_string()), + ruleset_aliases: f.and_then(|x| osu_parse::ruleset_aliases(x.mode)), + + title: f.map(|x| x.title.clone()), + title_unicode: f.map(|x| x.title_unicode.clone()), + artist: f.map(|x| x.artist.clone()), + artist_unicode: f.map(|x| x.artist_unicode.clone()), + creator: f.map(|x| x.creator.clone()), + version: f.map(|x| x.version.clone()), + source: f.map(|x| x.source.clone()), + tags: f.map(|x| x.tags.clone()), + + audio_filename_raw: f.map(|x| x.audio_filename_raw.clone()), + audio_lead_in_ms: f.map(|x| x.audio_lead_in_ms), + // Reference resolution → Phase 12. + audio_reference_id: None, + audio_blob_sha256: None, + background_reference_id: None, + background_blob_sha256: None, + background_x: f.and_then(|x| x.background_x), + background_y: f.and_then(|x| x.background_y), + video_reference_id: None, + video_blob_sha256: None, + video_start_time_ms: f.and_then(|x| x.video_start_time_ms), + + hp_drain_rate: f.map(|x| x.hp_drain_rate).unwrap_or(0.0), + circle_size: f.map(|x| x.circle_size).unwrap_or(0.0), + overall_difficulty: f.map(|x| x.overall_difficulty).unwrap_or(0.0), + approach_rate: f.map(|x| x.approach_rate), + slider_multiplier: f.map(|x| x.slider_multiplier as f32), + slider_tick_rate: f.map(|x| x.slider_tick_rate as f32), + + preview_time_ms: f.map(|x| x.preview_time_ms), + countdown: f.map(|x| x.countdown), + sample_set: f.map(|x| x.sample_set.clone()), + stack_leniency: f.map(|x| x.stack_leniency), + special_style: f.map(|x| x.special_style), + widescreen_storyboard: f.map(|x| x.widescreen_storyboard), + letterbox_in_breaks: f.map(|x| x.letterbox_in_breaks), + epilepsy_warning: f.map(|x| x.epilepsy_warning), + samples_match_playback_rate: f.map(|x| x.samples_match_playback_rate), + + // Count from our raw [HitObjects] reparse rather than rosu's, so the + // count survives even when rosu rejects the file (parse_status="partial"). + hit_object_count: parsed.hit_objects.len() as i32, + // Use OUR section-level count (all rows, inherited + uninherited) to + // match the schema's "[TimingPoints] section" definition. rosu's + // `control_points.timing_points` is only the uninherited subset. + timing_point_count: parsed.timing_points.len() as i32, + break_count: f.map(|x| x.break_count).unwrap_or(0), + event_count: f.map(|x| x.event_count).unwrap_or(0), + + has_osb, + has_local_storyboard: f.map(|x| x.has_local_storyboard).unwrap_or(false), + has_effective_storyboard: has_osb || f.map(|x| x.has_local_storyboard).unwrap_or(false), + has_video: f.map(|x| x.has_video).unwrap_or(false), + has_missing_references: false, // Phase 12 + + parser_name: osu_parse::PARSER_NAME.to_string(), + parser_version: osu_parse::PARSER_VERSION.to_string(), + parse_status: parsed.parse_status.as_str().to_string(), + parse_error: parsed.parse_error.clone(), + } +} + +fn build_hit_objects_common_row(ho: &RawHitObject, bm: &BeatmapRow) -> HitObjectsCommonRow { + // Mania routes by `bm.mode == 3`; mirror the per-mania-row key_count so a + // mode-mixed model that loads `hit_objects_common` can still partition-prune + // by key_count. Sentinel `0` for non-mania keeps the partition tuple + // well-defined (mania key_count is always 1..=18 by construction). + let key_count = if bm.mode == 3i8 { + mania_key_count(bm.circle_size) + } else { + 0 + }; + HitObjectsCommonRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + ruleset: bm.ruleset.clone(), + key_count, + object_index: ho.object_index, + x: ho.x, + y: ho.y, + time_ms: ho.time_ms, + end_time_ms: ho.end_time_ms, + type_flags: ho.type_flags, + hit_sound_flags: ho.hit_sound_flags, + common_object_kind: ho.common_kind.as_str().to_string(), + is_new_combo: ho.is_new_combo, + combo_skip: ho.combo_skip, + raw_params: if ho.raw_params.is_empty() { + None + } else { + Some(ho.raw_params.clone()) + }, + raw_line: ho.raw_line.clone(), + parse_status: ho.parse_status.to_string(), + } +} + +fn build_hit_objects_osu_row(ho: &RawHitObject, bm: &BeatmapRow) -> HitObjectsOsuRow { + let osu_kind = match ho.common_kind { + HitObjectCommonKind::Circle => "circle", + HitObjectCommonKind::Slider => "slider", + HitObjectCommonKind::Spinner => "spinner", + // Holds shouldn't appear in osu! standard, but if one slips through + // (mis-tagged map) preserve the raw kind label rather than guess. + HitObjectCommonKind::Hold => "hold", + HitObjectCommonKind::Unknown => "unknown", + } + .to_string(); + + let (curve_type, control_points_json, repeats, pixel_length) = match ho.slider.as_ref() { + Some(s) => ( + Some(s.curve_type.clone()), + Some(serialize_control_points(&s.control_points)), + Some(s.repeats), + Some(s.pixel_length), + ), + None => (None, None, None, None), + }; + let (edge_sounds_raw, edge_sets_raw, edge_sounds, edge_sets) = ho + .slider + .as_ref() + .map(|s| { + ( + s.edge_sounds_raw.clone(), + s.edge_sets_raw.clone(), + s.edge_sounds.clone(), + s.edge_sets.clone(), + ) + }) + .unwrap_or((None, None, None, None)); + let (hs_normal, hs_addition, hs_index, hs_volume, hs_filename) = hit_sample_components(ho); + + HitObjectsOsuRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + object_index: ho.object_index, + osu_kind, + start_time_ms: ho.time_ms, + end_time_ms: ho.end_time_ms, + x: ho.x, + y: ho.y, + slider_curve_type: curve_type, + slider_control_points_json: control_points_json, + slider_repeats: repeats, + slider_pixel_length: pixel_length, + edge_sounds_raw, + edge_sets_raw, + edge_sounds, + edge_sets, + hit_sample_raw: ho.hit_sample_raw.clone(), + hit_sample_normal_set: hs_normal, + hit_sample_addition_set: hs_addition, + hit_sample_index: hs_index, + hit_sample_volume: hs_volume, + hit_sample_filename: hs_filename, + } +} + +/// Project a parsed `RawHitObject.hit_sample` into the five typed columns +/// every per-mode `hit_objects_*` table now carries. +fn hit_sample_components( + ho: &RawHitObject, +) -> ( + Option, + Option, + Option, + Option, + Option, +) { + match ho.hit_sample.as_ref() { + Some(s) => ( + s.normal_set, + s.addition_set, + s.index, + s.volume, + s.filename.clone(), + ), + None => (None, None, None, None, None), + } +} + +fn build_hit_objects_taiko_row( + ho: &RawHitObject, + bm: &BeatmapRow, + timing_points: &[RawTimingPoint], +) -> HitObjectsTaikoRow { + let taiko_kind = match ho.common_kind { + HitObjectCommonKind::Circle => { + // FINISH (4) marks the "big" variant; doesn't change don/kat + // distinction. Whistle (2) or Clap (8) → kat; otherwise don. + if ho.hit_sound_flags & 0b1010 != 0 { + "kat" + } else { + "don" + } + } + HitObjectCommonKind::Slider => "drumroll", + HitObjectCommonKind::Spinner => "denden", + _ => "unknown", + } + .to_string(); + + let active = active_timing_point_at(ho.time_ms, timing_points); + let (hs_normal, hs_addition, hs_index, hs_volume, hs_filename) = hit_sample_components(ho); + HitObjectsTaikoRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + object_index: ho.object_index, + taiko_kind, + start_time_ms: ho.time_ms, + end_time_ms: ho.end_time_ms, + // FINISH bit (=4) marks big don/kat (and big drumroll). + is_big: ho.hit_sound_flags & 4 != 0, + hit_sound_flags: ho.hit_sound_flags, + inherited_sample_set: active.and_then(|tp| tp.sample_set), + sample_index: active.and_then(|tp| tp.sample_index), + hit_sample_raw: ho.hit_sample_raw.clone(), + hit_sample_normal_set: hs_normal, + hit_sample_addition_set: hs_addition, + hit_sample_index: hs_index, + hit_sample_volume: hs_volume, + hit_sample_filename: hs_filename, + } +} + +fn build_hit_objects_catch_row(ho: &RawHitObject, bm: &BeatmapRow) -> HitObjectsCatchRow { + let catch_kind = match ho.common_kind { + HitObjectCommonKind::Circle => "fruit", + HitObjectCommonKind::Slider => "juice_stream", + HitObjectCommonKind::Spinner => "banana_shower", + _ => "unknown", + } + .to_string(); + + let (curve_type, control_points_json, repeats, pixel_length) = match ho.slider.as_ref() { + Some(s) => ( + Some(s.curve_type.clone()), + Some(serialize_control_points(&s.control_points)), + Some(s.repeats), + Some(s.pixel_length), + ), + None => (None, None, None, None), + }; + + let (hs_normal, hs_addition, hs_index, hs_volume, hs_filename) = hit_sample_components(ho); + HitObjectsCatchRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + object_index: ho.object_index, + catch_kind, + start_time_ms: ho.time_ms, + end_time_ms: ho.end_time_ms, + x: ho.x, + y: ho.y, + slider_curve_type: curve_type, + slider_control_points_json: control_points_json, + slider_repeats: repeats, + slider_pixel_length: pixel_length, + hit_sample_raw: ho.hit_sample_raw.clone(), + hit_sample_normal_set: hs_normal, + hit_sample_addition_set: hs_addition, + hit_sample_index: hs_index, + hit_sample_volume: hs_volume, + hit_sample_filename: hs_filename, + } +} + +fn build_hit_objects_mania_row(ho: &RawHitObject, bm: &BeatmapRow) -> HitObjectsManiaRow { + let mania_kind = match ho.common_kind { + HitObjectCommonKind::Hold => "hold", + HitObjectCommonKind::Circle => "note", + _ => "unknown", + } + .to_string(); + + let key_count = mania_key_count(bm.circle_size); + // floor((x_pos / 512) * keyCount) per the .osu spec for mania column derivation. + let column_index = ((ho.x as i64 * key_count as i64) / 512).clamp(0, (key_count - 1) as i64); + + let (hs_normal, hs_addition, hs_index, hs_volume, hs_filename) = hit_sample_components(ho); + HitObjectsManiaRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + object_index: ho.object_index, + mania_kind, + start_time_ms: ho.time_ms, + end_time_ms: ho.end_time_ms, + x: ho.x, + column_index: column_index as i32, + key_count, + circle_size: bm.circle_size, + hit_sound_flags: ho.hit_sound_flags, + hit_sample_raw: ho.hit_sample_raw.clone(), + hit_sample_normal_set: hs_normal, + hit_sample_addition_set: hs_addition, + hit_sample_index: hs_index, + hit_sample_volume: hs_volume, + hit_sample_filename: hs_filename, + } +} + +/// Build one `colours` row from a parsed `[Colours]` section. Caller must +/// ensure the section actually contains content; empty sections are skipped +/// upstream so this never emits an all-null row. +fn build_colours_row( + colours: &osu_parse::RawColours, + bm: &BeatmapRow, + raw_section_text: String, +) -> ColoursRow { + // Hand-build the JSON so we don't bring in serde_json for a fixed shape. + let mut combo_json = String::from("["); + for (i, (r, g, b)) in colours.combo_colors.iter().enumerate() { + if i > 0 { + combo_json.push(','); + } + combo_json.push_str(&format!("[{r},{g},{b}]")); + } + combo_json.push(']'); + + let (track_r, track_g, track_b) = match colours.slider_track_override { + Some((r, g, b)) => (Some(r), Some(g), Some(b)), + None => (None, None, None), + }; + let (border_r, border_g, border_b) = match colours.slider_border { + Some((r, g, b)) => (Some(r), Some(g), Some(b)), + None => (None, None, None), + }; + + ColoursRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + combo_count: colours.combo_colors.len() as i32, + combo_colors_json: combo_json, + slider_track_override_r: track_r, + slider_track_override_g: track_g, + slider_track_override_b: track_b, + slider_border_r: border_r, + slider_border_g: border_g, + slider_border_b: border_b, + raw_section_text, + parse_status: if colours.had_parse_failure { + "partial".to_string() + } else { + "ok".to_string() + }, + } +} + +/// Mania's `key_count` is `round(circle_size)` clamped to the 1..=18 range +/// the game allows. Stored as int32 so partition pruning by key_count works. +fn mania_key_count(circle_size: f32) -> i32 { + let k = circle_size.round() as i32; + k.clamp(1, 18) +} + +fn serialize_control_points(points: &[(i32, i32)]) -> String { + // `[[x,y],[x,y],...]` — straightforward enough that hand-writing avoids + // pulling serde_json::to_string for a fixed shape. + let mut s = String::from("["); + for (i, (x, y)) in points.iter().enumerate() { + if i > 0 { + s.push(','); + } + s.push('['); + s.push_str(&x.to_string()); + s.push(','); + s.push_str(&y.to_string()); + s.push(']'); + } + s.push(']'); + s +} + +/// Most-recent timing point at or before `time_ms`. RawTimingPoint is in +/// source order, which the .osu spec also requires to be chronological — so +/// the last matching entry by `time_ms <= time` is the active one. +fn active_timing_point_at(time_ms: i32, tps: &[RawTimingPoint]) -> Option<&RawTimingPoint> { + let t = time_ms as f64; + tps.iter().rev().find(|tp| tp.time_ms <= t) +} + +/// Append rows for one parsed storyboard source (a `.osb` or one `.osu` +/// `[Events]` section) to the four storyboard vecs. The source suffix is the +/// same unique suffix used by `logical_files.logical_file_id`, so duplicate +/// archive members keep valid FKs. +#[allow(clippy::too_many_arguments)] +fn build_storyboard_rows( + parsed: &StoryboardParse, + scope: Scope, + set_revision_id: &str, + beatmap_uid: Option, + source_logical_file_id_suffix: &str, + source_path: String, + source_blob_sha256: String, + sources: &mut Vec, + elements: &mut Vec, + commands: &mut Vec, + variables: &mut Vec, +) { + let suffix = match scope { + Scope::SharedSet => source_logical_file_id_suffix.to_string(), + Scope::DifficultyLocal => beatmap_uid + .clone() + .unwrap_or_else(|| source_logical_file_id_suffix.to_string()), + }; + let storyboard_source_id = format!("{set_revision_id}::sb::{}::{suffix}", scope.as_str()); + let source_logical_file_id = format!("{set_revision_id}::{source_logical_file_id_suffix}"); + + sources.push(StoryboardSourceRow { + storyboard_source_id: storyboard_source_id.clone(), + set_revision_id: set_revision_id.to_string(), + beatmap_uid: beatmap_uid.clone(), + scope: scope.as_str().to_string(), + source_logical_file_id, + source_path, + source_blob_sha256, + parser_name: storyboard_parse::PARSER_NAME.to_string(), + parser_version: storyboard_parse::PARSER_VERSION.to_string(), + parse_status: parsed.parse_status.as_str().to_string(), + parse_error: parsed.parse_error.clone(), + }); + + for elem in &parsed.elements { + let storyboard_element_id = format!("{storyboard_source_id}::{}", elem.element_index); + elements.push(StoryboardElementRow { + storyboard_element_id, + storyboard_source_id: storyboard_source_id.clone(), + set_revision_id: set_revision_id.to_string(), + beatmap_uid: beatmap_uid.clone(), + element_index: elem.element_index, + layer: elem.layer.clone(), + origin: elem.origin.clone(), + element_kind: elem.element_kind.clone(), + file_reference_raw: elem.file_reference_raw.clone(), + // Reference resolution → Phase 12. + file_reference_id: None, + resolved_blob_sha256: None, + x: elem.x, + y: elem.y, + frame_count: elem.frame_count, + frame_delay: elem.frame_delay, + loop_type: elem.loop_type.clone(), + sample_time_ms: elem.sample_time_ms, + sample_volume: elem.sample_volume, + raw_line: elem.raw_line.clone(), + parse_status: elem.parse_status.to_string(), + }); + } + + for cmd in &parsed.commands { + let storyboard_element_id = format!("{storyboard_source_id}::{}", cmd.element_index); + let storyboard_command_id = format!("{storyboard_element_id}::cmd::{}", cmd.command_index); + let parent_command_id = cmd + .parent_command_index + .map(|p| format!("{storyboard_element_id}::cmd::{p}")); + commands.push(StoryboardCommandRow { + storyboard_command_id, + storyboard_element_id, + storyboard_source_id: storyboard_source_id.clone(), + set_revision_id: set_revision_id.to_string(), + beatmap_uid: beatmap_uid.clone(), + scope: scope.as_str().to_string(), + element_index: cmd.element_index, + command_index: cmd.command_index, + parent_command_id, + command_code: cmd.command_code.clone(), + easing: cmd.easing, + start_time_ms: cmd.start_time_ms, + end_time_ms: cmd.end_time_ms, + params_json: cmd.params_json.clone(), + raw_line: cmd.raw_line.clone(), + parse_status: cmd.parse_status.to_string(), + }); + } + + for var in &parsed.variables { + variables.push(StoryboardVariableRow { + storyboard_source_id: storyboard_source_id.clone(), + set_revision_id: set_revision_id.to_string(), + beatmap_uid: beatmap_uid.clone(), + scope: scope.as_str().to_string(), + variable_name: var.name.clone(), + raw_value: var.raw_value.clone(), + // We don't currently expand variables in the variables table; the + // expanded form is captured implicitly in the `storyboard_commands` + // rows (params_json is post-substitution). + expanded_value: None, + line_index: var.line_index, + }); + } +} + +/// Derive the beatmap-level storyboard flags from emitted storyboard rows. +/// +/// A bare `.osb` file (or an `[Events]` section containing only background / +/// break / colour metadata) is not an effective storyboard for ML consumers. +/// The useful signal is whether we emitted at least one element or command +/// for a shared-set or difficulty-local source. +fn backfill_beatmap_storyboard_flags( + beatmaps: &mut [BeatmapRow], + sources: &[StoryboardSourceRow], + elements: &[StoryboardElementRow], + commands: &[StoryboardCommandRow], +) { + use std::collections::{HashMap, HashSet}; + + let source_meta: HashMap<&str, (&str, Option<&str>)> = sources + .iter() + .map(|s| { + ( + s.storyboard_source_id.as_str(), + (s.scope.as_str(), s.beatmap_uid.as_deref()), + ) + }) + .collect(); + + let mut active_sources: HashSet<&str> = HashSet::new(); + for elem in elements { + active_sources.insert(elem.storyboard_source_id.as_str()); + } + for cmd in commands { + active_sources.insert(cmd.storyboard_source_id.as_str()); + } + + let mut has_shared = false; + let mut local_by_uid: HashSet<&str> = HashSet::new(); + for source_id in active_sources { + let Some((scope, beatmap_uid)) = source_meta.get(source_id).copied() else { + continue; + }; + match scope { + "shared_set" => has_shared = true, + "difficulty_local" => { + if let Some(uid) = beatmap_uid { + local_by_uid.insert(uid); + } + } + _ => {} + } + } + + for bm in beatmaps { + let has_local = local_by_uid.contains(bm.beatmap_uid.as_str()); + bm.has_local_storyboard = has_local; + bm.has_effective_storyboard = has_shared || has_local; + } +} + +/// Convert resolved references into `asset_references` Parquet rows. +/// Reference IDs are `::ref::::` where +/// `seq` resets per source (matches the schema description). Sources are +/// processed in input order, which extract_from_beatmap / extract_from_osb +/// produce deterministically. +fn build_asset_reference_rows( + resolved: &[ResolvedReference], + set_revision_id: &str, +) -> Vec { + let mut per_source_seq: std::collections::HashMap = + std::collections::HashMap::new(); + let mut out = Vec::with_capacity(resolved.len()); + for r in resolved { + let seq = per_source_seq + .entry(r.source_logical_file_id.clone()) + .or_insert(0); + let reference_id = format!( + "{set_revision_id}::ref::{}::{}", + r.source_logical_file_id, *seq + ); + *seq += 1; + let status_str = r.resolution_status.as_str().to_string(); + out.push(AssetReferenceRow { + reference_id, + set_revision_id: set_revision_id.to_string(), + beatmap_uid: r.beatmap_uid.clone(), + source_logical_file_id: r.source_logical_file_id.clone(), + source_path: r.source_path.clone(), + source_section: r.source_section.clone(), + source_context: r.source_context.clone(), + reference_kind: r.reference_kind.as_str().to_string(), + raw_reference: r.raw_reference.clone(), + normalized_reference: r.normalized_reference.clone(), + lookup_key: r.lookup_key.clone(), + resolved_logical_file_id: r.resolved_logical_file_id.clone(), + resolved_blob_sha256: r.resolved_blob_sha256.clone(), + resolved_path_posix: r.resolved_path_posix.clone(), + resolution_strategy: status_str.clone(), + resolution_status: status_str, + is_missing: r.is_missing, + is_ambiguous: r.is_ambiguous, + raw_line: r.raw_line.clone(), + }); + } + out +} + +/// Fill in audio_*, background_*, video_* blob refs and has_missing_references +/// on each beatmap row. For each (beatmap_uid, kind) we pick the first matching +/// asset_references row. Most beatmap have at most one of each. +fn backfill_beatmaps_from_references(beatmaps: &mut [BeatmapRow], refs: &[AssetReferenceRow]) { + use std::collections::HashMap; + let mut audio: HashMap<&str, &AssetReferenceRow> = HashMap::new(); + let mut bg: HashMap<&str, &AssetReferenceRow> = HashMap::new(); + let mut video: HashMap<&str, &AssetReferenceRow> = HashMap::new(); + let mut missing_by_uid: HashMap<&str, bool> = HashMap::new(); + for r in refs { + let Some(uid) = r.beatmap_uid.as_deref() else { + continue; + }; + match r.reference_kind.as_str() { + "audio_filename" => { + audio.entry(uid).or_insert(r); + } + "background_image" => { + bg.entry(uid).or_insert(r); + } + "video" => { + video.entry(uid).or_insert(r); + } + _ => {} + } + if r.is_missing { + missing_by_uid.insert(uid, true); + } + } + for bm in beatmaps.iter_mut() { + if let Some(r) = audio.get(bm.beatmap_uid.as_str()) { + bm.audio_reference_id = Some(r.reference_id.clone()); + bm.audio_blob_sha256 = r.resolved_blob_sha256.clone(); + } + if let Some(r) = bg.get(bm.beatmap_uid.as_str()) { + bm.background_reference_id = Some(r.reference_id.clone()); + bm.background_blob_sha256 = r.resolved_blob_sha256.clone(); + } + if let Some(r) = video.get(bm.beatmap_uid.as_str()) { + bm.video_reference_id = Some(r.reference_id.clone()); + bm.video_blob_sha256 = r.resolved_blob_sha256.clone(); + } + bm.has_missing_references = missing_by_uid + .get(bm.beatmap_uid.as_str()) + .copied() + .unwrap_or(false); + } +} + +/// Fill in `file_reference_id` and `resolved_blob_sha256` on storyboard_element +/// rows by joining on (source_logical_file_id, raw_reference). The element +/// row carries `storyboard_source_id`, which we map to source_logical_file_id +/// via the storyboard_sources rows. +fn backfill_storyboard_elements_from_references( + elements: &mut [StoryboardElementRow], + sources: &[StoryboardSourceRow], + refs: &[AssetReferenceRow], +) { + use std::collections::HashMap; + let source_logical: HashMap<&str, &str> = sources + .iter() + .map(|s| { + ( + s.storyboard_source_id.as_str(), + s.source_logical_file_id.as_str(), + ) + }) + .collect(); + // (source_logical_file_id, raw_reference) → first matching ref. + let mut by_key: HashMap<(&str, &str), &AssetReferenceRow> = HashMap::new(); + for r in refs { + match r.reference_kind.as_str() { + "storyboard_sprite" | "storyboard_animation" | "storyboard_audio_sample" | "video" => { + by_key + .entry((r.source_logical_file_id.as_str(), r.raw_reference.as_str())) + .or_insert(r); + } + _ => {} + } + } + for elem in elements.iter_mut() { + let Some(raw) = elem.file_reference_raw.as_deref() else { + continue; + }; + let Some(source_lf) = source_logical + .get(elem.storyboard_source_id.as_str()) + .copied() + else { + continue; + }; + if let Some(r) = by_key.get(&(source_lf, raw)) { + elem.file_reference_id = Some(r.reference_id.clone()); + elem.resolved_blob_sha256 = r.resolved_blob_sha256.clone(); + } + } +} + +/// Set `is_referenced` / `is_unreferenced_extra` on every logical_file based +/// on whether any resolved reference points to it. +fn backfill_logical_files_from_references( + logical_files: &mut [LogicalFileRow], + refs: &[AssetReferenceRow], +) { + use std::collections::{HashMap, HashSet}; + let referenced: HashSet<&str> = refs + .iter() + .filter_map(|r| r.resolved_logical_file_id.as_deref()) + .collect(); + let mut roles_by_lfid: HashMap<&str, HashSet> = HashMap::new(); + for r in refs { + let Some(lfid) = r.resolved_logical_file_id.as_deref() else { + continue; + }; + let Some(role) = role_for_reference_kind(r.reference_kind.as_str()) else { + continue; + }; + roles_by_lfid + .entry(lfid) + .or_default() + .insert(role.to_string()); + } + for lf in logical_files.iter_mut() { + let is_ref = referenced.contains(lf.logical_file_id.as_str()); + lf.is_referenced = is_ref; + // Source files (.osu / .osb themselves) carry references but aren't + // referenced themselves — keep them flagged as unreferenced_extra + // unless something does point to them. + lf.is_unreferenced_extra = !is_ref; + + let mut roles: HashSet = lf + .roles + .iter() + .filter(|r| r.as_str() != "unknown") + .cloned() + .collect(); + if let Some(extra) = roles_by_lfid.get(lf.logical_file_id.as_str()) { + roles.extend(extra.iter().cloned()); + } + match lf.media_kind.as_str() { + "video" => { + roles.insert("video".to_string()); + } + "font" => { + roles.insert("font".to_string()); + } + _ => {} + } + if roles.is_empty() { + roles.insert("unknown".to_string()); + } + let mut roles_vec: Vec = roles.into_iter().collect(); + roles_vec.sort(); + lf.roles = roles_vec; + } +} + +fn role_for_reference_kind(kind: &str) -> Option<&'static str> { + match kind { + "audio_filename" => Some("song_audio"), + "background_image" => Some("background_image"), + "video" => Some("video"), + "storyboard_sprite" => Some("storyboard_sprite"), + "storyboard_animation" | "storyboard_animation_frame" => Some("storyboard_animation_frame"), + "storyboard_audio_sample" => Some("storyboard_audio_sample"), + "explicit_hitsound_sample" | "derived_custom_hitsound_sample" => Some("custom_hitsound"), + "custom_skin_asset_conventional" => Some("custom_skin_asset"), + "font" => Some("font"), + _ => None, + } +} + +/// One `difficulty_attributes` row per (beatmap, default-mod) pair. Skips +/// beatmaps where `parse_status="failed"` (rosu-map saw zero sections, so +/// the ruleset isn't trustworthy) or where `ruleset` isn't one of the four +/// standards. rosu-pp does its own parse from the raw bytes, so a partial +/// rosu-map result is still worth attempting. +fn build_difficulty_attribute_rows( + osu_parses: &[ParsedBeatmap], + beatmaps: &[BeatmapRow], +) -> Vec { + let mut out = Vec::new(); + for (parsed, bm) in osu_parses.iter().zip(beatmaps.iter()) { + if parsed.parse_status == osu_parse::ParseStatus::Failed { + continue; + } + let rows = difficulty::compute(&parsed.raw_bytes, bm.ruleset.as_str()); + for r in rows { + out.push(DifficultyAttributesRow { + beatmap_uid: bm.beatmap_uid.clone(), + set_revision_id: bm.set_revision_id.clone(), + ruleset: r.ruleset, + calculator: r.calculator, + calculator_version: r.calculator_version, + lazer_commit: None, + tools_commit: None, + mods_acronym: r.mods_acronym, + mods_bitmask: r.mods_bitmask, + clock_rate: r.clock_rate, + stars: r.stars, + max_combo: r.max_combo, + attributes_json: r.attributes_json, + calculation_status: r.status, + calculation_error: r.error, + }); + } + } + out +} + +fn compute_beatmap_uid(parsed: &ParsedBeatmap) -> String { + if let Some(f) = parsed.fields.as_ref() { + if f.beatmap_id > 0 { + return format!("osu:{}", f.beatmap_id); + } + } + format!("sha256:{}", parsed.osu_blob_sha256) +} + +fn display_path(norm: &paths::NormalizedPath) -> String { + norm.posix + .clone() + .unwrap_or_else(|| format!("[base64:{}]", norm.raw_bytes_base64)) +} + +fn sha256_hex(data: &[u8]) -> String { + let mut h = Sha256::new(); + h.update(data); + hex::encode(h.finalize()) +} + +fn unix_now_ms() -> i64 { + SystemTime::now() + .duration_since(UNIX_EPOCH) + .map(|d| d.as_millis() as i64) + .unwrap_or(0) +} + +/// Atomically write `data` to `dest` if `dest` does not already exist. Uses a +/// `.tmp.` sidecar + rename. Idempotent under repeated invocations +/// for the same content, and safe under concurrent writers writing identical +/// content (renames overwrite atomically). +fn atomic_write_if_absent(dest: &Path, data: &[u8]) -> io::Result<()> { + if dest.exists() { + return Ok(()); + } + if let Some(parent) = dest.parent() { + std::fs::create_dir_all(parent)?; + } + let tmp = sidecar_tmp(dest); + std::fs::write(&tmp, data)?; + if let Err(e) = std::fs::rename(&tmp, dest) { + let _ = std::fs::remove_file(&tmp); + return Err(e); + } + Ok(()) +} + +fn atomic_copy_if_absent(src: &Path, dest: &Path) -> io::Result<()> { + if dest.exists() { + return Ok(()); + } + if let Some(parent) = dest.parent() { + std::fs::create_dir_all(parent)?; + } + let tmp = sidecar_tmp(dest); + std::fs::copy(src, &tmp)?; + if let Err(e) = std::fs::rename(&tmp, dest) { + let _ = std::fs::remove_file(&tmp); + return Err(e); + } + Ok(()) +} + +fn sidecar_tmp(dest: &Path) -> PathBuf { + let pid = std::process::id(); + let mut name = dest.file_name().unwrap_or_default().to_os_string(); + name.push(format!(".tmp.{pid}")); + dest.with_file_name(name) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::io::Cursor; + use zip::write::SimpleFileOptions; + + /// Realistic-ish .osu fixture: minimal but parseable, with an explicit + /// BeatmapSetID so set_revision_id resolution exercises the header path. + /// Hit objects exercise all three osu! kinds (circle / slider / spinner) + /// so the per-ruleset row builder is fully covered. + const OSU_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\nPreviewTime: 1000\r\n\r\n\ +[Metadata]\r\nTitle:Title\r\nTitleUnicode:TitleU\r\nArtist:Artist\r\n\ +ArtistUnicode:ArtistU\r\nCreator:peppy\r\nVersion:Hard\r\nSource:\r\n\ +Tags:tag1 tag2\r\nBeatmapID:5\r\nBeatmapSetID:99\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:6\r\n\ +ApproachRate:7\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n0,0,\"bg.jpg\",0,0\r\n\r\n\ +[TimingPoints]\r\n0,500.0,4,2,1,60,1,1\r\n1000,-50,4,2,1,60,0,0\r\n\r\n\ +[HitObjects]\r\n256,192,3000,1,0,0:0:0:0:\r\n\ +100,100,3500,2,0,L|200:200,1,100,2|0,0:0|0:0,0:0:0:0:\r\n\ +256,192,4000,12,0,5000,0:0:0:0:\r\n"; + + /// Mania fixture: Mode=3, CircleSize=4 (=> key_count 4). Two notes and + /// one hold on different columns to validate column_index math. + const MANIA_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 3\r\n\r\n\ +[Metadata]\r\nTitle:M\r\nTitleUnicode:M\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:Easy\r\nSource:\r\nTags:\r\nBeatmapID:11\r\nBeatmapSetID:22\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500.0,4,2,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n64,192,1000,1,0,0:0:0:0:\r\n\ +192,192,1100,1,0,0:0:0:0:\r\n\ +448,192,1200,128,0,1500:0:0:0:0:\r\n"; + + /// Taiko fixture: Mode=1. Mix of don/kat/big-don/drumroll/denden. + const TAIKO_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 1\r\n\r\n\ +[Metadata]\r\nTitle:T\r\nTitleUnicode:T\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:Oni\r\nSource:\r\nTags:\r\nBeatmapID:33\r\nBeatmapSetID:44\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:5\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500.0,4,3,5,60,1,0\r\n\r\n\ +[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:\r\n\ +256,192,1500,1,2,0:0:0:0:\r\n\ +256,192,2000,1,4,0:0:0:0:\r\n\ +256,192,2500,2,0,L|300:192,1,100\r\n\ +256,192,3500,12,0,4500,0:0:0:0:\r\n"; + + fn fixture_zip() -> Vec { + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"FAKE-AUDIO").unwrap(); + w.start_file("Artist - Title (peppy) [Hard].osu", opts) + .unwrap(); + w.write_all(OSU_FIXTURE.as_bytes()).unwrap(); + w.start_file("background.jpg", opts).unwrap(); + w.write_all(b"\xFF\xD8\xFF\xE0FAKE-JPEG").unwrap(); + w.start_file("Thumbs.db", opts).unwrap(); + w.write_all(b"junk-windows-cache").unwrap(); + w.start_file("empty.txt", opts).unwrap(); + // (zero bytes) + w.start_file("BACKGROUND.jpg", opts).unwrap(); // case collision + w.write_all(b"\xFF\xD8\xFF\xE0FAKE-JPEG-2").unwrap(); + w.finish().unwrap(); + } + buf + } + + fn write_fixture(dir: &Path) -> PathBuf { + let osz = dir.join("test.osz"); + std::fs::write(&osz, fixture_zip()).unwrap(); + osz + } + + fn osu_fixture_with_tags(version: &str, beatmap_id: i32, tags: &str) -> String { + format!( + "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:TagTest\r\nTitleUnicode:TagTest\r\nArtist:A\r\n\ +ArtistUnicode:A\r\nCreator:c\r\nVersion:{version}\r\nSource:\r\n\ +Tags:{tags}\r\nBeatmapID:{beatmap_id}\r\nBeatmapSetID:123\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500.0,4,2,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n" + ) + } + + #[test] + fn ingest_basic_archive_produces_expected_rows() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_fixture(tmp.path()); + let archives_dir = tmp.path().join("archives"); + let blobs_dir = tmp.path().join("blobs"); + + let stats = ingest_archive( + &osz, + &archives_dir, + &blobs_dir, + "test-batch", + "0.0.0-test", + "v1", + false, + ) + .expect("ingest must succeed"); + + // Archive row. + let ar = &stats.archive_revision; + assert_eq!(ar.ingest_decision, "accepted"); + assert_eq!(ar.member_count, 6); + assert!(ar.archive_path.starts_with("archives/sha256/")); + + // set_revision row resolved from BeatmapSetID=99 in the fixture. + let sr = &stats.set_revision; + assert_eq!(sr.beatmapset_id, Some(99)); + assert_eq!(sr.beatmapset_id_source, "osu_header"); + assert!( + sr.set_revision_id.starts_with("99:"), + "got {}", + sr.set_revision_id + ); + assert_eq!(sr.num_beatmaps, 1); + assert_eq!(sr.num_files, 4); + assert_eq!(sr.num_blobs, 4); + assert_eq!(sr.mode_set, vec!["osu".to_string()]); + + // Logical files: still 4 expected (Thumbs.db + empty skipped). + assert_eq!(stats.logical_files.len(), 4); + // The placeholder set_revision_id should have been rewritten. + for r in &stats.logical_files { + assert_eq!(r.set_revision_id, sr.set_revision_id); + assert_eq!(r.beatmapset_id, Some(99)); + assert!( + r.logical_file_id + .starts_with(&format!("{}::", sr.set_revision_id)), + "got {}", + r.logical_file_id + ); + } + let logical_ids: std::collections::HashSet<&str> = stats + .logical_files + .iter() + .map(|r| r.logical_file_id.as_str()) + .collect(); + assert_eq!(logical_ids.len(), stats.logical_files.len()); + let background_rows: Vec<&LogicalFileRow> = stats + .logical_files + .iter() + .filter(|r| r.path_key == "background.jpg") + .collect(); + assert_eq!(background_rows.len(), 2); + assert!(background_rows + .iter() + .any(|r| r.logical_file_id.ends_with("::background.jpg"))); + let duplicate_background = background_rows + .iter() + .find(|r| r.logical_file_id.ends_with("::background.jpg::member0002")) + .expect("duplicate background row should keep a stable member suffix"); + let duplicate_warning = duplicate_background.path_warning.as_deref().unwrap_or(""); + assert!(duplicate_warning.contains("duplicate_path_key")); + assert!(duplicate_warning.contains("case_collision")); + // Problems' set_revision_id also rewritten. + for p in &stats.problems { + assert_eq!(p.set_revision_id, sr.set_revision_id); + } + + // beatmaps row. + assert_eq!(stats.beatmaps.len(), 1); + let bm = &stats.beatmaps[0]; + assert_eq!(bm.beatmap_uid, "osu:5"); + assert_eq!(bm.beatmap_id, Some(5)); + assert_eq!(bm.beatmapset_id, Some(99)); + assert_eq!(bm.mode, 0); + assert_eq!(bm.ruleset, "osu"); + assert_eq!(bm.title.as_deref(), Some("Title")); + assert_eq!(bm.creator.as_deref(), Some("peppy")); + assert_eq!(bm.version.as_deref(), Some("Hard")); + assert_eq!(bm.audio_filename_raw.as_deref(), Some("song.mp3")); + assert_eq!(bm.format_version, Some(14)); + assert_eq!(bm.parse_status, "ok"); + // 3 hit objects: circle, slider, spinner (all in osu! mode). + assert_eq!(bm.hit_object_count, 3); + // 2 lines in [TimingPoints] (1 uninherited + 1 inherited). + assert_eq!(bm.timing_point_count, 2); + assert_eq!(bm.tags, Some(vec!["tag1".to_string(), "tag2".to_string()])); + assert_eq!(bm.parser_name, "rosu-map"); + assert_eq!(bm.has_osb, false); + + // osu_sections covers at least: _header, [General], [Metadata], [Difficulty], [Events], [TimingPoints], [HitObjects]. + assert!(stats.osu_sections.len() >= 7); + let names: Vec<&str> = stats + .osu_sections + .iter() + .map(|s| s.section_name.as_str()) + .collect(); + assert!(names.contains(&"[General]")); + assert!(names.contains(&"[TimingPoints]")); + + // timing_points: 2 lines parsed, with bpm/svm derived correctly. + assert_eq!(stats.timing_points.len(), 2); + let red = &stats.timing_points[0]; + assert_eq!(red.row_index, 0); + assert!(red.uninherited); + assert_eq!(red.bpm, Some(120.0)); // 60000 / 500 + assert_eq!(red.slider_velocity_multiplier, None); + assert!(red.is_kiai); // effects=1 in the fixture line 1 + let green = &stats.timing_points[1]; + assert!(!green.uninherited); + assert_eq!(green.bpm, None); + assert_eq!(green.slider_velocity_multiplier, Some(2.0)); // -100 / -50 + + // Hit objects: 3 common rows (circle/slider/spinner). + assert_eq!(stats.hit_objects_common.len(), 3); + let kinds: Vec<&str> = stats + .hit_objects_common + .iter() + .map(|r| r.common_object_kind.as_str()) + .collect(); + assert_eq!(kinds, vec!["circle", "slider", "spinner"]); + for r in &stats.hit_objects_common { + assert_eq!(r.beatmap_uid, "osu:5"); + assert_eq!(r.set_revision_id, sr.set_revision_id); + assert_eq!(r.ruleset, "osu"); + // Sentinel 0 for non-mania rulesets (mania always >= 1 by clamp). + assert_eq!(r.key_count, 0); + } + + // osu_kind routes only to hit_objects_osu (mode 0). + assert_eq!(stats.hit_objects_osu.len(), 3); + assert!(stats.hit_objects_taiko.is_empty()); + assert!(stats.hit_objects_catch.is_empty()); + assert!(stats.hit_objects_mania.is_empty()); + + // Slider row: control points decoded, raw edge sounds preserved. + let slider = &stats.hit_objects_osu[1]; + assert_eq!(slider.osu_kind, "slider"); + assert_eq!(slider.slider_curve_type.as_deref(), Some("L")); + assert_eq!(slider.slider_repeats, Some(1)); + assert_eq!(slider.slider_pixel_length, Some(100.0)); + assert_eq!( + slider.slider_control_points_json.as_deref(), + Some("[[200,200]]") + ); + assert_eq!(slider.edge_sounds_raw.as_deref(), Some("2|0")); + assert_eq!(slider.edge_sets_raw.as_deref(), Some("0:0|0:0")); + // Circles have no end_time; spinners do. + assert_eq!(stats.hit_objects_osu[0].end_time_ms, None); + assert_eq!(stats.hit_objects_osu[2].osu_kind, "spinner"); + assert_eq!(stats.hit_objects_osu[2].end_time_ms, Some(5000)); + + // Phase 12: asset_references table. + // Audio: AudioFilename = "song.mp3" → resolved to song.mp3 in archive. + let audio_refs: Vec<&AssetReferenceRow> = stats + .asset_references + .iter() + .filter(|r| r.reference_kind == "audio_filename") + .collect(); + assert_eq!(audio_refs.len(), 1); + assert_eq!(audio_refs[0].raw_reference, "song.mp3"); + assert_eq!(audio_refs[0].resolution_status, "found_exact"); + assert!(!audio_refs[0].is_missing); + assert!(audio_refs[0].resolved_blob_sha256.is_some()); + // Backfilled onto the beatmap row. + assert_eq!(bm.audio_blob_sha256, audio_refs[0].resolved_blob_sha256); + assert_eq!( + bm.audio_reference_id.as_deref(), + Some(audio_refs[0].reference_id.as_str()) + ); + + // Background: [Events] says "bg.jpg" but the archive ships + // "background.jpg" (different filename) → missing. + let bg_refs: Vec<&AssetReferenceRow> = stats + .asset_references + .iter() + .filter(|r| r.reference_kind == "background_image") + .collect(); + assert_eq!(bg_refs.len(), 1); + assert_eq!(bg_refs[0].raw_reference, "bg.jpg"); + assert_eq!(bg_refs[0].resolution_status, "missing"); + assert!(bg_refs[0].is_missing); + assert!(bg_refs[0].resolved_blob_sha256.is_none()); + // Beatmap reflects the missing reference. + assert!(bm.has_missing_references); + assert!(bm.background_blob_sha256.is_none()); + + // Derived hitsounds: at least normal-hitnormal.wav generated. + // None are in this archive, so all should be external_or_default. + let derived: Vec<&AssetReferenceRow> = stats + .asset_references + .iter() + .filter(|r| r.reference_kind == "derived_custom_hitsound_sample") + .collect(); + assert!(!derived.is_empty()); + for r in &derived { + assert_eq!(r.resolution_status, "external_or_default_resource"); + // external_or_default is NOT a missing failure. + assert!(!r.is_missing); + } + + // logical_files: song.mp3 should be referenced; the .osu and the + // unreferenced bg files should not be. + let song = stats + .logical_files + .iter() + .find(|f| f.path_key == "song.mp3") + .expect("song.mp3 row"); + assert!(song.is_referenced); + assert!(!song.is_unreferenced_extra); + let osu_file = stats + .logical_files + .iter() + .find(|f| f.extension.as_deref() == Some("osu")) + .expect("osu row"); + // .osu is the source of references but isn't itself referenced. + assert!(!osu_file.is_referenced); + assert!(osu_file.is_unreferenced_extra); + + // num_missing_references aggregates across the archive. + assert!(sr.num_missing_references >= 1); + + // reference_id format: ::ref::::. + for r in &stats.asset_references { + let prefix = format!( + "{}::ref::{}::", + sr.set_revision_id, r.source_logical_file_id + ); + assert!( + r.reference_id.starts_with(&prefix), + "reference_id {} should start with {}", + r.reference_id, + prefix + ); + } + } + + #[test] + fn set_revision_tags_union_across_difficulties() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("tag-union.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("easy.osu", opts).unwrap(); + w.write_all(osu_fixture_with_tags("Easy", 1, "alpha beta").as_bytes()) + .unwrap(); + w.start_file("hard.osu", opts).unwrap(); + w.write_all(osu_fixture_with_tags("Hard", 2, "beta gamma").as_bytes()) + .unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "test-batch", + "0.0.0-test", + "v1", + true, + ) + .expect("ingest must succeed"); + + assert_eq!(stats.beatmaps.len(), 2); + assert_eq!( + stats.set_revision.tags, + Some(vec![ + "alpha".to_string(), + "beta".to_string(), + "gamma".to_string() + ]) + ); + } + + #[test] + fn ingest_mania_archive_routes_rows_with_correct_columns() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("mania.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(MANIA_FIXTURE.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "test-batch", + "0.0.0", + "v1", + false, + ) + .unwrap(); + + assert_eq!(stats.beatmaps.len(), 1); + assert_eq!(stats.beatmaps[0].mode, 3); + assert_eq!(stats.beatmaps[0].ruleset, "mania"); + + // Common: 3 rows. Mania: 3 rows. Other rulesets: empty. + assert_eq!(stats.hit_objects_common.len(), 3); + assert_eq!(stats.hit_objects_mania.len(), 3); + assert!(stats.hit_objects_osu.is_empty()); + assert!(stats.hit_objects_taiko.is_empty()); + assert!(stats.hit_objects_catch.is_empty()); + + // CircleSize=4 → key_count=4. Column math: x=64 → col 0, x=192 → col 1, + // x=448 → col 3 (clamped within 0..key_count). + let m = &stats.hit_objects_mania; + assert!(m.iter().all(|r| r.key_count == 4)); + assert_eq!(m[0].x, 64); + assert_eq!(m[0].column_index, 0); + assert_eq!(m[0].mania_kind, "note"); + assert_eq!(m[0].end_time_ms, None); + assert_eq!(m[1].column_index, 1); + // Hold note: end_time decoded from "endTime:hitsample" tail param. + assert_eq!(m[2].mania_kind, "hold"); + assert_eq!(m[2].column_index, 3); + assert_eq!(m[2].end_time_ms, Some(1500)); + + // Mania routes the per-mode key_count onto hit_objects_common too so a + // mode-mixed model loading `hit_objects_common` can partition-prune by + // (ruleset='mania', key_count=4). The common rows mirror the mania ones. + assert!(stats + .hit_objects_common + .iter() + .all(|r| r.ruleset == "mania" && r.key_count == 4)); + } + + #[test] + fn ingest_taiko_archive_classifies_kinds() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("taiko.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("t.osu", opts).unwrap(); + w.write_all(TAIKO_FIXTURE.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "test-batch", + "0.0.0", + "v1", + false, + ) + .unwrap(); + + assert_eq!(stats.beatmaps[0].mode, 1); + assert_eq!(stats.beatmaps[0].ruleset, "taiko"); + assert_eq!(stats.hit_objects_taiko.len(), 5); + assert!(stats.hit_objects_osu.is_empty()); + + let kinds: Vec<&str> = stats + .hit_objects_taiko + .iter() + .map(|r| r.taiko_kind.as_str()) + .collect(); + assert_eq!(kinds, vec!["don", "kat", "don", "drumroll", "denden"]); + // FINISH (4) → big don. + assert!(stats.hit_objects_taiko[2].is_big); + assert!(!stats.hit_objects_taiko[0].is_big); + // Active timing point at t=1000: only row, sample_set=3, sample_index=5. + assert_eq!(stats.hit_objects_taiko[0].inherited_sample_set, Some(3)); + assert_eq!(stats.hit_objects_taiko[0].sample_index, Some(5)); + } + + #[test] + fn ingest_corrupt_archive_is_quarantined_with_archive_row_present() { + let tmp = tempfile::tempdir().unwrap(); + let bad = tmp.path().join("not-a-zip.osz"); + std::fs::write(&bad, b"this is not a zip").unwrap(); + let archives_dir = tmp.path().join("archives"); + let blobs_dir = tmp.path().join("blobs"); + + let stats = ingest_archive( + &bad, + &archives_dir, + &blobs_dir, + "test-batch", + "0.0.0-test", + "v1", + false, + ) + .expect("hash + copy succeed; quarantine is not a hard error"); + + assert_eq!(stats.archive_revision.ingest_decision, "quarantined"); + assert_eq!(stats.archive_revision.member_count, 0); + assert!(stats.logical_files.is_empty()); + assert!(stats.beatmaps.is_empty()); + assert!(stats + .problems + .iter() + .any(|p| p.severity == "fatal" && p.category == "zip")); + + let mut out = Vec::new(); + emit_stats(&mut out, &stats).unwrap(); + let tables: Vec = String::from_utf8(out) + .unwrap() + .lines() + .map(|line| { + serde_json::from_str::(line).unwrap()["_table"] + .as_str() + .unwrap() + .to_string() + }) + .collect(); + assert_eq!(tables, vec!["archive_revisions", "problems"]); + } + + #[test] + fn blob_storage_failure_aborts_instead_of_quarantining() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_fixture(tmp.path()); + let archives_dir = tmp.path().join("archives"); + let blobs_dir = tmp.path().join("blobs"); + std::fs::write(&blobs_dir, b"not a directory").unwrap(); + + let err = ingest_archive( + &osz, + &archives_dir, + &blobs_dir, + "test-batch", + "0.0.0-test", + "v1", + false, + ) + .expect_err("storage failures must abort the chunk, not quarantine the archive"); + + let msg = format!("{err:#}"); + assert!(msg.contains("walking archive members"), "{msg}"); + assert!(msg.contains("member callback failed"), "{msg}"); + assert!(msg.contains("writing blob"), "{msg}"); + } + + #[test] + fn deterministic_archive_hash() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_fixture(tmp.path()); + let h1 = archive::hash_file(&osz).unwrap().0; + let h2 = archive::hash_file(&osz).unwrap().0; + assert_eq!(h1, h2); + assert_eq!(h1.len(), 64); + } + + #[test] + fn re_ingest_is_idempotent() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_fixture(tmp.path()); + let archives_dir = tmp.path().join("archives"); + let blobs_dir = tmp.path().join("blobs"); + let s1 = ingest_archive(&osz, &archives_dir, &blobs_dir, "b", "v", "v1", false).unwrap(); + let s2 = ingest_archive(&osz, &archives_dir, &blobs_dir, "b", "v", "v1", false).unwrap(); + assert_eq!(s1.beatmaps.len(), s2.beatmaps.len()); + assert_eq!( + s1.set_revision.set_revision_id, + s2.set_revision.set_revision_id + ); + assert_eq!(s1.logical_files.len(), s2.logical_files.len()); + } + + #[test] + fn duplicate_osu_members_keep_distinct_logical_file_fks() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("duplicate-osu.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("A.osu", opts).unwrap(); + w.write_all(osu_fixture_with_tags("Upper", 100, "one").as_bytes()) + .unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(osu_fixture_with_tags("Lower", 101, "two").as_bytes()) + .unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "test-batch", + "0.0.0-test", + "v1", + true, + ) + .expect("ingest must succeed"); + + let logical_ids: HashSet<&str> = stats + .logical_files + .iter() + .map(|r| r.logical_file_id.as_str()) + .collect(); + assert_eq!(logical_ids.len(), stats.logical_files.len()); + + let upper = stats + .beatmaps + .iter() + .find(|b| b.beatmap_id == Some(100)) + .expect("upper beatmap"); + let lower = stats + .beatmaps + .iter() + .find(|b| b.beatmap_id == Some(101)) + .expect("lower beatmap"); + assert!(logical_ids.contains(upper.osu_logical_file_id.as_str())); + assert!(logical_ids.contains(lower.osu_logical_file_id.as_str())); + assert_ne!(upper.osu_logical_file_id, lower.osu_logical_file_id); + assert!(lower.osu_logical_file_id.ends_with("::a.osu::member0002")); + + let source_ids: HashSet<&str> = stats + .asset_references + .iter() + .map(|r| r.source_logical_file_id.as_str()) + .collect(); + assert!(source_ids.contains(upper.osu_logical_file_id.as_str())); + assert!(source_ids.contains(lower.osu_logical_file_id.as_str())); + } + + #[test] + fn emit_stats_writes_one_line_per_row_with_table_tags() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_fixture(tmp.path()); + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + let mut buf = Vec::::new(); + emit_stats(&mut buf, &stats).unwrap(); + let text = String::from_utf8(buf).unwrap(); + + let lines: Vec<&str> = text.lines().collect(); + let expected = 1 + + 1 + + stats.logical_files.len() + + stats.beatmaps.len() + + stats.osu_sections.len() + + stats.timing_points.len() + + stats.hit_objects_common.len() + + stats.hit_objects_osu.len() + + stats.hit_objects_taiko.len() + + stats.hit_objects_catch.len() + + stats.hit_objects_mania.len() + + stats.storyboard_sources.len() + + stats.storyboard_elements.len() + + stats.storyboard_commands.len() + + stats.storyboard_variables.len() + + stats.asset_references.len() + + stats.difficulty_attributes.len() + + stats.problems.len(); + assert_eq!(lines.len(), expected); + + let first: serde_json::Value = serde_json::from_str(lines[0]).unwrap(); + assert_eq!(first["_table"], "archive_revisions"); + let second: serde_json::Value = serde_json::from_str(lines[1]).unwrap(); + assert_eq!(second["_table"], "set_revisions"); + + let mut seen_tables = std::collections::HashSet::new(); + for line in &lines { + let v: serde_json::Value = serde_json::from_str(line).unwrap(); + seen_tables.insert(v["_table"].as_str().unwrap().to_string()); + } + for t in [ + "archive_revisions", + "set_revisions", + "logical_files", + "beatmaps", + "osu_sections", + "timing_points", + "hit_objects_common", + "hit_objects_osu", + ] { + assert!(seen_tables.contains(t), "missing table {t} in NDJSON"); + } + } + + /// `.osu` fixture whose `[Events]` carries a difficulty-local storyboard + /// (one Sprite + one Fade command). Same general shape as `OSU_FIXTURE` + /// but with a storyboard chunk in `[Events]`. Note: leading whitespace on + /// the `_F,...` command line uses an underscore rather than a space so + /// Rust's string-literal continuation doesn't eat it. + const OSU_WITH_LOCAL_SB: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:LocalSB\r\nTitleUnicode:LocalSB\r\nArtist:A\r\n\ +ArtistUnicode:A\r\nCreator:c\r\nVersion:Sb\r\nSource:\r\nTags:\r\n\ +BeatmapID:777\r\nBeatmapSetID:888\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n0,0,\"bg.jpg\",0,0\r\n\ +Sprite,Foreground,Centre,\"sb/star.png\",320,240\r\n\ +_F,0,0,1000,0,1\r\n\ +[TimingPoints]\r\n0,500.0,4,2,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:\r\n"; + + /// Minimal `.osb` fixture: 1 variable + 1 sprite + 1 fade command. + const OSB_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[Variables]\r\n$col=255,128,0\r\n\r\n\ +[Events]\r\nSprite,Foreground,Centre,\"sb/anim.png\",100,200\r\n\ +_F,0,0,1000,0,1\r\n\ +_C,0,0,1000,$col,$col\r\n"; + + #[test] + fn ingest_archive_with_difficulty_local_storyboard() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("local_sb.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(OSU_WITH_LOCAL_SB.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + // No .osb in the archive. + assert_eq!(stats.beatmaps.len(), 1); + let bm = &stats.beatmaps[0]; + assert_eq!(bm.has_osb, false); + assert_eq!(bm.has_local_storyboard, true); + assert_eq!(bm.has_effective_storyboard, true); + + // Exactly one storyboard source (difficulty_local), keyed off beatmap_uid. + assert_eq!(stats.storyboard_sources.len(), 1); + let src = &stats.storyboard_sources[0]; + assert_eq!(src.scope, "difficulty_local"); + assert_eq!(src.beatmap_uid.as_deref(), Some("osu:777")); + assert!( + src.storyboard_source_id + .contains("::sb::difficulty_local::osu:777"), + "got {}", + src.storyboard_source_id + ); + assert_eq!(src.parser_name, "rosu-storyboard"); + assert_eq!(src.parse_status, "ok"); + // `.osu` files have no [Variables] section. + assert!(stats.storyboard_variables.is_empty()); + + // One sprite + one F command on it. + assert_eq!(stats.storyboard_elements.len(), 1); + let elem = &stats.storyboard_elements[0]; + assert_eq!(elem.element_kind, "sprite"); + assert_eq!(elem.layer, "Foreground"); + assert_eq!(elem.origin.as_deref(), Some("Centre")); + assert_eq!(elem.file_reference_raw.as_deref(), Some("sb/star.png")); + assert_eq!(elem.beatmap_uid.as_deref(), Some("osu:777")); + + assert_eq!(stats.storyboard_commands.len(), 1); + let cmd = &stats.storyboard_commands[0]; + assert_eq!(cmd.command_code, "F"); + assert_eq!(cmd.start_time_ms, Some(0)); + assert_eq!(cmd.end_time_ms, Some(1000)); + assert_eq!(cmd.parent_command_id, None); + assert_eq!(cmd.params_json, "{\"values\":[0,1]}"); + assert!(cmd.storyboard_command_id.ends_with("::cmd::0")); + } + + #[test] + fn ingest_archive_with_shared_set_storyboard_osb() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("osb.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + // OSU_FIXTURE has BeatmapSetID=99 and no storyboard markers in + // [Events] — exactly what we want here so has_local_storyboard=false. + w.write_all(OSU_FIXTURE.as_bytes()).unwrap(); + w.start_file("storyboard.osb", opts).unwrap(); + w.write_all(OSB_FIXTURE.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + let bm = &stats.beatmaps[0]; + assert_eq!(bm.has_osb, true); + assert_eq!(bm.has_local_storyboard, false); + assert_eq!(bm.has_effective_storyboard, true); + + // Exactly one storyboard source (shared_set). + assert_eq!(stats.storyboard_sources.len(), 1); + let src = &stats.storyboard_sources[0]; + assert_eq!(src.scope, "shared_set"); + assert_eq!(src.beatmap_uid, None); + assert!( + src.storyboard_source_id.contains("::sb::shared_set::"), + "got {}", + src.storyboard_source_id + ); + assert!( + src.source_logical_file_id.ends_with("::storyboard.osb"), + "got {}", + src.source_logical_file_id + ); + + // [Variables] preserved as one row. + assert_eq!(stats.storyboard_variables.len(), 1); + assert_eq!(stats.storyboard_variables[0].variable_name, "$col"); + assert_eq!(stats.storyboard_variables[0].raw_value, "255,128,0"); + + // One sprite + two commands (F, C). C's params_json reflects the + // post-substitution value of $col → (255, 128, 0). + assert_eq!(stats.storyboard_elements.len(), 1); + assert_eq!(stats.storyboard_commands.len(), 2); + let f = &stats.storyboard_commands[0]; + assert_eq!(f.command_code, "F"); + let c = &stats.storyboard_commands[1]; + assert_eq!(c.command_code, "C"); + assert_eq!(c.params_json, "{\"colors\":[[255,128,0],[255,128,0]]}"); + // The raw_line preserves the $col tokens — only params_json is post-sub. + assert!(c.raw_line.contains("$col")); + } + + #[test] + fn ingest_archive_with_both_scopes() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("both.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(OSU_WITH_LOCAL_SB.as_bytes()).unwrap(); + w.start_file("storyboard.osb", opts).unwrap(); + w.write_all(OSB_FIXTURE.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + // Both scopes present: 2 sources. + assert_eq!(stats.storyboard_sources.len(), 2); + let mut scopes: Vec<&str> = stats + .storyboard_sources + .iter() + .map(|s| s.scope.as_str()) + .collect(); + scopes.sort(); + assert_eq!(scopes, vec!["difficulty_local", "shared_set"]); + + // Variables only come from the .osb. + assert_eq!(stats.storyboard_variables.len(), 1); + + // 2 elements (1 from each source). 3 commands (1 from .osu, 2 from .osb). + assert_eq!(stats.storyboard_elements.len(), 2); + assert_eq!(stats.storyboard_commands.len(), 3); + + // has_effective_storyboard reflects either source. + let bm = &stats.beatmaps[0]; + assert!(bm.has_osb); + assert!(bm.has_local_storyboard); + assert!(bm.has_effective_storyboard); + } + + #[test] + fn fingerprint_fallback_when_beatmapset_id_is_negative() { + // Build a .osu with BeatmapSetID:-1 → falls back to fingerprint. + let osu_text = "osu file format v14\r\n[General]\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nBeatmapID:-1\r\nBeatmapSetID:-1\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n[HitObjects]\r\n"; + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("a.osu", opts).unwrap(); + w.write_all(osu_text.as_bytes()).unwrap(); + w.finish().unwrap(); + } + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("nope.osz"); + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + assert!(stats + .set_revision + .set_revision_id + .starts_with("fingerprint:")); + assert_eq!(stats.set_revision.beatmapset_id_source, "fingerprint"); + assert_eq!(stats.set_revision.beatmapset_id, None); + + // beatmap_uid falls back to sha256 since beatmap_id is -1. + assert_eq!(stats.beatmaps.len(), 1); + assert!( + stats.beatmaps[0].beatmap_uid.starts_with("sha256:"), + "got {}", + stats.beatmaps[0].beatmap_uid + ); + } + + #[test] + fn filename_fallback_when_header_id_is_negative() { + // Official local archives are named by beatmapset id. For old maps + // whose .osu still says BeatmapSetID:-1, use a plain numeric filename + // before falling back to the anonymous fingerprint key. + let osu_text = "osu file format v14\r\n[General]\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nBeatmapID:-1\r\nBeatmapSetID:-1\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n[HitObjects]\r\n"; + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("a.osu", opts).unwrap(); + w.write_all(osu_text.as_bytes()).unwrap(); + w.finish().unwrap(); + } + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("12345.osz"); + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + assert!(stats.set_revision.set_revision_id.starts_with("12345:")); + assert_eq!(stats.set_revision.beatmapset_id_source, "filename"); + assert_eq!(stats.set_revision.beatmapset_id, Some(12345)); + } + + /// `.osu` referencing a sprite, audio, and a custom hitsound that all + /// exist in the archive — every reference should resolve and the + /// resolved blob shas should be backfilled. + const OSU_FOR_REFS_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\nSampleSet: Normal\r\n\r\n\ +[Metadata]\r\nTitle:R\r\nTitleUnicode:R\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:Refs\r\nSource:\r\nTags:\r\nBeatmapID:1234\r\nBeatmapSetID:5678\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n0,0,\"bg.png\",0,0\r\n\ +Sprite,Foreground,Centre,\"sb/star.png\",320,240\r\n\ +_F,0,0,1000,0,1\r\n\ +[TimingPoints]\r\n0,500.0,4,1,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:custom-clap.wav\r\n\ +256,192,1500,1,8,0:0:0:0:\r\n"; + + #[test] + fn ingest_resolves_sprite_audio_and_explicit_hitsound() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("refs.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"FAKE-AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(OSU_FOR_REFS_FIXTURE.as_bytes()).unwrap(); + w.start_file("bg.png", opts).unwrap(); + w.write_all(b"\x89PNG\r\nFAKE").unwrap(); + w.start_file("sb/star.png", opts).unwrap(); + w.write_all(b"\x89PNG\r\nFAKE-STAR").unwrap(); + w.start_file("custom-clap.wav", opts).unwrap(); + w.write_all(b"FAKE-WAV").unwrap(); + w.start_file("normal-hitnormal.wav", opts).unwrap(); + w.write_all(b"FAKE-NORMAL").unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + let bm = &stats.beatmaps[0]; + + // Audio resolves. + let audio = stats + .asset_references + .iter() + .find(|r| r.reference_kind == "audio_filename") + .expect("audio ref"); + assert_eq!(audio.resolution_status, "found_exact"); + assert_eq!(bm.audio_blob_sha256, audio.resolved_blob_sha256); + + // Background "bg.png" resolves to bg.png. + let bg = stats + .asset_references + .iter() + .find(|r| r.reference_kind == "background_image") + .expect("bg ref"); + assert_eq!(bg.resolution_status, "found_exact"); + assert_eq!(bm.background_blob_sha256, bg.resolved_blob_sha256); + + // Storyboard sprite resolves and is backfilled onto the element row. + let sprite_ref = stats + .asset_references + .iter() + .find(|r| r.reference_kind == "storyboard_sprite") + .expect("sprite ref"); + assert_eq!(sprite_ref.resolution_status, "found_exact"); + assert_eq!(sprite_ref.raw_reference, "sb/star.png"); + + let sprite_elem = stats + .storyboard_elements + .iter() + .find(|e| e.element_kind == "sprite") + .expect("sprite element"); + assert_eq!( + sprite_elem.file_reference_id.as_deref(), + Some(sprite_ref.reference_id.as_str()) + ); + assert_eq!( + sprite_elem.resolved_blob_sha256, + sprite_ref.resolved_blob_sha256 + ); + + // Explicit custom hitsound filename resolves. + let explicit = stats + .asset_references + .iter() + .find(|r| r.reference_kind == "explicit_hitsound_sample") + .expect("explicit hitsound ref"); + assert_eq!(explicit.raw_reference, "custom-clap.wav"); + assert_eq!(explicit.resolution_status, "found_exact"); + + // Derived hitsound `normal-hitnormal.wav` is in the archive → + // found_by_convention. + let derived_normal = stats + .asset_references + .iter() + .find(|r| { + r.reference_kind == "derived_custom_hitsound_sample" + && r.raw_reference == "normal-hitnormal.wav" + }) + .expect("derived normal-hitnormal ref"); + assert_eq!(derived_normal.resolution_status, "found_by_convention"); + + // Derived `normal-hitclap.wav` is NOT in the archive → + // external_or_default_resource (clap bit set on the second hit + // object). + let derived_clap = stats + .asset_references + .iter() + .find(|r| { + r.reference_kind == "derived_custom_hitsound_sample" + && r.raw_reference == "normal-hitclap.wav" + }) + .expect("derived normal-hitclap ref"); + assert_eq!( + derived_clap.resolution_status, + "external_or_default_resource" + ); + + // No missing refs in this archive — every explicit + non-convention + // reference resolved. + assert!(!bm.has_missing_references); + let any_missing = stats.asset_references.iter().any(|r| r.is_missing); + assert!(!any_missing); + assert_eq!(stats.set_revision.num_missing_references, 0); + + // is_referenced flags propagate. + let song = stats + .logical_files + .iter() + .find(|f| f.path_key == "song.mp3") + .unwrap(); + let star = stats + .logical_files + .iter() + .find(|f| f.path_key == "sb/star.png") + .unwrap(); + let custom = stats + .logical_files + .iter() + .find(|f| f.path_key == "custom-clap.wav") + .unwrap(); + assert!(song.is_referenced); + assert!(star.is_referenced); + assert!(custom.is_referenced); + } + + /// Slash-normalization tier: archive uses forward slashes, the .osu + /// references with backslashes. + #[test] + fn ingest_resolves_storyboard_ref_via_slash_normalization() { + let osu_text = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:S\r\nTitleUnicode:S\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:S\r\nSource:\r\nTags:\r\nBeatmapID:1\r\nBeatmapSetID:1\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\nSprite,Foreground,Centre,\"sb\\Typography\\0030.png\",320,240\r\n\ +[TimingPoints]\r\n[HitObjects]\r\n"; + + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("slash.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(osu_text.as_bytes()).unwrap(); + // Forward-slash variant in the archive. + w.start_file("sb/Typography/0030.png", opts).unwrap(); + w.write_all(b"\x89PNGFAKE").unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + let sprite = stats + .asset_references + .iter() + .find(|r| r.reference_kind == "storyboard_sprite") + .expect("sprite ref"); + // The reference uses backslashes; the file uses forward slashes. + // Either slash-normalized or casefolded tier matches (both produce + // the same key in this case since path_key is already + // slash+casefold-normalized). + assert!(matches!( + sprite.resolution_status.as_str(), + "found_slash_normalized" | "found_casefolded" + )); + assert!(sprite.resolved_blob_sha256.is_some()); + assert_eq!(sprite.normalized_reference, "sb/Typography/0030.png"); + } + + #[test] + fn ingest_records_missing_video_reference() { + // .osu declares a video that doesn't exist in the archive. + let osu_text = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:V\r\nTitleUnicode:V\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:V\r\nSource:\r\nTags:\r\nBeatmapID:7\r\nBeatmapSetID:8\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:5\r\n\ +ApproachRate:5\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\nVideo,0,\"intro.mp4\"\r\n[TimingPoints]\r\n[HitObjects]\r\n"; + + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("missing_video.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(osu_text.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + let video = stats + .asset_references + .iter() + .find(|r| r.reference_kind == "video") + .expect("video ref"); + assert_eq!(video.raw_reference, "intro.mp4"); + assert_eq!(video.resolution_status, "missing"); + assert!(video.is_missing); + + let bm = &stats.beatmaps[0]; + assert!(bm.has_missing_references); + assert!(bm.video_blob_sha256.is_none()); + assert!(stats.set_revision.num_missing_references >= 1); + } + + /// End-to-end: every default mod for an osu! map shows up in + /// `difficulty_attributes`, identity columns are stamped from the + /// upstream beatmap row, and skip_difficulty=true zeroes the table. + const OSU_RICH_FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: song.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:T\r\nTitleUnicode:T\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:Hard\r\nSource:\r\nTags:\r\nBeatmapID:42\r\nBeatmapSetID:1234\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:7\r\n\ +ApproachRate:9\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500.0,4,1,1,60,1,0\r\n\r\n\ +[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:\r\n\ +128,192,1500,1,0,0:0:0:0:\r\n\ +384,192,2000,1,0,0:0:0:0:\r\n\ +256,128,2500,1,0,0:0:0:0:\r\n\ +256,256,3000,1,0,0:0:0:0:\r\n"; + + fn write_diff_fixture_archive(dir: &Path) -> PathBuf { + let osz = dir.join("diff.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(OSU_RICH_FIXTURE.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + osz + } + + #[test] + fn ingest_emits_difficulty_attributes_for_each_default_mod() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_diff_fixture_archive(tmp.path()); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + assert_eq!(stats.beatmaps.len(), 1); + let bm = &stats.beatmaps[0]; + + // 9 default osu mods → 9 difficulty rows. + assert_eq!(stats.difficulty_attributes.len(), 9); + let acronyms: Vec<&str> = stats + .difficulty_attributes + .iter() + .map(|r| r.mods_acronym.as_str()) + .collect(); + assert_eq!( + acronyms, + vec!["NM", "HD", "HR", "DT", "HT", "EZ", "FL", "HDHR", "HDDT"] + ); + + // Identity columns stamped from the upstream beatmap row. + for r in &stats.difficulty_attributes { + assert_eq!(r.beatmap_uid, bm.beatmap_uid); + assert_eq!(r.set_revision_id, bm.set_revision_id); + assert_eq!(r.ruleset, "osu"); + assert_eq!(r.calculator, "rosu-pp"); + assert_eq!(r.calculation_status, "ok"); + assert!(r.calculation_error.is_none()); + // calculator_version came from build.rs via Cargo.lock — must be + // a real semver, not "unknown". + assert!(r + .calculator_version + .chars() + .next() + .unwrap() + .is_ascii_digit()); + assert!(r.lazer_commit.is_none()); // reserved + assert!(r.tools_commit.is_none()); // reserved + } + + // attributes_json rule: ruleset key matches; stars in the JSON equals + // stars on the row. + let nm = stats + .difficulty_attributes + .iter() + .find(|r| r.mods_acronym == "NM") + .unwrap(); + let v: serde_json::Value = serde_json::from_str(&nm.attributes_json).unwrap(); + assert_eq!(v["ruleset"], "osu"); + assert_eq!(v["stars"].as_f64().unwrap(), nm.stars); + } + + #[test] + fn skip_difficulty_zeroes_the_difficulty_table() { + let tmp = tempfile::tempdir().unwrap(); + let osz = write_diff_fixture_archive(tmp.path()); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + true, // skip_difficulty + ) + .unwrap(); + + assert_eq!(stats.beatmaps.len(), 1); + assert!(stats.difficulty_attributes.is_empty()); + // Other tables unaffected. + assert!(!stats.hit_objects_common.is_empty()); + assert!(!stats.asset_references.is_empty()); + } + + #[test] + fn mania_archive_emits_mania_difficulty_rows_only() { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("mania.osz"); + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"AUDIO").unwrap(); + w.start_file("m.osu", opts).unwrap(); + w.write_all(MANIA_FIXTURE.as_bytes()).unwrap(); + w.finish().unwrap(); + } + std::fs::write(&osz, &buf).unwrap(); + + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "b", + "v", + "v1", + false, + ) + .unwrap(); + + // Mania default mod set is {NM, HR, DT, HT, EZ}. + assert_eq!(stats.difficulty_attributes.len(), 5); + let mods: Vec<&str> = stats + .difficulty_attributes + .iter() + .map(|r| r.mods_acronym.as_str()) + .collect(); + assert_eq!(mods, vec!["NM", "HR", "DT", "HT", "EZ"]); + for r in &stats.difficulty_attributes { + assert_eq!(r.ruleset, "mania"); + assert_eq!(r.calculation_status, "ok"); + let v: serde_json::Value = serde_json::from_str(&r.attributes_json).unwrap(); + assert_eq!(v["ruleset"], "mania"); + assert!(v.get("n_hold_notes").is_some()); + } + } + + #[test] + fn reference_id_extraction_order_is_stable_across_runs() { + // The asset_references writer relies on deterministic extraction + // order — General (AudioFilename) → Events → HitObjects explicit → + // HitObjects derived — so reference_id sequence numbers stay stable + // across re-ingests of the same archive. Ingest the same fixture + // twice and assert the reference_id sequence is identical. + let mut buf = Vec::new(); + { + let mut w = zip::ZipWriter::new(Cursor::new(&mut buf)); + let opts = + SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated); + w.start_file("song.mp3", opts).unwrap(); + w.write_all(b"FAKE-AUDIO").unwrap(); + w.start_file("a.osu", opts).unwrap(); + w.write_all(OSU_FOR_REFS_FIXTURE.as_bytes()).unwrap(); + w.start_file("bg.png", opts).unwrap(); + w.write_all(b"\x89PNG\r\nFAKE").unwrap(); + w.start_file("sb/star.png", opts).unwrap(); + w.write_all(b"\x89PNG\r\nFAKE-STAR").unwrap(); + w.start_file("custom-clap.wav", opts).unwrap(); + w.write_all(b"FAKE-WAV").unwrap(); + w.start_file("normal-hitnormal.wav", opts).unwrap(); + w.write_all(b"FAKE-NORMAL").unwrap(); + w.finish().unwrap(); + } + + let run = || { + let tmp = tempfile::tempdir().unwrap(); + let osz = tmp.path().join("refs.osz"); + std::fs::write(&osz, &buf).unwrap(); + let stats = ingest_archive( + &osz, + &tmp.path().join("archives"), + &tmp.path().join("blobs"), + "batch", + "v", + "v1", + false, + ) + .unwrap(); + stats + .asset_references + .iter() + .map(|r| { + ( + r.reference_kind.clone(), + r.raw_reference.clone(), + r.reference_id.clone(), + ) + }) + .collect::>() + }; + + let a = run(); + let b = run(); + assert_eq!( + a, b, + "reference_id extraction order is non-deterministic — reference \ + rows must be emitted in the same order across runs of the same \ + input" + ); + + // The sequence numbers must increase strictly per reference within + // one archive. Pull out the trailing :: integer and verify. + let seqs: Vec = a + .iter() + .map(|(_, _, rid)| { + rid.rsplit("::") + .next() + .and_then(|s| s.parse::().ok()) + .expect("reference_id ends with ::") + }) + .collect(); + for pair in seqs.windows(2) { + assert!( + pair[1] > pair[0], + "reference_id sequence numbers must be strictly increasing; \ + got {} then {}", + pair[0], + pair[1] + ); + } + + // Documented order: AudioFilename (General) appears before any Events + // refs, which appear before HitObjects-derived refs. + let kinds: Vec<&str> = a.iter().map(|(k, _, _)| k.as_str()).collect(); + let audio_pos = kinds.iter().position(|k| *k == "audio_filename").unwrap(); + let bg_pos = kinds.iter().position(|k| *k == "background_image").unwrap(); + let derived_pos = kinds + .iter() + .position(|k| *k == "derived_custom_hitsound_sample") + .unwrap(); + assert!(audio_pos < bg_pos); + assert!(bg_pos < derived_pos); + } +} diff --git a/crates/osu_indexer/src/osu_parse.rs b/crates/osu_indexer/src/osu_parse.rs new file mode 100644 index 0000000000000000000000000000000000000000..fbdc1637c31227a76b20a700586f5781c8f6092c --- /dev/null +++ b/crates/osu_indexer/src/osu_parse.rs @@ -0,0 +1,1778 @@ +//! `.osu` parsing via rosu-map, with raw section preservation and a +//! standalone `[TimingPoints]` parser. +//! +//! rosu-map decomposes `[TimingPoints]` into four separate vecs (timing / +//! difficulty / effect / sample). The schema's `timing_points` table mirrors +//! the original .osu CSV format, so we reparse that section from raw text +//! rather than reconstructing from rosu's split structures. + +use rosu_map::section::general::{CountdownType, GameMode}; +use rosu_map::section::hit_objects::hit_samples::SampleBank; +use rosu_map::Beatmap; + +pub const PARSER_NAME: &str = "rosu-map"; +pub const PARSER_VERSION: &str = "0.2"; + +/// Outcome of parsing one `.osu` file. +#[derive(Debug, Clone)] +pub struct ParsedBeatmap { + /// File-level identity (known regardless of whether parsing succeeded). + pub osu_blob_sha256: String, + pub osu_path_raw: Option, + pub osu_path_posix: Option, + /// Lookup-only path key. Duplicate archive members may share this value. + pub osu_path_key: String, + /// Unique logical-file suffix used to construct `logical_file_id` once the + /// `set_revision_id` is resolved. Equal to `osu_path_key` for ordinary + /// members, with a `::memberNNNN` suffix for duplicate path keys. + pub osu_logical_file_id_suffix: String, + + pub parse_status: ParseStatus, + pub parse_error: Option, + + /// Always populated. Empty list on total scan failure (BOM/encoding). + pub sections: Vec, + + /// None when rosu-map fails outright. + pub fields: Option, + + /// Reparsed from the raw `[TimingPoints]` section (in source order). + /// Empty when the section is missing or rosu-map failed and no section + /// scan succeeded. + pub timing_points: Vec, + + /// Reparsed from the raw `[HitObjects]` section (in source order). Empty + /// when the section is missing. + pub hit_objects: Vec, + + /// Reparsed from the raw `[Colours]` section. None when the section is + /// absent. Always Some when at least one combo/slider line was scanned. + pub colours: Option, + + /// Break events from `[Events]` (entries 2,start,end / Break,start,end). + /// Empty when none are declared. + pub breaks: Vec, + + /// Original `.osu` bytes, retained so downstream consumers (e.g. + /// `difficulty::compute` via rosu-pp) can re-parse without re-reading the + /// blob. Memory cost is bounded: typical `.osu` is 5–30 KB; even + /// storyboard-heavy maps cap at a few hundred KB. + pub raw_bytes: Vec, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ParseStatus { + Ok, + Partial, + Failed, +} + +impl ParseStatus { + pub fn as_str(self) -> &'static str { + match self { + ParseStatus::Ok => "ok", + ParseStatus::Partial => "partial", + ParseStatus::Failed => "failed", + } + } +} + +#[allow(dead_code)] +#[derive(Debug, Clone)] +pub struct ParsedFields { + pub format_version: i32, + pub mode: u8, + pub ruleset: String, + + pub title: String, + pub title_unicode: String, + pub artist: String, + pub artist_unicode: String, + pub creator: String, + pub version: String, + pub source: String, + pub tags: Vec, + + pub audio_filename_raw: String, + pub audio_lead_in_ms: i32, + pub background_filename: Option, + + pub hp_drain_rate: f32, + pub circle_size: f32, + pub overall_difficulty: f32, + pub approach_rate: f32, + pub slider_multiplier: f64, + pub slider_tick_rate: f64, + + pub preview_time_ms: i32, + pub countdown: i32, + pub sample_set: String, + pub stack_leniency: f32, + pub special_style: bool, + pub widescreen_storyboard: bool, + pub letterbox_in_breaks: bool, + pub epilepsy_warning: bool, + pub samples_match_playback_rate: bool, + + pub hit_object_count: i32, + pub timing_point_count: i32, + pub break_count: i32, + pub event_count: i32, + + pub has_local_storyboard: bool, + pub has_video: bool, + + pub beatmap_id: i32, + pub beatmapset_id: i32, + + /// Optional pixel offset on the background line in `[Events]`. + pub background_x: Option, + pub background_y: Option, + /// Optional offset (ms) on the video line in `[Events]`. + pub video_start_time_ms: Option, +} + +#[derive(Debug, Clone)] +pub struct RawSection { + /// Header as written in the file, including brackets (`[General]`), or + /// the literal `_header` for the leading `osu file format vN` declaration + /// and any pre-section content. + pub section_name: String, + pub line_index_start: i32, + pub line_index_end: i32, + pub byte_start: i64, + pub byte_end: i64, + pub raw_text: String, + pub parse_status: String, +} + +#[derive(Debug, Clone)] +pub struct RawTimingPoint { + pub row_index: i32, + pub time_ms: f64, + pub beat_length: f64, + pub meter: Option, + pub sample_set: Option, + pub sample_index: Option, + pub volume: Option, + pub uninherited: bool, + pub effects: Option, + pub raw_line: String, +} + +/// Per-line hit object. Built by reparsing `[HitObjects]` directly: rosu-map +/// strips the raw curve string and edge-sound list, but the schema preserves +/// them column-for-column. +#[derive(Debug, Clone)] +pub struct RawHitObject { + pub object_index: i32, + pub x: i32, + pub y: i32, + pub time_ms: i32, + pub type_flags: i32, + pub hit_sound_flags: i32, + pub common_kind: HitObjectCommonKind, + pub is_new_combo: bool, + pub combo_skip: Option, + /// CSV tail after the first 5 mandatory fields (x, y, time, type, hitsound). + pub raw_params: Vec, + pub raw_line: String, + pub parse_status: &'static str, + /// Spinner / hold end time, if present. + pub end_time_ms: Option, + /// Decoded slider geometry, when `common_kind == Slider`. + pub slider: Option, + /// Trailing colon-delimited "normalSet:additionSet:index:volume:filename". + pub hit_sample_raw: Option, + /// Parsed view of `hit_sample_raw`. None when `hit_sample_raw` is None or + /// empty; partially-populated when only some fields parse. + pub hit_sample: Option, +} + +/// Decoded `normalSet:additionSet:index:volume:filename` field. Each component +/// is independently optional — old maps may carry just a few fields. +#[derive(Debug, Clone, Default)] +pub struct HitSample { + pub normal_set: Option, + pub addition_set: Option, + pub index: Option, + pub volume: Option, + pub filename: Option, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum HitObjectCommonKind { + Circle, + Slider, + Spinner, + Hold, + Unknown, +} + +impl HitObjectCommonKind { + pub fn as_str(self) -> &'static str { + match self { + HitObjectCommonKind::Circle => "circle", + HitObjectCommonKind::Slider => "slider", + HitObjectCommonKind::Spinner => "spinner", + HitObjectCommonKind::Hold => "hold", + HitObjectCommonKind::Unknown => "unknown", + } + } + + /// Decode the type byte. Mania `Hold` (bit 7) takes precedence, then + /// `Spinner` (bit 3), `Slider` (bit 1), `Circle` (bit 0). The flags are + /// mutually exclusive in practice but we still pick a winner deterministically. + fn from_type_flags(flags: i32) -> Self { + if flags & 128 != 0 { + Self::Hold + } else if flags & 8 != 0 { + Self::Spinner + } else if flags & 2 != 0 { + Self::Slider + } else if flags & 1 != 0 { + Self::Circle + } else { + Self::Unknown + } + } +} + +/// Decoded slider geometry from the raw line. Stays as close to the file +/// format as possible: `curve_type` is the literal prefix (usually a single +/// letter, occasionally `B` for higher-order Béziers); control points +/// do NOT include the implicit head at `(x, y)`. +#[derive(Debug, Clone)] +pub struct RawSlider { + pub curve_type: String, + pub control_points: Vec<(i32, i32)>, + pub repeats: i32, + pub pixel_length: f64, + pub edge_sounds_raw: Option, + pub edge_sets_raw: Option, + /// Parsed `edge_sounds_raw` (pipe-split integers). None when the field + /// is absent; empty Vec is returned only when an explicitly-empty field + /// somehow survives parsing. + pub edge_sounds: Option>, + /// Parsed `edge_sets_raw` (pipe-split "normalSet:additionSet" strings). + pub edge_sets: Option>, +} + +/// Parsed `[Colours]` section. +#[derive(Debug, Clone)] +pub struct RawColours { + /// Combo color RGB triples in declared order (Combo1, Combo2, ...). + pub combo_colors: Vec<(i32, i32, i32)>, + pub slider_track_override: Option<(i32, i32, i32)>, + pub slider_border: Option<(i32, i32, i32)>, + /// Whether any line failed to parse. Lets us mark the row partial. + pub had_parse_failure: bool, +} + +/// One break event from `[Events]` (`2,start,end` or `Break,start,end`). +/// `break_index` is stamped at row-build time to mirror the iter index. +#[derive(Debug, Clone)] +pub struct RawBreak { + pub start_time_ms: i32, + pub end_time_ms: i32, + pub raw_line: String, +} + +/// Decoded background event line: `0,0,"bg.jpg",x,y`. The filename is already +/// captured on `bm.background_file`; this struct just carries the optional +/// pixel offset. +#[derive(Debug, Clone, Default)] +pub struct RawBackgroundEvent { + pub x: Option, + pub y: Option, +} + +/// Decoded video event line: `1,start,"video.mp4"` or `Video,start,"..."`. +#[derive(Debug, Clone, Default)] +pub struct RawVideoEvent { + pub start_time_ms: Option, +} + +/// Parse a `.osu` blob. +/// +/// `osu_blob_sha256` / `osu_path_*` come from the `logical_files` row already +/// being constructed for this member, so they're passed in by the caller. The +/// returned `ParsedBeatmap` is always populated even when rosu-map fails — the +/// raw section scan still runs, and `parse_status` distinguishes the cases. +pub fn parse( + bytes: &[u8], + osu_blob_sha256: String, + osu_path_raw: Option, + osu_path_posix: Option, + osu_path_key: String, + osu_logical_file_id_suffix: String, +) -> ParsedBeatmap { + // Independently of rosu-map: scan sections so osu_sections / timing_points + // are queryable even on parse failure. + let text_for_scan = decode_for_scan(bytes); + let sections = scan_sections(&text_for_scan); + let timing_points = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[TimingPoints]")) + .map(|s| parse_timing_points_section(&s.raw_text)) + .unwrap_or_default(); + let mut hit_objects = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[HitObjects]")) + .map(|s| parse_hit_objects_section(&s.raw_text)) + .unwrap_or_default(); + let colours = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Colours]")) + .map(|s| parse_colours_section(&s.raw_text)); + let events_section = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")); + let breaks = events_section + .map(|s| parse_breaks_from_events(&s.raw_text)) + .unwrap_or_default(); + let background_event = events_section.and_then(|s| parse_background_event(&s.raw_text)); + let video_event = events_section.and_then(|s| parse_video_event(&s.raw_text)); + // background_event / video_event are consumed by build_fields below; we + // don't store them on ParsedBeatmap because every column we care about + // (background_x/y, video_start_time_ms) is already exposed via fields. + + // Slider tail times need (pixel_length, repeats) plus the active timing + // point's beat_length and SV multiplier — none of which + // `parse_hit_objects_section` has access to. Fill them in here so + // downstream `hit_objects_*.end_time_ms` and `beatmaps.last_object_time_ms` + // include sliders. SliderMultiplier comes from rosu-map when the beatmap + // parses, else falls back to the .osu format default of 1.4. + let bm_result = Beatmap::from_bytes(bytes); + let slider_multiplier_for_ends = match bm_result.as_ref() { + Ok(bm) => bm.slider_multiplier, + Err(_) => 1.4, + }; + compute_slider_end_times(&mut hit_objects, slider_multiplier_for_ends, &timing_points); + + match bm_result { + Ok(bm) => { + let fields = build_fields( + &bm, + §ions, + background_event.as_ref(), + video_event.as_ref(), + ); + ParsedBeatmap { + osu_blob_sha256, + osu_path_raw, + osu_path_posix, + osu_path_key, + osu_logical_file_id_suffix, + parse_status: ParseStatus::Ok, + parse_error: None, + sections, + fields: Some(fields), + timing_points, + hit_objects, + colours, + breaks, + raw_bytes: bytes.to_vec(), + } + } + Err(e) => { + // rosu failed but our raw scan may have succeeded — partial vs + // failed depends on whether we see at least one bracketed section. + let has_any_section = sections.iter().any(|s| s.section_name.starts_with('[')); + let status = if has_any_section { + ParseStatus::Partial + } else { + ParseStatus::Failed + }; + ParsedBeatmap { + osu_blob_sha256, + osu_path_raw, + osu_path_posix, + osu_path_key, + osu_logical_file_id_suffix, + parse_status: status, + parse_error: Some(e.to_string()), + sections, + fields: None, + timing_points, + hit_objects, + colours, + breaks, + raw_bytes: bytes.to_vec(), + } + } + } +} + +fn decode_for_scan(bytes: &[u8]) -> String { + // .osu files are UTF-8 (with optional BOM). Lossy-decode lets the section + // scanner work on best-effort text even when the file has stray bytes. + let text = String::from_utf8_lossy(bytes); + let stripped = text.strip_prefix('\u{FEFF}').unwrap_or(&text); + stripped.to_string() +} + +fn build_fields( + bm: &Beatmap, + sections: &[RawSection], + background_event: Option<&RawBackgroundEvent>, + video_event: Option<&RawVideoEvent>, +) -> ParsedFields { + let mode_u8 = game_mode_to_u8(bm.mode); + let event_count = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")) + .map(|s| count_data_lines(&s.raw_text)) + .unwrap_or(0); + let has_local_storyboard = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")) + .map(|s| events_has_storyboard(&s.raw_text)) + .unwrap_or(false); + let has_video = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")) + .map(|s| events_has_video(&s.raw_text)) + .unwrap_or(false); + + let bg = if bm.background_file.is_empty() { + None + } else { + Some(bm.background_file.clone()) + }; + + ParsedFields { + format_version: bm.format_version, + mode: mode_u8, + ruleset: ruleset_string(mode_u8).to_string(), + + title: bm.title.clone(), + title_unicode: bm.title_unicode.clone(), + artist: bm.artist.clone(), + artist_unicode: bm.artist_unicode.clone(), + creator: bm.creator.clone(), + version: bm.version.clone(), + source: bm.source.clone(), + tags: bm.tags.split_whitespace().map(String::from).collect(), + + audio_filename_raw: bm.audio_file.clone(), + // [General] AudioLeadIn — silence prepended before audio playback. + // Stored as i32 to match other ms columns; rosu-map decodes to f64 + // but parses the source as i32, so the cast is lossless. + audio_lead_in_ms: bm.audio_lead_in as i32, + background_filename: bg, + + hp_drain_rate: bm.hp_drain_rate, + circle_size: bm.circle_size, + overall_difficulty: bm.overall_difficulty, + approach_rate: bm.approach_rate, + slider_multiplier: bm.slider_multiplier, + slider_tick_rate: bm.slider_tick_rate, + + preview_time_ms: bm.preview_time, + countdown: countdown_to_int(bm.countdown), + sample_set: sample_bank_string(bm.default_sample_bank).to_string(), + stack_leniency: bm.stack_leniency, + special_style: bm.special_style, + widescreen_storyboard: bm.widescreen_storyboard, + letterbox_in_breaks: bm.letterbox_in_breaks, + epilepsy_warning: bm.epilepsy_warning, + samples_match_playback_rate: bm.samples_match_playback_rate, + + hit_object_count: bm.hit_objects.len() as i32, + timing_point_count: bm.control_points.timing_points.len() as i32, + break_count: bm.breaks.len() as i32, + event_count, + + has_local_storyboard, + has_video, + + beatmap_id: bm.beatmap_id, + beatmapset_id: bm.beatmap_set_id, + + background_x: background_event.and_then(|e| e.x), + background_y: background_event.and_then(|e| e.y), + video_start_time_ms: video_event.and_then(|e| e.start_time_ms), + } +} + +pub fn ruleset_string(mode: u8) -> &'static str { + match mode { + 0 => "osu", + 1 => "taiko", + 2 => "catch", + 3 => "mania", + _ => "unknown", + } +} + +pub fn ruleset_aliases(mode: u8) -> Option> { + match mode { + 2 => Some(vec!["ctb".to_string()]), + _ => None, + } +} + +fn game_mode_to_u8(m: GameMode) -> u8 { + match m { + GameMode::Osu => 0, + GameMode::Taiko => 1, + GameMode::Catch => 2, + GameMode::Mania => 3, + } +} + +fn countdown_to_int(c: CountdownType) -> i32 { + // Conventional .osu mapping per the file-format wiki: + // 0 = no countdown, 1 = normal, 2 = half, 3 = double. + match c { + CountdownType::None => 0, + CountdownType::Normal => 1, + CountdownType::HalfSpeed => 2, + CountdownType::DoubleSpeed => 3, + } +} + +fn sample_bank_string(b: SampleBank) -> &'static str { + match b { + SampleBank::None => "none", + SampleBank::Normal => "normal", + SampleBank::Soft => "soft", + SampleBank::Drum => "drum", + } +} + +/// Count non-empty, non-comment lines inside a raw section body, excluding +/// the bracketed header line. +fn count_data_lines(section_text: &str) -> i32 { + let mut n = 0i32; + for (i, line) in section_text.lines().enumerate() { + if i == 0 && line.trim_start().starts_with('[') { + continue; + } + let t = line.trim(); + if t.is_empty() || t.starts_with("//") { + continue; + } + n += 1; + } + n +} + +/// True when [Events] contains any storyboard command lines. +fn events_has_storyboard(section_text: &str) -> bool { + for (i, line) in section_text.lines().enumerate() { + if i == 0 && line.trim_start().starts_with('[') { + continue; + } + let t = line.trim_start(); + if t.is_empty() || t.starts_with("//") { + continue; + } + let lc = t.to_ascii_lowercase(); + if lc.starts_with("sprite,") + || lc.starts_with("animation,") + || lc.starts_with("sample,") + || lc.starts_with("4,") + || lc.starts_with("5,") + || lc.starts_with("6,") + { + return true; + } + // Indented child commands (F, M, S, R, etc.) appear under + // sprite/animation parents, so any indented line is also evidence. + if line.starts_with(' ') || line.starts_with('\t') || line.starts_with('_') { + return true; + } + } + false +} + +/// True when [Events] has a video event (code 1 or "Video,..."). +fn events_has_video(section_text: &str) -> bool { + for (i, line) in section_text.lines().enumerate() { + if i == 0 && line.trim_start().starts_with('[') { + continue; + } + let t = line.trim_start(); + if t.is_empty() || t.starts_with("//") { + continue; + } + let lc = t.to_ascii_lowercase(); + if lc.starts_with("video,") || lc.starts_with("1,") { + return true; + } + } + false +} + +/// Slice a `.osu` text into `RawSection`s. Section headers are bracket- +/// delimited (`[General]`, `[Events]`, …). Anything before the first header +/// (typically just `osu file format vN`) is collected into a synthetic +/// `_header` section. +pub fn scan_sections(text: &str) -> Vec { + let mut sections: Vec = Vec::new(); + let mut byte_offset: i64 = 0; + let mut header_started = false; + + let mut cur_name: Option = None; + let mut cur_start_line: i32 = 0; + let mut cur_start_byte: i64 = 0; + let mut cur_text = String::new(); + + let mut last_line_index: i32 = -1; + + for (line_index, line_with_newline) in text.split_inclusive('\n').enumerate() { + let line_index = line_index as i32; + last_line_index = line_index; + let line_byte_start = byte_offset; + let line_len = line_with_newline.len() as i64; + let trimmed = line_with_newline + .trim_end_matches('\n') + .trim_end_matches('\r'); + + let is_section_header = trimmed.starts_with('[') && trimmed.ends_with(']'); + + if is_section_header { + // Close current section. + if let Some(name) = cur_name.take() { + sections.push(RawSection { + section_name: name, + line_index_start: cur_start_line, + line_index_end: line_index - 1, + byte_start: cur_start_byte, + byte_end: line_byte_start - 1, + raw_text: std::mem::take(&mut cur_text), + parse_status: "ok".to_string(), + }); + } else if header_started { + // Pre-header bucket (anonymous "_header") existed; close it. + sections.push(RawSection { + section_name: "_header".to_string(), + line_index_start: 0, + line_index_end: line_index - 1, + byte_start: 0, + byte_end: line_byte_start - 1, + raw_text: std::mem::take(&mut cur_text), + parse_status: "ok".to_string(), + }); + header_started = false; + } + // Start the new section. + cur_name = Some(trimmed.to_string()); + cur_start_line = line_index; + cur_start_byte = line_byte_start; + cur_text = String::from(line_with_newline); + } else if cur_name.is_some() { + cur_text.push_str(line_with_newline); + } else { + // Pre-header content. + if !header_started { + header_started = true; + cur_start_line = 0; + cur_start_byte = 0; + } + cur_text.push_str(line_with_newline); + } + + byte_offset += line_len; + } + + // Close trailing section. + if let Some(name) = cur_name { + sections.push(RawSection { + section_name: name, + line_index_start: cur_start_line, + line_index_end: last_line_index, + byte_start: cur_start_byte, + byte_end: byte_offset.saturating_sub(1), + raw_text: cur_text, + parse_status: "ok".to_string(), + }); + } else if header_started { + sections.push(RawSection { + section_name: "_header".to_string(), + line_index_start: 0, + line_index_end: last_line_index, + byte_start: 0, + byte_end: byte_offset.saturating_sub(1), + raw_text: cur_text, + parse_status: "ok".to_string(), + }); + } + + sections +} + +/// Parse the raw text of a `[TimingPoints]` section. Skips comments, blank +/// lines, and the bracketed header itself. +pub fn parse_timing_points_section(section_text: &str) -> Vec { + let mut out = Vec::new(); + let mut row_index = 0i32; + for line in section_text.lines() { + let trimmed = line.trim(); + if trimmed.is_empty() || trimmed.starts_with("//") || trimmed.starts_with('[') { + continue; + } + let parts: Vec<&str> = trimmed.split(',').collect(); + if parts.len() < 2 { + continue; + } + let time_ms = parts[0].trim().parse::().unwrap_or(f64::NAN); + let beat_length = parts[1].trim().parse::().unwrap_or(f64::NAN); + if !time_ms.is_finite() || !beat_length.is_finite() { + continue; + } + let meter = parts.get(2).and_then(|s| s.trim().parse::().ok()); + let sample_set = parts.get(3).and_then(|s| s.trim().parse::().ok()); + let sample_index = parts.get(4).and_then(|s| s.trim().parse::().ok()); + let volume = parts.get(5).and_then(|s| s.trim().parse::().ok()); + // The `uninherited` flag was introduced in v8 of the .osu format. Old + // maps lack it; default to (beat_length > 0) which matches the format + // convention (positive beat_length = uninherited). + let uninherited = parts + .get(6) + .and_then(|s| s.trim().parse::().ok()) + .map(|n| n != 0) + .unwrap_or(beat_length > 0.0); + let effects = parts.get(7).and_then(|s| s.trim().parse::().ok()); + + out.push(RawTimingPoint { + row_index, + time_ms, + beat_length, + meter, + sample_set, + sample_index, + volume, + uninherited, + effects, + raw_line: trimmed.to_string(), + }); + row_index += 1; + } + out +} + +/// Parse the raw text of a `[HitObjects]` section. Skips comments, blank +/// lines, and the bracketed header. Each line must have at least 5 +/// comma-separated fields (x, y, time, type, hitsound) to produce a row. +pub fn parse_hit_objects_section(section_text: &str) -> Vec { + let mut out = Vec::new(); + let mut object_index = 0i32; + for line in section_text.lines() { + let trimmed = line.trim(); + if trimmed.is_empty() || trimmed.starts_with("//") || trimmed.starts_with('[') { + continue; + } + let parts: Vec<&str> = trimmed.split(',').collect(); + if parts.len() < 5 { + continue; + } + + let x = parse_int_field(parts[0]); + let y = parse_int_field(parts[1]); + let time_ms = parse_int_field(parts[2]); + let type_flags = parts[3].trim().parse::().ok(); + let hit_sound_flags = parts[4].trim().parse::().ok(); + let (Some(x), Some(y), Some(time_ms), Some(tf), Some(hs)) = + (x, y, time_ms, type_flags, hit_sound_flags) + else { + continue; + }; + + let raw_params: Vec = parts[5..].iter().map(|s| s.to_string()).collect(); + let common_kind = HitObjectCommonKind::from_type_flags(tf); + let is_new_combo = (tf & 4) != 0; + let combo_skip = Some((tf >> 4) & 7); + + let mut end_time_ms: Option = None; + let mut slider: Option = None; + let mut hit_sample_raw: Option = None; + let mut parse_status: &'static str = "ok"; + + match common_kind { + HitObjectCommonKind::Circle => { + hit_sample_raw = raw_params.first().cloned().filter(|s| !s.is_empty()); + } + HitObjectCommonKind::Slider => { + let parsed_slider = parse_slider_params(&raw_params); + if parsed_slider.is_none() { + parse_status = "partial"; + } + slider = parsed_slider; + // Slider tail layout (.osu spec): + // curve, slides, length, edgeSounds, edgeSets, hitSample + // Older format versions stop at `length`; that's why everything + // past index 2 is optional. + hit_sample_raw = raw_params.get(5).cloned().filter(|s| !s.is_empty()); + } + HitObjectCommonKind::Spinner => { + end_time_ms = raw_params.first().and_then(|s| parse_int_field(s)); + if end_time_ms.is_none() { + parse_status = "partial"; + } + hit_sample_raw = raw_params.get(1).cloned().filter(|s| !s.is_empty()); + } + HitObjectCommonKind::Hold => { + // Mania holds collapse `endTime:hitSample` into one comma- + // separated tail param. + if let Some(first) = raw_params.first() { + if let Some((end, sample)) = first.split_once(':') { + end_time_ms = parse_int_field(end); + if !sample.is_empty() { + hit_sample_raw = Some(sample.to_string()); + } + } else { + end_time_ms = parse_int_field(first); + } + } + if end_time_ms.is_none() { + parse_status = "partial"; + } + } + HitObjectCommonKind::Unknown => { + parse_status = "partial"; + } + } + + let hit_sample = hit_sample_raw.as_deref().and_then(parse_hit_sample_field); + out.push(RawHitObject { + object_index, + x, + y, + time_ms, + type_flags: tf, + hit_sound_flags: hs, + common_kind, + is_new_combo, + combo_skip, + raw_params, + raw_line: trimmed.to_string(), + parse_status, + end_time_ms, + slider, + hit_sample_raw, + hit_sample, + }); + object_index += 1; + } + out +} + +/// Fill in `end_time_ms` for every Slider in `hit_objects` whose value is +/// still `None`. Sliders need (`pixel_length`, `repeats`) plus the active +/// timing point's `beat_length` (uninherited) and SV multiplier (inherited if +/// active, else 1.0) — none of which `parse_hit_objects_section` has access +/// to. This pass fills the gap so `beatmaps.total_length_ms` and +/// `last_object_time_ms` cover slider/drumroll/juice-stream tails without +/// downstream consumers redoing the math. +/// +/// Formula (osu! file-format wiki, [HitObjects] → Slider): +/// +/// ```text +/// slide_duration_ms = (pixel_length / (slider_multiplier * 100 * sv)) * beat_length +/// total_duration_ms = slide_duration_ms * repeats +/// end_time_ms = start_time_ms + total_duration_ms +/// ``` +/// +/// where `beat_length` is from the most recent UNINHERITED timing point and +/// `sv` is `-100 / beat_length` for the most recent timing point if it's +/// INHERITED with negative `beat_length`, else `1.0`. +/// +/// Idempotent: only sliders whose `end_time_ms` is currently `None` are +/// touched, so callers can run this twice safely. +pub fn compute_slider_end_times( + hit_objects: &mut [RawHitObject], + slider_multiplier: f64, + timing_points: &[RawTimingPoint], +) { + if slider_multiplier <= 0.0 { + return; + } + for ho in hit_objects.iter_mut() { + if !matches!(ho.common_kind, HitObjectCommonKind::Slider) { + continue; + } + if ho.end_time_ms.is_some() { + continue; + } + let slider = match ho.slider.as_ref() { + Some(s) => s, + None => continue, + }; + if slider.pixel_length <= 0.0 || slider.repeats < 1 { + continue; + } + + // Most recent uninherited timing point at or before the slider start. + // Falls back to the first uninherited timing point if the slider + // precedes every point — rare on real maps but possible on broken + // 2008-era data; better an approximation than a null tail. + let beat_length = timing_points + .iter() + .rev() + .find(|tp| tp.uninherited && tp.time_ms <= ho.time_ms as f64) + .or_else(|| timing_points.iter().find(|tp| tp.uninherited)) + .map(|tp| tp.beat_length); + let beat_length = match beat_length { + Some(b) if b > 0.0 => b, + _ => continue, + }; + + // Most recent timing point of any kind for the SV multiplier. Red + // (uninherited) lines reset SV to 1.0; green (inherited) lines carry + // SV via `-100 / beat_length`. + let sv = timing_points + .iter() + .rev() + .find(|tp| tp.time_ms <= ho.time_ms as f64) + .map(|tp| { + if !tp.uninherited && tp.beat_length < 0.0 { + -100.0 / tp.beat_length + } else { + 1.0 + } + }) + .unwrap_or(1.0); + if sv <= 0.0 { + continue; + } + + let slide_duration = (slider.pixel_length / (slider_multiplier * 100.0 * sv)) * beat_length; + let total_duration = slide_duration * slider.repeats as f64; + ho.end_time_ms = Some((ho.time_ms as f64 + total_duration).round() as i32); + } +} + +fn parse_int_field(s: &str) -> Option { + let t = s.trim(); + // Some old maps store coordinates as floats ("256.5"). Accept both via f64. + t.parse::().ok().map(|v| v.round() as i32) +} + +fn parse_slider_params(raw_params: &[String]) -> Option { + let curve = raw_params.first()?; + let slides = raw_params.get(1)?.trim().parse::().ok()?; + let pixel_length = raw_params.get(2)?.trim().parse::().ok()?; + let (curve_type, control_points) = parse_curve_string(curve)?; + let edge_sounds_raw = raw_params.get(3).cloned().filter(|s| !s.is_empty()); + let edge_sets_raw = raw_params.get(4).cloned().filter(|s| !s.is_empty()); + let edge_sounds = edge_sounds_raw.as_deref().map(parse_edge_sounds); + let edge_sets = edge_sets_raw.as_deref().map(parse_edge_sets); + Some(RawSlider { + curve_type, + control_points, + repeats: slides, + pixel_length, + edge_sounds_raw, + edge_sets_raw, + edge_sounds, + edge_sets, + }) +} + +/// Parse `2|0|2` → `[2, 0, 2]`. Returns one entry per pipe-delimited field; +/// unparseable entries default to 0 (which is "no extra hit sound" in the +/// .osu spec, matching osu's tolerance for malformed lines). +pub fn parse_edge_sounds(raw: &str) -> Vec { + raw.split('|') + .map(|s| s.trim().parse::().unwrap_or(0)) + .collect() +} + +/// Parse `0:0|1:0|0:0` → `["0:0", "1:0", "0:0"]`. Each entry is a literal +/// `normalSet:additionSet` pair; we leave parsing of the inner colon to the +/// consumer because it's only meaningful when paired with the matching +/// edge_sounds bitfield. +pub fn parse_edge_sets(raw: &str) -> Vec { + raw.split('|').map(|s| s.trim().to_string()).collect() +} + +/// Parse `normalSet:additionSet:index:volume:filename` into a `HitSample`. +/// Empty/missing components map to None. Per the .osu spec, fields use 0 as +/// "use timing point default" — we preserve the raw 0 rather than synthesizing +/// nulls, since the consumer can distinguish "explicitly 0" from "not given" +/// by the field count. +pub fn parse_hit_sample_field(raw: &str) -> Option { + let trimmed = raw.trim(); + if trimmed.is_empty() { + return None; + } + let parts: Vec<&str> = trimmed.split(':').collect(); + let take_int = |idx: usize| -> Option { + parts + .get(idx) + .map(|s| s.trim()) + .filter(|s| !s.is_empty()) + .and_then(|s| s.parse::().ok()) + }; + let filename = parts + .get(4) + .map(|s| s.trim().to_string()) + .filter(|s| !s.is_empty()); + Some(HitSample { + normal_set: take_int(0), + addition_set: take_int(1), + index: take_int(2), + volume: take_int(3), + filename, + }) +} + +/// Parse `[Colours]` body. Per the .osu wiki: keys are `Combo` (1..=8), +/// `SliderTrackOverride`, `SliderBorder`. Values are `R,G,B` (each 0..=255). +/// Unknown keys are tolerated (preserved in raw_section_text only). +pub fn parse_colours_section(section_text: &str) -> RawColours { + let mut combo_colors: Vec<(i32, i32, i32)> = Vec::new(); + let mut slider_track_override: Option<(i32, i32, i32)> = None; + let mut slider_border: Option<(i32, i32, i32)> = None; + let mut had_parse_failure = false; + for line in section_text.lines() { + let trimmed = line.trim(); + if trimmed.is_empty() || trimmed.starts_with("//") || trimmed.starts_with('[') { + continue; + } + let Some((key_raw, value_raw)) = trimmed.split_once(':') else { + continue; + }; + let key = key_raw.trim(); + let value = value_raw.trim(); + let parsed_rgb = parse_rgb(value); + let Some(rgb) = parsed_rgb else { + had_parse_failure = true; + continue; + }; + if key.eq_ignore_ascii_case("SliderTrackOverride") { + slider_track_override = Some(rgb); + } else if key.eq_ignore_ascii_case("SliderBorder") { + slider_border = Some(rgb); + } else if let Some(rest) = key + .strip_prefix("Combo") + .or_else(|| key.strip_prefix("combo")) + { + // The numeric tail confirms it's actually a combo entry; we store + // them in declared order rather than indexed by N because old maps + // sometimes skip / re-order numbers. + if rest.trim().parse::().is_ok() { + combo_colors.push(rgb); + } + } + } + RawColours { + combo_colors, + slider_track_override, + slider_border, + had_parse_failure, + } +} + +/// Parse "r,g,b" (with optional whitespace). Clamped to 0..=255 since some old +/// maps store out-of-range values; consumers can recover the raw text from +/// `colours.raw_section_text` if the clamp matters. +fn parse_rgb(value: &str) -> Option<(i32, i32, i32)> { + let parts: Vec<&str> = value.split(',').collect(); + if parts.len() < 3 { + return None; + } + let r = parts[0].trim().parse::().ok()?.round() as i32; + let g = parts[1].trim().parse::().ok()?.round() as i32; + let b = parts[2].trim().parse::().ok()?.round() as i32; + Some((r.clamp(0, 255), g.clamp(0, 255), b.clamp(0, 255))) +} + +/// Pull every `2,start,end` (or `Break,start,end`) line out of `[Events]`. +/// Events are 0-indented; storyboard child commands at depth>=1 don't count. +pub fn parse_breaks_from_events(section_text: &str) -> Vec { + let mut out = Vec::new(); + for (i, line) in section_text.lines().enumerate() { + if i == 0 && line.trim_start().starts_with('[') { + continue; + } + if line.starts_with(' ') || line.starts_with('\t') || line.starts_with('_') { + continue; + } + let trimmed = line.trim(); + if trimmed.is_empty() || trimmed.starts_with("//") { + continue; + } + let parts: Vec<&str> = trimmed.split(',').collect(); + if parts.len() < 3 { + continue; + } + let kind = parts[0].trim(); + if !(kind == "2" || kind.eq_ignore_ascii_case("Break")) { + continue; + } + let start = parse_int_field(parts[1]); + let end = parse_int_field(parts[2]); + let (Some(start), Some(end)) = (start, end) else { + continue; + }; + out.push(RawBreak { + start_time_ms: start, + end_time_ms: end, + raw_line: trimmed.to_string(), + }); + } + out +} + +/// First background event line in `[Events]`. Format: `0,0,"bg.jpg",x,y` (the +/// trailing x,y are optional). +pub fn parse_background_event(section_text: &str) -> Option { + for (i, line) in section_text.lines().enumerate() { + if i == 0 && line.trim_start().starts_with('[') { + continue; + } + if line.starts_with(' ') || line.starts_with('\t') || line.starts_with('_') { + continue; + } + let trimmed = line.trim(); + if trimmed.is_empty() || trimmed.starts_with("//") { + continue; + } + let parts: Vec<&str> = trimmed.split(',').collect(); + if parts.len() < 3 { + continue; + } + let kind = parts[0].trim(); + if !(kind == "0" || kind.eq_ignore_ascii_case("Background")) { + continue; + } + // parts[1] = startTime (always 0 for backgrounds), parts[2] = filename + // (quoted), parts[3] = x, parts[4] = y. + let x = parts.get(3).and_then(|s| parse_int_field(s)); + let y = parts.get(4).and_then(|s| parse_int_field(s)); + return Some(RawBackgroundEvent { x, y }); + } + None +} + +/// First video event line in `[Events]`. Format: `1,startTime,"video.mp4"` +/// or `Video,startTime,"video.mp4"`. +pub fn parse_video_event(section_text: &str) -> Option { + for (i, line) in section_text.lines().enumerate() { + if i == 0 && line.trim_start().starts_with('[') { + continue; + } + if line.starts_with(' ') || line.starts_with('\t') || line.starts_with('_') { + continue; + } + let trimmed = line.trim(); + if trimmed.is_empty() || trimmed.starts_with("//") { + continue; + } + let parts: Vec<&str> = trimmed.split(',').collect(); + if parts.len() < 3 { + continue; + } + let kind = parts[0].trim(); + if !(kind == "1" || kind.eq_ignore_ascii_case("Video")) { + continue; + } + let start = parts.get(1).and_then(|s| parse_int_field(s)); + return Some(RawVideoEvent { + start_time_ms: start, + }); + } + None +} + +/// Decode the slider curve string `B|x:y|x:y|...`. Returns the literal prefix +/// (typically a single letter, occasionally `B`) and the list of +/// explicit control points (head implicit at the object's `(x, y)`). +fn parse_curve_string(s: &str) -> Option<(String, Vec<(i32, i32)>)> { + let mut iter = s.split('|'); + let head = iter.next()?; + let mut points = Vec::new(); + for p in iter { + let (xs, ys) = p.split_once(':')?; + let x = parse_int_field(xs)?; + let y = parse_int_field(ys)?; + points.push((x, y)); + } + Some((head.to_string(), points)) +} + +#[cfg(test)] +mod tests { + use super::*; + + const FIXTURE: &str = "osu file format v14\r\n\r\n\ +[General]\r\n\ +AudioFilename: audio.mp3\r\n\ +AudioLeadIn: 1500\r\n\ +PreviewTime: 12345\r\n\ +Mode: 0\r\n\ +\r\n\ +[Metadata]\r\n\ +Title:Test Title\r\n\ +TitleUnicode:テストタイトル\r\n\ +Artist:Test Artist\r\n\ +ArtistUnicode:テストアーティスト\r\n\ +Creator:peppy\r\n\ +Version:Easy\r\n\ +Source:\r\n\ +Tags:tag1 tag2 tag3\r\n\ +BeatmapID:42\r\n\ +BeatmapSetID:7\r\n\ +\r\n\ +[Difficulty]\r\n\ +HPDrainRate:5\r\n\ +CircleSize:4\r\n\ +OverallDifficulty:6\r\n\ +ApproachRate:7\r\n\ +SliderMultiplier:1.4\r\n\ +SliderTickRate:1\r\n\ +\r\n\ +[Events]\r\n\ +0,0,\"bg.jpg\",0,0\r\n\ +Video,0,\"intro.mp4\"\r\n\ +2,1000,2000\r\n\ +\r\n\ +[TimingPoints]\r\n\ +0,500.0,4,2,1,60,1,0\r\n\ +1000,-50,4,2,1,60,0,1\r\n\ +\r\n\ +[HitObjects]\r\n\ +256,192,3000,1,0,0:0:0:0:\r\n\ +"; + + #[test] + fn rosu_parses_fixture() { + let p = parse( + FIXTURE.as_bytes(), + "deadbeef".to_string(), + Some("Test.osu".to_string()), + Some("Test.osu".to_string()), + "test.osu".to_string(), + "test.osu".to_string(), + ); + assert_eq!(p.parse_status, ParseStatus::Ok); + let f = p.fields.expect("fields populated on Ok"); + assert_eq!(f.beatmap_id, 42); + assert_eq!(f.beatmapset_id, 7); + assert_eq!(f.format_version, 14); + assert_eq!(f.mode, 0); + assert_eq!(f.ruleset, "osu"); + assert_eq!(f.title, "Test Title"); + assert_eq!(f.title_unicode, "テストタイトル"); + assert_eq!(f.artist, "Test Artist"); + assert_eq!(f.creator, "peppy"); + assert_eq!(f.version, "Easy"); + assert_eq!(f.tags, vec!["tag1", "tag2", "tag3"]); + assert_eq!(f.audio_filename_raw, "audio.mp3"); + assert_eq!(f.audio_lead_in_ms, 1500); + assert_eq!(f.preview_time_ms, 12345); + assert_eq!(f.hp_drain_rate, 5.0); + assert_eq!(f.circle_size, 4.0); + assert_eq!(f.overall_difficulty, 6.0); + assert_eq!(f.approach_rate, 7.0); + assert!(f.has_video, "Video,0 line should set has_video"); + assert!(f.event_count >= 2); + } + + #[test] + fn scan_sections_finds_all_blocks() { + let s = scan_sections(FIXTURE); + let names: Vec<&str> = s.iter().map(|r| r.section_name.as_str()).collect(); + assert!(names.contains(&"_header")); + assert!(names.contains(&"[General]")); + assert!(names.contains(&"[Metadata]")); + assert!(names.contains(&"[Difficulty]")); + assert!(names.contains(&"[Events]")); + assert!(names.contains(&"[TimingPoints]")); + assert!(names.contains(&"[HitObjects]")); + // Sections are ordered by appearance. + let pos = |needle: &str| names.iter().position(|n| *n == needle).unwrap(); + assert!(pos("_header") < pos("[General]")); + assert!(pos("[General]") < pos("[Metadata]")); + assert!(pos("[TimingPoints]") < pos("[HitObjects]")); + // Byte ranges are non-overlapping and increasing. + for w in s.windows(2) { + assert!(w[0].byte_end < w[1].byte_start); + } + } + + #[test] + fn timing_points_parsed() { + let s = scan_sections(FIXTURE); + let tp_section = s + .iter() + .find(|x| x.section_name == "[TimingPoints]") + .expect("[TimingPoints] section must exist"); + let pts = parse_timing_points_section(&tp_section.raw_text); + assert_eq!(pts.len(), 2); + assert_eq!(pts[0].row_index, 0); + assert_eq!(pts[0].time_ms, 0.0); + assert_eq!(pts[0].beat_length, 500.0); + assert!(pts[0].uninherited); + assert_eq!(pts[1].time_ms, 1000.0); + assert_eq!(pts[1].beat_length, -50.0); + assert!(!pts[1].uninherited); + } + + #[test] + fn parse_failure_keeps_section_scan() { + // garbage that rosu can't parse but still has a [General] header. + let bad = b"not a real osu file\n[General]\nbroken line without colon\n"; + let p = parse( + bad, + "x".to_string(), + None, + None, + "bad.osu".to_string(), + "bad.osu".to_string(), + ); + // Either Ok (rosu is lenient) or Partial (rosu rejected, sections captured). + assert_ne!(p.parse_status, ParseStatus::Failed); + assert!(p.sections.iter().any(|s| s.section_name == "[General]")); + } + + #[test] + fn ruleset_string_maps_modes() { + assert_eq!(ruleset_string(0), "osu"); + assert_eq!(ruleset_string(1), "taiko"); + assert_eq!(ruleset_string(2), "catch"); + assert_eq!(ruleset_string(3), "mania"); + assert_eq!(ruleset_string(99), "unknown"); + } + + #[test] + fn ruleset_aliases_only_for_catch() { + assert_eq!(ruleset_aliases(0), None); + assert_eq!(ruleset_aliases(2), Some(vec!["ctb".to_string()])); + assert_eq!(ruleset_aliases(3), None); + } + + #[test] + fn hit_objects_circle_minimal() { + let text = "[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:\r\n"; + let v = parse_hit_objects_section(text); + assert_eq!(v.len(), 1); + let h = &v[0]; + assert_eq!(h.object_index, 0); + assert_eq!(h.x, 256); + assert_eq!(h.y, 192); + assert_eq!(h.time_ms, 1000); + assert_eq!(h.type_flags, 1); + assert_eq!(h.hit_sound_flags, 0); + assert_eq!(h.common_kind, HitObjectCommonKind::Circle); + assert!(!h.is_new_combo); + assert_eq!(h.hit_sample_raw.as_deref(), Some("0:0:0:0:")); + assert_eq!(h.parse_status, "ok"); + assert_eq!(h.end_time_ms, None); + assert!(h.slider.is_none()); + } + + #[test] + fn hit_objects_slider_full_tail() { + // Linear slider, 1 slide, 100px, edges + sets + hit sample. + let text = "[HitObjects]\r\n100,100,2000,2,0,L|200:200,1,100,2|0,0:0|0:0,0:0:0:0:\r\n"; + let v = parse_hit_objects_section(text); + assert_eq!(v.len(), 1); + let h = &v[0]; + assert_eq!(h.common_kind, HitObjectCommonKind::Slider); + assert_eq!(h.parse_status, "ok"); + let s = h.slider.as_ref().expect("slider populated"); + assert_eq!(s.curve_type, "L"); + assert_eq!(s.control_points, vec![(200, 200)]); + assert_eq!(s.repeats, 1); + assert_eq!(s.pixel_length, 100.0); + assert_eq!(s.edge_sounds_raw.as_deref(), Some("2|0")); + assert_eq!(s.edge_sets_raw.as_deref(), Some("0:0|0:0")); + assert_eq!(h.hit_sample_raw.as_deref(), Some("0:0:0:0:")); + } + + #[test] + fn hit_objects_slider_bezier_multi_anchor() { + // Bezier curve with 3 explicit control points (after head). + let text = "[HitObjects]\r\n50,50,2500,2,0,B|100:100|150:50|150:50|200:100,2,150\r\n"; + let v = parse_hit_objects_section(text); + let s = v[0].slider.as_ref().unwrap(); + assert_eq!(s.curve_type, "B"); + assert_eq!( + s.control_points, + vec![(100, 100), (150, 50), (150, 50), (200, 100)] + ); + assert_eq!(s.repeats, 2); + assert_eq!(s.pixel_length, 150.0); + // No edge sounds / hitsample on this old-style line. + assert!(s.edge_sounds_raw.is_none()); + assert!(s.edge_sets_raw.is_none()); + assert!(v[0].hit_sample_raw.is_none()); + } + + #[test] + fn hit_objects_spinner() { + let text = "[HitObjects]\r\n256,192,3000,12,0,5000,1:0:0:0:\r\n"; + let v = parse_hit_objects_section(text); + let h = &v[0]; + assert_eq!(h.common_kind, HitObjectCommonKind::Spinner); + assert!(h.is_new_combo); // type=12 = SPINNER(8) | NEW_COMBO(4) + assert_eq!(h.end_time_ms, Some(5000)); + assert_eq!(h.hit_sample_raw.as_deref(), Some("1:0:0:0:")); + } + + #[test] + fn hit_objects_mania_hold() { + // mania hold: type bit 7 = 128. Tail param "endTime:normalSet:..." + let text = "[HitObjects]\r\n64,192,1000,128,0,1500:0:0:0:0:\r\n"; + let v = parse_hit_objects_section(text); + let h = &v[0]; + assert_eq!(h.common_kind, HitObjectCommonKind::Hold); + assert_eq!(h.end_time_ms, Some(1500)); + assert_eq!(h.hit_sample_raw.as_deref(), Some("0:0:0:0:")); + } + + #[test] + fn hit_objects_combo_skip_extracted() { + // type = 1 (circle) | 4 (new_combo) | (2 << 4) (combo_skip = 2) + let tf = 1 | 4 | (2 << 4); + let line = format!("256,192,1000,{tf},0,0:0:0:0:\r\n"); + let v = parse_hit_objects_section(&format!("[HitObjects]\r\n{line}")); + assert_eq!(v[0].is_new_combo, true); + assert_eq!(v[0].combo_skip, Some(2)); + } + + #[test] + fn hit_objects_indexes_increment_in_source_order() { + let text = + "[HitObjects]\r\n10,10,1000,1,0,0:0:0:0:\r\n20,20,1100,1,0,0:0:0:0:\r\n30,30,1200,1,0,0:0:0:0:\r\n"; + let v = parse_hit_objects_section(text); + assert_eq!(v.len(), 3); + assert_eq!(v[0].object_index, 0); + assert_eq!(v[1].object_index, 1); + assert_eq!(v[2].object_index, 2); + assert_eq!(v[0].time_ms, 1000); + assert_eq!(v[2].time_ms, 1200); + } + + #[test] + fn hit_objects_short_line_skipped() { + // Less than 5 fields = unparseable; row is dropped. + let text = "[HitObjects]\r\n10,20,1000\r\n"; + let v = parse_hit_objects_section(text); + assert!(v.is_empty()); + } + + #[test] + fn hit_objects_unknown_kind_marked_partial() { + // Type byte = 0 (none of the known bits set) → Unknown. + let text = "[HitObjects]\r\n100,100,500,0,0\r\n"; + let v = parse_hit_objects_section(text); + assert_eq!(v.len(), 1); + assert_eq!(v[0].common_kind, HitObjectCommonKind::Unknown); + assert_eq!(v[0].parse_status, "partial"); + } + + #[test] + fn colours_section_parses_combo_and_overrides() { + let s = "[Colours]\r\n\ + Combo1 : 255,128,32\r\n\ + Combo2 : 100,100,100\r\n\ + SliderTrackOverride : 200,0,0\r\n\ + SliderBorder : 0,255,0\r\n"; + let c = parse_colours_section(s); + assert_eq!(c.combo_colors, vec![(255, 128, 32), (100, 100, 100)]); + assert_eq!(c.slider_track_override, Some((200, 0, 0))); + assert_eq!(c.slider_border, Some((0, 255, 0))); + assert!(!c.had_parse_failure); + } + + #[test] + fn colours_section_clamps_out_of_range_values() { + // Some old maps store color values >255; we clamp rather than reject. + let s = "[Colours]\r\nCombo1 : 300,-5,128\r\n"; + let c = parse_colours_section(s); + assert_eq!(c.combo_colors, vec![(255, 0, 128)]); + } + + #[test] + fn colours_section_skips_unknown_keys() { + let s = "[Colours]\r\nCombo1:1,2,3\r\nWeirdKey:4,5,6\r\n"; + let c = parse_colours_section(s); + assert_eq!(c.combo_colors, vec![(1, 2, 3)]); + assert!(c.slider_track_override.is_none()); + assert!(c.slider_border.is_none()); + } + + #[test] + fn colours_section_marks_failure_on_malformed_rgb() { + let s = "[Colours]\r\nCombo1:not,a,color\r\n"; + let c = parse_colours_section(s); + assert!(c.combo_colors.is_empty()); + assert!(c.had_parse_failure); + } + + #[test] + fn breaks_extracted_from_events() { + let s = "[Events]\r\n\ + 0,0,\"bg.jpg\",0,0\r\n\ + 2,1000,2000\r\n\ + Break,5000,7500\r\n\ + Sprite,Foreground,Centre,\"sb.png\",320,240\r\n\ + F,0,0,1000,0,1\r\n"; + let breaks = parse_breaks_from_events(s); + assert_eq!(breaks.len(), 2); + assert_eq!(breaks[0].start_time_ms, 1000); + assert_eq!(breaks[0].end_time_ms, 2000); + assert_eq!(breaks[1].start_time_ms, 5000); + assert_eq!(breaks[1].end_time_ms, 7500); + // Indented child commands (`F,...`) must NOT be misread as a break + // (they're under a sprite, not break events). + } + + #[test] + fn background_event_offset_extracted() { + let s = "[Events]\r\n0,0,\"bg.jpg\",16,-32\r\n"; + let bg = parse_background_event(s).expect("background event"); + assert_eq!(bg.x, Some(16)); + assert_eq!(bg.y, Some(-32)); + } + + #[test] + fn background_event_offset_optional_when_omitted() { + let s = "[Events]\r\n0,0,\"bg.jpg\"\r\n"; + let bg = parse_background_event(s).expect("background event"); + assert!(bg.x.is_none()); + assert!(bg.y.is_none()); + } + + #[test] + fn video_event_start_time_extracted() { + let s = "[Events]\r\nVideo,-1500,\"intro.mp4\"\r\n"; + let v = parse_video_event(s).expect("video event"); + assert_eq!(v.start_time_ms, Some(-1500)); + } + + #[test] + fn video_event_numeric_form() { + let s = "[Events]\r\n1,2000,\"v.mp4\"\r\n"; + let v = parse_video_event(s).expect("video event"); + assert_eq!(v.start_time_ms, Some(2000)); + } + + #[test] + fn edge_sounds_parsed_from_pipe_delimited() { + assert_eq!(parse_edge_sounds("2|0|8"), vec![2, 0, 8]); + assert_eq!(parse_edge_sounds("0"), vec![0]); + // Non-numeric tokens default to 0 (osu's lenient behavior). + assert_eq!(parse_edge_sounds("2|x|8"), vec![2, 0, 8]); + } + + #[test] + fn edge_sets_parsed_from_pipe_delimited() { + assert_eq!( + parse_edge_sets("0:0|1:0|0:0"), + vec!["0:0".to_string(), "1:0".to_string(), "0:0".to_string()] + ); + } + + #[test] + fn slider_emits_parsed_edge_lists_alongside_raw() { + // 1 slide, edge_sounds 2|0, edge_sets 0:0|1:0 + let text = "[HitObjects]\r\n100,100,2000,2,0,L|200:200,1,100,2|0,0:0|1:0,0:0:0:0:\r\n"; + let v = parse_hit_objects_section(text); + let s = v[0].slider.as_ref().unwrap(); + assert_eq!(s.edge_sounds.as_deref(), Some(&[2, 0][..])); + assert_eq!( + s.edge_sets.as_ref().map(Vec::as_slice), + Some(&["0:0".to_string(), "1:0".to_string()][..]) + ); + // Raw forms preserved for round-trip. + assert_eq!(s.edge_sounds_raw.as_deref(), Some("2|0")); + assert_eq!(s.edge_sets_raw.as_deref(), Some("0:0|1:0")); + } + + #[test] + fn slider_end_time_computed_from_pixel_length_and_active_timing() { + // Red TP at t=0 with beat_length=500ms (= 120 BPM). Slider at t=1000 + // with pixel_length=100, slides=1, no inherited TP active so SV=1.0. + // SliderMultiplier=1.4. Expected: + // slide_duration = 100 / (1.4 * 100 * 1.0) * 500 ≈ 357.14 ms + // end_time = 1000 + 357.14 ≈ 1357 + let tps_text = "[TimingPoints]\r\n0,500,4,2,1,60,1,0\r\n"; + let hos_text = "[HitObjects]\r\n100,100,1000,2,0,L|200:200,1,100,0|0,0:0|0:0,0:0:0:0:\r\n"; + let tps = parse_timing_points_section(tps_text); + let mut hos = parse_hit_objects_section(hos_text); + // Pre-condition: parser leaves slider end_time_ms unset. + assert!(hos[0].end_time_ms.is_none()); + compute_slider_end_times(&mut hos, 1.4, &tps); + let end = hos[0].end_time_ms.expect("slider end_time should be set"); + assert!( + (1355..=1359).contains(&end), + "expected slider end ~1357, got {end}" + ); + } + + #[test] + fn slider_end_time_respects_inherited_sv_doubler() { + // Red TP at 0 with beat_length=500ms, green TP at 1500 with + // beat_length=-50 (= 2x SV). Slider at 2000 with pixel_length=100, + // slides=1, SliderMultiplier=1.0: + // slide_duration = 100 / (1.0 * 100 * 2.0) * 500 = 250 ms + // end_time = 2000 + 250 = 2250 + let tps_text = "[TimingPoints]\r\n0,500,4,2,1,60,1,0\r\n1500,-50,4,2,1,60,0,0\r\n"; + let hos_text = "[HitObjects]\r\n100,100,2000,2,0,L|200:200,1,100,0|0,0:0|0:0,0:0:0:0:\r\n"; + let tps = parse_timing_points_section(tps_text); + let mut hos = parse_hit_objects_section(hos_text); + compute_slider_end_times(&mut hos, 1.0, &tps); + assert_eq!(hos[0].end_time_ms, Some(2250)); + } + + #[test] + fn slider_end_time_handles_repeats() { + // Same as the basic case but slides=3 (two repeats). Total duration + // triples. + let tps_text = "[TimingPoints]\r\n0,500,4,2,1,60,1,0\r\n"; + let hos_text = + "[HitObjects]\r\n100,100,1000,2,0,L|200:200,3,100,0|0|0|0,0:0|0:0|0:0|0:0,0:0:0:0:\r\n"; + let tps = parse_timing_points_section(tps_text); + let mut hos = parse_hit_objects_section(hos_text); + compute_slider_end_times(&mut hos, 1.4, &tps); + let end = hos[0].end_time_ms.expect("slider end_time should be set"); + // slide_duration ≈ 357.14 ms × 3 = 1071.43 ms; end ≈ 2071. + assert!( + (2069..=2073).contains(&end), + "expected slider end ~2071, got {end}" + ); + } + + #[test] + fn slider_end_time_skipped_when_already_set() { + // Idempotency: an existing end_time_ms is left alone. + let tps_text = "[TimingPoints]\r\n0,500,4,2,1,60,1,0\r\n"; + let hos_text = "[HitObjects]\r\n100,100,1000,2,0,L|200:200,1,100,0|0,0:0|0:0,0:0:0:0:\r\n"; + let tps = parse_timing_points_section(tps_text); + let mut hos = parse_hit_objects_section(hos_text); + hos[0].end_time_ms = Some(9999); + compute_slider_end_times(&mut hos, 1.4, &tps); + assert_eq!(hos[0].end_time_ms, Some(9999)); + } + + #[test] + fn slider_end_time_skipped_for_non_sliders() { + // Spinner (type=12) has its own end_time path; circle has none. Both + // should pass through compute_slider_end_times untouched. + let tps_text = "[TimingPoints]\r\n0,500,4,2,1,60,1,0\r\n"; + let hos_text = "[HitObjects]\r\n256,192,1000,1,0,0:0:0:0:\r\n\ +256,192,2000,12,0,3000,0:0:0:0:\r\n"; + let tps = parse_timing_points_section(tps_text); + let mut hos = parse_hit_objects_section(hos_text); + compute_slider_end_times(&mut hos, 1.4, &tps); + // Circle: no end time. + assert!(hos[0].end_time_ms.is_none()); + // Spinner: end time from its own raw param, untouched by this pass. + assert_eq!(hos[1].end_time_ms, Some(3000)); + } + + #[test] + fn parse_populates_slider_end_times_end_to_end() { + // Slider at time 3500 with pixel_length=100, slides=1. Red TP at 0 + // (beat_length=500) and green TP at 1000 (beat_length=-50, SV=2.0). + // SliderMultiplier=1.4. Expected: + // slide_duration = 100 / (1.4 * 100 * 2.0) * 500 ≈ 178.57 ms + // end_time ≈ 3500 + 179 = 3679 + let osu = "osu file format v14\r\n\r\n\ +[General]\r\nAudioFilename: a.mp3\r\nMode: 0\r\n\r\n\ +[Metadata]\r\nTitle:T\r\nTitleUnicode:T\r\nArtist:A\r\nArtistUnicode:A\r\n\ +Creator:c\r\nVersion:Hard\r\nSource:\r\nTags:\r\nBeatmapID:1\r\nBeatmapSetID:1\r\n\r\n\ +[Difficulty]\r\nHPDrainRate:5\r\nCircleSize:4\r\nOverallDifficulty:6\r\n\ +ApproachRate:7\r\nSliderMultiplier:1.4\r\nSliderTickRate:1\r\n\r\n\ +[Events]\r\n[TimingPoints]\r\n0,500,4,2,1,60,1,0\r\n1000,-50,4,2,1,60,0,0\r\n\r\n\ +[HitObjects]\r\n100,100,3500,2,0,L|200:200,1,100,0|0,0:0|0:0,0:0:0:0:\r\n"; + let p = parse( + osu.as_bytes(), + "deadbeef".to_string(), + None, + None, + "test.osu".to_string(), + "test.osu".to_string(), + ); + let slider = p + .hit_objects + .iter() + .find(|h| matches!(h.common_kind, HitObjectCommonKind::Slider)) + .expect("fixture has a slider"); + let end = slider + .end_time_ms + .expect("slider end_time should be filled by parse()"); + assert!( + (3675..=3683).contains(&end), + "expected slider end ~3679, got {end}" + ); + } + + #[test] + fn hit_sample_parsed_into_typed_components() { + // normal=1, addition=2, index=3, volume=80, filename="custom.wav" + let s = parse_hit_sample_field("1:2:3:80:custom.wav").expect("hit sample"); + assert_eq!(s.normal_set, Some(1)); + assert_eq!(s.addition_set, Some(2)); + assert_eq!(s.index, Some(3)); + assert_eq!(s.volume, Some(80)); + assert_eq!(s.filename.as_deref(), Some("custom.wav")); + } + + #[test] + fn hit_sample_handles_short_fields() { + // Partial: only first three fields populated. + let s = parse_hit_sample_field("1:0:0").expect("hit sample"); + assert_eq!(s.normal_set, Some(1)); + assert_eq!(s.addition_set, Some(0)); + assert_eq!(s.index, Some(0)); + assert!(s.volume.is_none()); + assert!(s.filename.is_none()); + } + + #[test] + fn hit_sample_propagates_to_circle_via_parse_hit_objects_section() { + let text = "[HitObjects]\r\n256,192,1000,1,0,2:1:5:60:custom.wav\r\n"; + let v = parse_hit_objects_section(text); + let hs = v[0].hit_sample.as_ref().expect("hit sample populated"); + assert_eq!(hs.normal_set, Some(2)); + assert_eq!(hs.addition_set, Some(1)); + assert_eq!(hs.index, Some(5)); + assert_eq!(hs.volume, Some(60)); + assert_eq!(hs.filename.as_deref(), Some("custom.wav")); + } + + #[test] + fn fixture_with_offset_background_and_video_populates_fields() { + // Re-use FIXTURE which has `0,0,"bg.jpg",0,0` and `Video,0,...`. + let p = parse( + FIXTURE.as_bytes(), + "deadbeef".to_string(), + None, + None, + "test.osu".to_string(), + "test.osu".to_string(), + ); + let f = p.fields.expect("fields populated"); + assert_eq!(f.background_x, Some(0)); + assert_eq!(f.background_y, Some(0)); + assert_eq!(f.video_start_time_ms, Some(0)); + // FIXTURE has one break event (`2,1000,2000`). + assert_eq!(p.breaks.len(), 1); + assert_eq!(p.breaks[0].start_time_ms, 1000); + assert_eq!(p.breaks[0].end_time_ms, 2000); + } + + #[test] + fn bom_is_stripped_before_scan() { + let mut bytes = vec![0xEF, 0xBB, 0xBF]; + bytes.extend_from_slice(FIXTURE.as_bytes()); + let p = parse( + &bytes, + "x".to_string(), + None, + None, + "test.osu".to_string(), + "test.osu".to_string(), + ); + assert_ne!(p.parse_status, ParseStatus::Failed); + assert!(p.sections.iter().any(|s| s.section_name == "[General]")); + } +} diff --git a/crates/osu_indexer/src/output.rs b/crates/osu_indexer/src/output.rs new file mode 100644 index 0000000000000000000000000000000000000000..543d311449edf166e4290ddafe0053cf3d71b055 --- /dev/null +++ b/crates/osu_indexer/src/output.rs @@ -0,0 +1,177 @@ +//! NDJSON emission, junk-file filter, and media-kind classification. +//! +//! Tables emitted (matching `schemas/v1/*.schema.json`): +//! archive_revisions, set_revisions, logical_files, +//! beatmaps, osu_sections, timing_points, +//! hit_objects_common, hit_objects_{osu,taiko,catch,mania}, +//! storyboard_sources, storyboard_elements, storyboard_commands, storyboard_variables, +//! asset_references, difficulty_attributes, problems. + +use anyhow::Result; +use serde::Serialize; +use std::io::Write; + +/// Serialize `row` as JSON, splice in a `_table` field, and write a newline. +pub fn emit(table: &str, row: &T, w: &mut W) -> Result<()> { + let mut v = serde_json::to_value(row)?; + if let serde_json::Value::Object(ref mut m) = v { + m.insert( + "_table".to_string(), + serde_json::Value::String(table.to_string()), + ); + } + serde_json::to_writer(&mut *w, &v)?; + w.write_all(b"\n")?; + Ok(()) +} + +/// Junk-file filter. Matches against the casefolded +/// `path_key` (which already has the slash-normalized, NFC-normalized, +/// lowercased form) plus the basename. +/// +/// Returns `Some(pattern_label)` to log alongside the skip, or `None` if the +/// path is not junk. +pub fn match_junk(path_key: &str) -> Option<&'static str> { + let basename = path_key.rsplit('/').next().unwrap_or(path_key); + + if basename == "thumbs.db" { + return Some("Thumbs.db"); + } + if basename == "desktop.ini" { + return Some("desktop.ini"); + } + if basename == ".ds_store" { + return Some(".DS_Store"); + } + if basename.starts_with("~$") { + return Some("~$* (Office lock)"); + } + if basename.ends_with(".bak") { + return Some("*.bak"); + } + if basename.ends_with(".swp") || basename.ends_with(".swo") { + return Some("*.swp/*.swo"); + } + if basename.ends_with(".tmp") { + return Some("*.tmp"); + } + + for seg in path_key.split('/') { + match seg { + "__macosx" => return Some("__MACOSX/"), + ".git" => return Some(".git/"), + "node_modules" => return Some("node_modules/"), + _ => {} + } + } + + None +} + +/// Map an extension (lowercase, no dot) to a `media_kind` enum value. +/// Aligned with logical-file schema media kinds: +/// audio | image | video | osu | osb | text | archive | font | skin_asset | unknown. +/// +/// `skin_asset` is intentionally not assigned here — it requires reference +/// resolution to confirm a file is referenced as a skin element. +pub fn classify_media_kind(extension: Option<&str>) -> &'static str { + let Some(ext) = extension else { + return "unknown"; + }; + match ext { + "mp3" | "ogg" | "wav" | "flac" | "m4a" | "opus" | "aac" => "audio", + "jpg" | "jpeg" | "png" | "gif" | "webp" | "bmp" => "image", + "mp4" | "mkv" | "avi" | "mov" | "webm" | "flv" | "wmv" | "m4v" => "video", + "osu" => "osu", + "osb" => "osb", + "txt" | "log" | "md" | "ini" | "cfg" => "text", + "zip" | "rar" | "7z" | "tar" | "gz" => "archive", + "ttf" | "otf" | "woff" | "woff2" => "font", + _ => "unknown", + } +} + +/// Default `roles` assignment before reference resolution refines asset roles. +pub fn classify_roles(extension: Option<&str>) -> Vec { + match extension { + Some("osu") => vec!["beatmap_osu".to_string()], + Some("osb") => vec!["storyboard_osb".to_string()], + _ => vec!["unknown".to_string()], + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn match_junk_basics() { + assert_eq!(match_junk("thumbs.db"), Some("Thumbs.db")); + assert_eq!(match_junk("song/thumbs.db"), Some("Thumbs.db")); + assert_eq!(match_junk("desktop.ini"), Some("desktop.ini")); + assert_eq!(match_junk(".ds_store"), Some(".DS_Store")); + assert_eq!(match_junk("a/b/.ds_store"), Some(".DS_Store")); + assert_eq!(match_junk("__macosx/foo"), Some("__MACOSX/")); + assert_eq!(match_junk("a/__macosx/b/c"), Some("__MACOSX/")); + assert_eq!(match_junk(".git/index"), Some(".git/")); + assert_eq!( + match_junk("project/node_modules/foo"), + Some("node_modules/") + ); + assert_eq!(match_junk("foo.bak"), Some("*.bak")); + assert_eq!(match_junk("~$report.docx"), Some("~$* (Office lock)")); + assert_eq!(match_junk("foo.swp"), Some("*.swp/*.swo")); + assert_eq!(match_junk("foo.tmp"), Some("*.tmp")); + } + + #[test] + fn match_junk_negatives() { + assert_eq!(match_junk("audio.mp3"), None); + assert_eq!(match_junk("song [Hard].osu"), None); + assert_eq!(match_junk("background.jpg"), None); + // ".git" as a substring of another segment is fine. + assert_eq!(match_junk("not-git/foo.txt"), None); + // backups inside a segment that doesn't end in .bak are fine. + assert_eq!(match_junk("backup-data/foo.txt"), None); + } + + #[test] + fn classify_media_kind_known_extensions() { + assert_eq!(classify_media_kind(Some("mp3")), "audio"); + assert_eq!(classify_media_kind(Some("ogg")), "audio"); + assert_eq!(classify_media_kind(Some("jpg")), "image"); + assert_eq!(classify_media_kind(Some("png")), "image"); + assert_eq!(classify_media_kind(Some("mp4")), "video"); + assert_eq!(classify_media_kind(Some("osu")), "osu"); + assert_eq!(classify_media_kind(Some("osb")), "osb"); + assert_eq!(classify_media_kind(Some("ttf")), "font"); + assert_eq!(classify_media_kind(Some("xyz")), "unknown"); + assert_eq!(classify_media_kind(None), "unknown"); + } + + #[test] + fn emit_writes_one_line_with_table_field() { + #[derive(Serialize)] + struct Row { + a: i32, + } + let mut buf = Vec::::new(); + emit("test_table", &Row { a: 7 }, &mut buf).unwrap(); + let s = String::from_utf8(buf).unwrap(); + assert!(s.ends_with('\n')); + let v: serde_json::Value = serde_json::from_str(s.trim()).unwrap(); + assert_eq!(v["_table"], "test_table"); + assert_eq!(v["a"], 7); + } + + #[test] + fn classify_roles_recognizes_osu_and_osb() { + assert_eq!(classify_roles(Some("osu")), vec!["beatmap_osu".to_string()]); + assert_eq!( + classify_roles(Some("osb")), + vec!["storyboard_osb".to_string()] + ); + assert_eq!(classify_roles(Some("mp3")), vec!["unknown".to_string()]); + assert_eq!(classify_roles(None), vec!["unknown".to_string()]); + } +} diff --git a/crates/osu_indexer/src/paths.rs b/crates/osu_indexer/src/paths.rs new file mode 100644 index 0000000000000000000000000000000000000000..4393cb2e9c7e5fa4f5606f43da40d1205b6e1722 --- /dev/null +++ b/crates/osu_indexer/src/paths.rs @@ -0,0 +1,315 @@ +//! Path normalization, validation, and warning detection. +//! +//! Five path forms are tracked: +//! * `raw` decoded UTF-8, if decodable +//! * `raw_bytes_base64` always populated (source of truth for reconstruction) +//! * `posix` `raw` with backslashes → forward slashes +//! * `nfc` Unicode-NFC-normalized `posix` +//! * `key` casefolded `nfc` (lookup-only) +//! +//! Flags emitted (semicolon-joined into `logical_files.path_warning`): +//! path_traversal, absolute_path, invalid_unicode, unsafe_name. +//! `duplicate_path_key` and `case_collision` are detected at the archive +//! walk layer (need full member set), not here. +//! `zero_byte_file` is enforced by the junk filter; no logical_files row is +//! emitted for these so this flag is unused in practice. + +use base64::engine::general_purpose::STANDARD as B64; +use base64::Engine; +use unicode_normalization::UnicodeNormalization; + +pub const WARN_TRAVERSAL: &str = "path_traversal"; +pub const WARN_ABSOLUTE: &str = "absolute_path"; +pub const WARN_INVALID_UNICODE: &str = "invalid_unicode"; +pub const WARN_UNSAFE_NAME: &str = "unsafe_name"; + +#[derive(Debug, Clone)] +pub struct NormalizedPath { + pub raw: Option, + pub raw_bytes_base64: String, + pub posix: Option, + pub nfc: Option, + pub key: String, + pub warnings: Vec<&'static str>, + /// Set when the original ZIP entry name ends in '/' — by convention a + /// directory marker rather than a real file. + pub is_dir_marker: bool, + /// Lowercase extension (without the dot), recovered even when `posix` is + /// None — extensions are virtually always ASCII (.osu, .osb, .mp3, .jpg) + /// and survive any byte-level encoding. This is what classifies a 2008-era + /// Shift-JIS-named `Kenji Ninuma - DISCO★PRINCE [Normal].osu` as media_kind=osu. + pub extension: Option, +} + +/// Decode raw ZIP-name bytes into the five variants and run safety checks. +/// +/// Decoding is UTF-8-only: ZIP entries from osu! clients are virtually always +/// UTF-8 (post-2008 MapsetSerializer). Falling back to CP437/CP932 introduces +/// guesswork; we'd rather flag `invalid_unicode` and preserve raw bytes via +/// base64 so reconstruction is lossless. +pub fn normalize(raw_bytes: &[u8]) -> NormalizedPath { + let raw_bytes_base64 = B64.encode(raw_bytes); + let raw = std::str::from_utf8(raw_bytes).ok().map(String::from); + + let mut warnings: Vec<&'static str> = Vec::new(); + if raw.is_none() { + warnings.push(WARN_INVALID_UNICODE); + } + + let posix = raw.as_ref().map(|s| s.replace('\\', "/")); + let is_dir_marker = posix.as_deref().is_some_and(|s| s.ends_with('/')); + + if let Some(p) = posix.as_deref() { + if is_absolute(p) { + warnings.push(WARN_ABSOLUTE); + } + if has_traversal(p) { + warnings.push(WARN_TRAVERSAL); + } + if has_unsafe_chars(p) { + warnings.push(WARN_UNSAFE_NAME); + } + } + + let nfc = posix.as_deref().map(|s| s.nfc().collect::()); + + // path_key: casefolded NFC. Rust's str::to_lowercase is Unicode-aware and + // close enough for our purposes — true Unicode casefolding (which folds + // German ß → ss, etc.) requires the `caseless` crate. Osu paths are + // overwhelmingly ASCII; the few non-ASCII titles round-trip fine through + // to_lowercase(). Revisit if real collisions ever appear in problems.parquet. + // + // For undecodable bytes we fall back to a hex-prefixed key so it still + // uniquely identifies the entry (no NUL bytes, safe for joining). + let key = match nfc.as_deref() { + Some(n) => n.to_lowercase(), + None => format!("invalid:{}", hex::encode(raw_bytes)), + }; + + let extension = match posix.as_deref() { + Some(p) => extension(p), + None => extension_from_raw(raw_bytes), + }; + + NormalizedPath { + raw, + raw_bytes_base64, + posix, + nfc, + key, + warnings, + is_dir_marker, + extension, + } +} + +/// Extract a lowercase ASCII extension directly from raw ZIP-name bytes, +/// without requiring UTF-8 decoding. The strategy is conservative: we only +/// accept an extension if every byte after the final dot in the basename is +/// ASCII alphanumeric. This is enough for `.osu`, `.osb`, `.mp3`, `.jpg`, etc. +fn extension_from_raw(raw_bytes: &[u8]) -> Option { + let last_sep = raw_bytes + .iter() + .rposition(|&b| b == b'/' || b == b'\\') + .map(|i| i + 1) + .unwrap_or(0); + let basename = &raw_bytes[last_sep..]; + let dot = basename.iter().rposition(|&b| b == b'.')?; + if dot == 0 { + return None; + } + let ext = &basename[dot + 1..]; + if ext.is_empty() || !ext.iter().all(|b| b.is_ascii_alphanumeric()) { + return None; + } + // Safe: we just verified every byte is ASCII alphanumeric. + Some(std::str::from_utf8(ext).ok()?.to_ascii_lowercase()) +} + +/// True when `path_posix` looks absolute (POSIX root, Windows drive prefix, or +/// UNC/server share). Operates on the slash-normalized form. +fn is_absolute(p: &str) -> bool { + if p.starts_with('/') { + return true; + } + let bytes = p.as_bytes(); + // Windows drive: "C:" / "C:/foo". + if bytes.len() >= 2 && bytes[1] == b':' && bytes[0].is_ascii_alphabetic() { + return true; + } + false +} + +/// True when any path segment is exactly `..` (the dangerous one). +/// "..." or "..foo" are weird but not traversal. +fn has_traversal(p: &str) -> bool { + p.split('/').any(|seg| seg == "..") +} + +/// True when the path contains NUL or any C0 control character. These can't +/// be safely materialized to disk and almost always indicate corruption. +fn has_unsafe_chars(p: &str) -> bool { + p.bytes().any(|b| b < 0x20) +} + +/// Return `(aa, bb)` — the first two and next two hex chars of a SHA-256 — +/// used for sharded blob/archive paths under `sha256/aa/bb/.bin`. +pub fn shard(sha256_hex: &str) -> (String, String) { + debug_assert!(sha256_hex.len() >= 4, "sha256 hex must be ≥ 4 chars"); + (sha256_hex[0..2].to_string(), sha256_hex[2..4].to_string()) +} + +/// Lowercase extension of `path_posix` (without the dot). None if the basename +/// has no dot or only a leading dot ("dotfile"). +pub fn extension(path_posix: &str) -> Option { + let basename = path_posix.rsplit('/').next().unwrap_or(path_posix); + let dot = basename.rfind('.')?; + if dot == 0 { + return None; + } + Some(basename[dot + 1..].to_lowercase()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn ascii_plain_path() { + let n = normalize(b"audio.mp3"); + assert_eq!(n.raw.as_deref(), Some("audio.mp3")); + assert_eq!(n.posix.as_deref(), Some("audio.mp3")); + assert_eq!(n.nfc.as_deref(), Some("audio.mp3")); + assert_eq!(n.key, "audio.mp3"); + assert!(n.warnings.is_empty()); + assert!(!n.is_dir_marker); + } + + #[test] + fn backslash_to_posix() { + let n = normalize(b"sb\\Typography\\0030.png"); + assert_eq!(n.posix.as_deref(), Some("sb/Typography/0030.png")); + assert_eq!(n.key, "sb/typography/0030.png"); + assert!(n.warnings.is_empty()); + } + + #[test] + fn dir_marker_trailing_slash() { + let n = normalize(b"subdir/"); + assert!(n.is_dir_marker); + } + + #[test] + fn casefold_lookup_key() { + let a = normalize(b"Audio.MP3").key; + let b = normalize(b"audio.mp3").key; + assert_eq!(a, b); + } + + #[test] + fn nfc_normalization() { + // U+00C5 (Å precomposed) vs. U+0041 U+030A (A + combining ring). + let composed = normalize("\u{00C5}.png".as_bytes()); + let decomposed = normalize("A\u{030A}.png".as_bytes()); + assert_eq!(composed.nfc, decomposed.nfc); + assert_eq!(composed.key, decomposed.key); + } + + #[test] + fn absolute_path_posix_root() { + let n = normalize(b"/etc/passwd"); + assert!(n.warnings.contains(&WARN_ABSOLUTE)); + } + + #[test] + fn absolute_path_windows_drive() { + let n = normalize(b"C:/Windows/system32/cmd.exe"); + assert!(n.warnings.contains(&WARN_ABSOLUTE)); + } + + #[test] + fn traversal_segment() { + let n = normalize(b"foo/../etc/passwd"); + assert!(n.warnings.contains(&WARN_TRAVERSAL)); + } + + #[test] + fn dot_dot_in_filename_is_not_traversal() { + let n = normalize(b"foo/..bar.txt"); + assert!(!n.warnings.contains(&WARN_TRAVERSAL)); + } + + #[test] + fn nul_byte_unsafe() { + let n = normalize(b"foo\0bar.txt"); + assert!(n.warnings.contains(&WARN_UNSAFE_NAME)); + } + + #[test] + fn invalid_utf8() { + let n = normalize(&[0xff, 0xfe, 0xfd]); + assert!(n.raw.is_none()); + assert!(n.posix.is_none()); + assert!(n.warnings.contains(&WARN_INVALID_UNICODE)); + // Key stays unique via hex-encoded fallback. + assert!(n.key.starts_with("invalid:")); + // base64 of [0xff,0xfe,0xfd] = "//79". + assert_eq!(n.raw_bytes_base64, "//79"); + } + + #[test] + fn extension_recovered_from_undecodable_path() { + // The actual filename of beatmap 1's hardest difficulty: + // "Kenji Ninuma - DISCO\x81\x9aPRINCE (peppy) [Normal].osu" + // where \x81\x9a is Shift-JIS for ★. UTF-8 decoding fails, but the + // .osu suffix is plain ASCII so we still recover the extension. + let mut bytes = b"Kenji Ninuma - DISCO".to_vec(); + bytes.extend_from_slice(&[0x81, 0x9a]); + bytes.extend_from_slice(b"PRINCE (peppy) [Normal].osu"); + + let n = normalize(&bytes); + assert!( + n.posix.is_none(), + "Shift-JIS path should not decode as UTF-8" + ); + assert!(n.warnings.contains(&WARN_INVALID_UNICODE)); + assert_eq!(n.extension.as_deref(), Some("osu")); + } + + #[test] + fn extension_field_matches_extension_helper_for_ascii_paths() { + let n = normalize(b"Folder/song.MP3"); + assert_eq!(n.extension.as_deref(), Some("mp3")); + let n = normalize(b"README"); + assert_eq!(n.extension, None); + } + + #[test] + fn extension_simple() { + assert_eq!(extension("song.MP3").as_deref(), Some("mp3")); + assert_eq!(extension("a/b/c.OGG").as_deref(), Some("ogg")); + } + + #[test] + fn extension_no_extension() { + assert_eq!(extension("README"), None); + assert_eq!(extension("a/b/README"), None); + } + + #[test] + fn extension_dotfile() { + assert_eq!(extension(".gitignore"), None); + } + + #[test] + fn extension_double_extension_takes_last() { + assert_eq!(extension("archive.tar.gz").as_deref(), Some("gz")); + } + + #[test] + fn shard_takes_first_two_pairs() { + let (a, b) = shard("abcdef0123456789"); + assert_eq!(a, "ab"); + assert_eq!(b, "cd"); + } +} diff --git a/crates/osu_indexer/src/references.rs b/crates/osu_indexer/src/references.rs new file mode 100644 index 0000000000000000000000000000000000000000..d0335168d72eb21ebdae86e4fa55d003329be2ac --- /dev/null +++ b/crates/osu_indexer/src/references.rs @@ -0,0 +1,1034 @@ +//! Asset reference extraction + five-phase resolution. +//! +//! Reference resolution order: +//! 1. exact raw path +//! 2. slash-normalized +//! 3. unicode-NFC normalized +//! 4. casefolded +//! 5. convention-based (hitsounds — extension swap and external_or_default) +//! 6. mark `missing` / `ambiguous` / `invalid_path` +//! +//! Extraction sites: +//! * `.osu [General]` → AudioFilename +//! * `.osu [Events]` → Background (event 0), Video (event 1), +//! Sprite (4), Sample (5), Animation (6) +//! * `.osu [HitObjects]` → explicit + derived hitsound candidates +//! * `.osb [Events]` → Sprite, Sample, Animation, Video +//! +//! Hitsound conventional names that don't match the archive are +//! `external_or_default_resource`, NOT `missing` (osu falls back to skin). +//! All other unmatched references are `missing`. + +use std::collections::{BTreeSet, HashMap}; + +use unicode_normalization::UnicodeNormalization; + +use crate::hitsounds::{self, SampleSet}; +use crate::osu_parse::{ParsedBeatmap, RawHitObject, RawTimingPoint}; +use crate::storyboard_parse::{split_storyboard_fields, StoryboardParse}; + +/// A reference extracted from a source file (.osu or .osb), prior to +/// resolution against the logical_files of its set revision. +#[derive(Debug, Clone)] +pub struct ExtractedReference { + pub source_logical_file_id: String, + pub source_path: String, + pub source_section: Option, + pub source_context: String, + pub beatmap_uid: Option, + pub reference_kind: ReferenceKind, + pub raw_reference: String, + pub animation_frame_index: Option, + pub raw_line: Option, +} + +/// Reference categories matching the `reference_kind` enum in +/// `schemas/v1/references.schema.json`. +#[allow(dead_code)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum ReferenceKind { + AudioFilename, + BackgroundImage, + Video, + StoryboardSprite, + StoryboardAnimation, + StoryboardAnimationFrame, + StoryboardAudioSample, + ExplicitHitsoundSample, + DerivedCustomHitsoundSample, + CustomSkinAssetConventional, + Font, + Unknown, +} + +impl ReferenceKind { + pub fn as_str(self) -> &'static str { + match self { + Self::AudioFilename => "audio_filename", + Self::BackgroundImage => "background_image", + Self::Video => "video", + Self::StoryboardSprite => "storyboard_sprite", + Self::StoryboardAnimation => "storyboard_animation", + Self::StoryboardAnimationFrame => "storyboard_animation_frame", + Self::StoryboardAudioSample => "storyboard_audio_sample", + Self::ExplicitHitsoundSample => "explicit_hitsound_sample", + Self::DerivedCustomHitsoundSample => "derived_custom_hitsound_sample", + Self::CustomSkinAssetConventional => "custom_skin_asset_conventional", + Self::Font => "font", + Self::Unknown => "unknown", + } + } + + /// True for kinds whose conventional candidates fall back to default + /// skin resources rather than failing as `missing`. + fn is_conventional(self) -> bool { + matches!( + self, + Self::DerivedCustomHitsoundSample | Self::CustomSkinAssetConventional + ) + } +} + +/// Resolution outcomes matching the `resolution_status` enum. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ResolutionStatus { + FoundExact, + FoundSlashNormalized, + FoundUnicodeNormalized, + FoundCasefolded, + FoundByConvention, + Missing, + Ambiguous, + ExternalOrDefaultResource, + InvalidPath, +} + +impl ResolutionStatus { + pub fn as_str(self) -> &'static str { + match self { + Self::FoundExact => "found_exact", + Self::FoundSlashNormalized => "found_slash_normalized", + Self::FoundUnicodeNormalized => "found_unicode_normalized", + Self::FoundCasefolded => "found_casefolded", + Self::FoundByConvention => "found_by_convention", + Self::Missing => "missing", + Self::Ambiguous => "ambiguous", + Self::ExternalOrDefaultResource => "external_or_default_resource", + Self::InvalidPath => "invalid_path", + } + } +} + +/// One row's worth of resolved data, ready to be turned into an +/// `asset_references` Parquet row. +#[derive(Debug, Clone)] +pub struct ResolvedReference { + pub source_logical_file_id: String, + pub source_path: String, + pub source_section: Option, + pub source_context: String, + pub beatmap_uid: Option, + pub reference_kind: ReferenceKind, + pub raw_reference: String, + pub normalized_reference: String, + pub lookup_key: String, + pub resolved_logical_file_id: Option, + pub resolved_blob_sha256: Option, + pub resolved_path_posix: Option, + pub resolution_status: ResolutionStatus, + pub is_missing: bool, + pub is_ambiguous: bool, + pub raw_line: Option, +} + +/// One file entry in the resolver index. +#[derive(Debug, Clone)] +pub struct LogicalFileEntry { + pub logical_file_id: String, + pub blob_sha256: String, + pub path_raw: Option, + pub path_posix: Option, + pub path_nfc: Option, + pub path_key: String, +} + +/// Pre-built lookup index over the logical_files of one set revision. +/// +/// Each phase tier is a separate hash map so we never rebuild keys per +/// reference. The casefolded tier holds a `Vec` so we can detect +/// ambiguity when multiple distinct blobs share the same path_key. +pub struct ResolverIndex<'a> { + by_raw: HashMap<&'a str, &'a LogicalFileEntry>, + by_posix: HashMap<&'a str, &'a LogicalFileEntry>, + by_nfc: HashMap<&'a str, &'a LogicalFileEntry>, + by_key: HashMap<&'a str, Vec<&'a LogicalFileEntry>>, +} + +impl<'a> ResolverIndex<'a> { + pub fn build(entries: &'a [LogicalFileEntry]) -> Self { + let mut by_raw: HashMap<&'a str, &'a LogicalFileEntry> = HashMap::new(); + let mut by_posix: HashMap<&'a str, &'a LogicalFileEntry> = HashMap::new(); + let mut by_nfc: HashMap<&'a str, &'a LogicalFileEntry> = HashMap::new(); + let mut by_key: HashMap<&'a str, Vec<&'a LogicalFileEntry>> = HashMap::new(); + for entry in entries { + if let Some(raw) = entry.path_raw.as_deref() { + by_raw.entry(raw).or_insert(entry); + } + if let Some(posix) = entry.path_posix.as_deref() { + by_posix.entry(posix).or_insert(entry); + } + if let Some(nfc) = entry.path_nfc.as_deref() { + by_nfc.entry(nfc).or_insert(entry); + } + by_key + .entry(entry.path_key.as_str()) + .or_default() + .push(entry); + } + ResolverIndex { + by_raw, + by_posix, + by_nfc, + by_key, + } + } +} + +/// Resolve every extracted reference. Order is preserved. +pub fn resolve(refs: Vec, index: &ResolverIndex<'_>) -> Vec { + refs.into_iter().map(|r| resolve_one(r, index)).collect() +} + +fn resolve_one(ext: ExtractedReference, index: &ResolverIndex) -> ResolvedReference { + let raw = ext.raw_reference.clone(); + let normalized = normalize_for_lookup(&raw); + let lookup_key = casefold_nfc(&normalized); + + if raw.trim().is_empty() { + return finalize( + ext, + normalized, + lookup_key, + None, + ResolutionStatus::InvalidPath, + ); + } + + if matches!(ext.reference_kind, ReferenceKind::StoryboardAnimationFrame) { + let hit = ext + .animation_frame_index + .and_then(|idx| animation_frame_match_for_index(&lookup_key, idx, index)); + let status = if hit.is_some() { + ResolutionStatus::FoundByConvention + } else { + ResolutionStatus::Missing + }; + return finalize(ext, normalized, lookup_key, hit, status); + } + + let conventional = ext.reference_kind.is_conventional(); + let status_for = |default: ResolutionStatus| { + if conventional { + ResolutionStatus::FoundByConvention + } else { + default + } + }; + + // Phase 1: exact raw match. + if let Some(hit) = index.by_raw.get(raw.as_str()) { + return finalize( + ext, + normalized, + lookup_key, + Some((*hit).clone()), + status_for(ResolutionStatus::FoundExact), + ); + } + + // Phase 2: slash-normalized. + if let Some(hit) = index.by_posix.get(normalized.as_str()) { + return finalize( + ext, + normalized.clone(), + lookup_key, + Some((*hit).clone()), + status_for(ResolutionStatus::FoundSlashNormalized), + ); + } + + // Phase 3: NFC. + let nfc_form: String = normalized.nfc().collect(); + if let Some(hit) = index.by_nfc.get(nfc_form.as_str()) { + return finalize( + ext, + normalized, + lookup_key, + Some((*hit).clone()), + status_for(ResolutionStatus::FoundUnicodeNormalized), + ); + } + + // Phase 4: casefolded. Detect ambiguity (multiple distinct blobs). + if let Some(candidates) = index.by_key.get(lookup_key.as_str()) { + if !candidates.is_empty() { + let distinct_blobs: std::collections::HashSet<&str> = + candidates.iter().map(|c| c.blob_sha256.as_str()).collect(); + if distinct_blobs.len() > 1 { + let first = (*candidates[0]).clone(); + return ambiguous(ext, normalized, lookup_key, first); + } + return finalize( + ext, + normalized, + lookup_key, + Some((*candidates[0]).clone()), + status_for(ResolutionStatus::FoundCasefolded), + ); + } + } + + // Phase 5: convention extension swap (hitsound stems sometimes ship as + // .mp3 or .ogg even though .wav is the canonical name). + if conventional { + for alt_ext in &["mp3", "ogg"] { + if let Some(swapped) = swap_extension(&lookup_key, alt_ext) { + if let Some(candidates) = index.by_key.get(swapped.as_str()) { + if let Some(first) = candidates.first() { + return finalize( + ext, + normalized, + lookup_key, + Some((**first).clone()), + ResolutionStatus::FoundByConvention, + ); + } + } + } + } + // Conventional candidate without a match → external_or_default. + // Not a "missing" failure — osu falls back to the default skin. + return finalize( + ext, + normalized, + lookup_key, + None, + ResolutionStatus::ExternalOrDefaultResource, + ); + } + + // Phase 5b: storyboard animation references are patterns, not paths — + // the actual files are `<.ext>`. We don't know the + // frame count (not threaded through `ExtractedReference`), so try a + // small set of canonical suffixes and accept the first match. This + // covers the bulk of real maps: `name0.png`, `name00.png`, … + if matches!(ext.reference_kind, ReferenceKind::StoryboardAnimation) { + if let Some(hit) = animation_frame_match(&lookup_key, index) { + return finalize( + ext, + normalized, + lookup_key, + Some(hit), + ResolutionStatus::FoundByConvention, + ); + } + } + + // Phase 6: nothing matched. + finalize(ext, normalized, lookup_key, None, ResolutionStatus::Missing) +} + +/// Search for an animation-frame variant of `lookup_key`. Tries 1–4 leading +/// zero patterns (covers `0`, `00`, `000`, `0000`). +fn animation_frame_match(lookup_key: &str, index: &ResolverIndex) -> Option { + animation_frame_match_for_index(lookup_key, 0, index) +} + +fn animation_frame_match_for_index( + lookup_key: &str, + frame_index: i32, + index: &ResolverIndex, +) -> Option { + if frame_index < 0 { + return None; + } + let dot = lookup_key.rfind('.')?; + let stem = &lookup_key[..dot]; + let ext = &lookup_key[dot..]; + let mut suffixes = Vec::new(); + suffixes.push(frame_index.to_string()); + suffixes.push(format!("{frame_index:02}")); + suffixes.push(format!("{frame_index:03}")); + suffixes.push(format!("{frame_index:04}")); + suffixes.dedup(); + for suffix in suffixes { + let candidate = format!("{stem}{suffix}{ext}"); + if let Some(rows) = index.by_key.get(candidate.as_str()) { + if let Some(first) = rows.first() { + return Some((**first).clone()); + } + } + } + None +} + +fn finalize( + ext: ExtractedReference, + normalized: String, + lookup_key: String, + hit: Option, + status: ResolutionStatus, +) -> ResolvedReference { + let is_missing = matches!( + status, + ResolutionStatus::Missing | ResolutionStatus::Ambiguous | ResolutionStatus::InvalidPath + ); + ResolvedReference { + source_logical_file_id: ext.source_logical_file_id, + source_path: ext.source_path, + source_section: ext.source_section, + source_context: ext.source_context, + beatmap_uid: ext.beatmap_uid, + reference_kind: ext.reference_kind, + raw_reference: ext.raw_reference, + normalized_reference: normalized, + lookup_key, + resolved_logical_file_id: hit.as_ref().map(|h| h.logical_file_id.clone()), + resolved_blob_sha256: hit.as_ref().map(|h| h.blob_sha256.clone()), + resolved_path_posix: hit.and_then(|h| h.path_posix), + resolution_status: status, + is_missing, + is_ambiguous: false, + raw_line: ext.raw_line, + } +} + +fn ambiguous( + ext: ExtractedReference, + normalized: String, + lookup_key: String, + first: LogicalFileEntry, +) -> ResolvedReference { + ResolvedReference { + source_logical_file_id: ext.source_logical_file_id, + source_path: ext.source_path, + source_section: ext.source_section, + source_context: ext.source_context, + beatmap_uid: ext.beatmap_uid, + reference_kind: ext.reference_kind, + raw_reference: ext.raw_reference, + normalized_reference: normalized, + lookup_key, + resolved_logical_file_id: Some(first.logical_file_id), + resolved_blob_sha256: Some(first.blob_sha256), + resolved_path_posix: first.path_posix, + resolution_status: ResolutionStatus::Ambiguous, + is_missing: true, + is_ambiguous: true, + raw_line: ext.raw_line, + } +} + +fn normalize_for_lookup(raw: &str) -> String { + let trimmed = raw.trim(); + let stripped = trimmed.strip_prefix('"').unwrap_or(trimmed); + let stripped = stripped.strip_suffix('"').unwrap_or(stripped); + stripped.replace('\\', "/") +} + +fn casefold_nfc(normalized: &str) -> String { + normalized.nfc().collect::().to_lowercase() +} + +fn swap_extension(lookup_key: &str, new_ext: &str) -> Option { + let dot = lookup_key.rfind('.')?; + let stem = &lookup_key[..dot]; + Some(format!("{stem}.{new_ext}")) +} + +// --------------------------------------------------------------------------- +// Extraction +// --------------------------------------------------------------------------- + +/// Extract every reference originating from a parsed `.osu` file: AudioFilename +/// from [General], Background/Video/storyboard refs from [Events], explicit +/// hitsound filenames from [HitObjects], and conventional derived hitsound +/// candidates. +pub fn extract_from_beatmap( + parsed: &ParsedBeatmap, + set_revision_id: &str, + beatmap_uid: &str, +) -> Vec { + let mut out = Vec::new(); + let source_logical_file_id = + format!("{set_revision_id}::{}", parsed.osu_logical_file_id_suffix); + let source_path = parsed + .osu_path_posix + .clone() + .unwrap_or_else(|| parsed.osu_path_key.clone()); + let beatmap_uid_owned = beatmap_uid.to_string(); + + // [General] AudioFilename. fields is None on partial/failed parses; in + // those cases we don't have a clean AudioFilename anyway. + if let Some(fields) = parsed.fields.as_ref() { + let audio = fields.audio_filename_raw.trim(); + if !audio.is_empty() { + out.push(ExtractedReference { + source_logical_file_id: source_logical_file_id.clone(), + source_path: source_path.clone(), + source_section: Some("[General]".to_string()), + source_context: "AudioFilename".to_string(), + beatmap_uid: Some(beatmap_uid_owned.clone()), + reference_kind: ReferenceKind::AudioFilename, + raw_reference: audio.to_string(), + animation_frame_index: None, + raw_line: None, + }); + } + } + + // [Events] — walk independently of rosu so refs survive partial parses. + if let Some(events) = parsed + .sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")) + { + extract_from_events( + &events.raw_text, + &source_logical_file_id, + &source_path, + Some(beatmap_uid_owned.as_str()), + true, // include Background + Video + &mut out, + ); + } + + // [HitObjects]: explicit hitsounds + derived candidates. + let default_sample_set = parsed + .fields + .as_ref() + .map(|f| SampleSet::from_str(&f.sample_set)) + .unwrap_or(SampleSet::Auto); + extract_from_hit_objects( + &parsed.hit_objects, + &parsed.timing_points, + default_sample_set, + &source_logical_file_id, + &source_path, + Some(beatmap_uid_owned.as_str()), + &mut out, + ); + + out +} + +/// Extract references from a parsed `.osb` storyboard. `.osb`s carry no +/// AudioFilename / Background / hitsound refs — only sprite / animation / +/// sample / video event references. +pub fn extract_from_osb( + parsed: &StoryboardParse, + set_revision_id: &str, + source_logical_file_id_suffix: &str, + source_path: &str, +) -> Vec { + let mut out = Vec::new(); + let source_logical_file_id = format!("{set_revision_id}::{source_logical_file_id_suffix}"); + for elem in &parsed.elements { + let kind = match elem.element_kind.as_str() { + "sprite" => ReferenceKind::StoryboardSprite, + "animation" => ReferenceKind::StoryboardAnimation, + "sample" => ReferenceKind::StoryboardAudioSample, + "video" => ReferenceKind::Video, + _ => continue, + }; + let raw = match &elem.file_reference_raw { + Some(s) if !s.trim().is_empty() => s.clone(), + _ => continue, + }; + let context = match elem.element_kind.as_str() { + "sprite" => "storyboard_sprite", + "animation" => "storyboard_animation", + "sample" => "storyboard_audio_sample", + "video" => "video_event", + _ => "unknown", + }; + out.push(ExtractedReference { + source_logical_file_id: source_logical_file_id.clone(), + source_path: source_path.to_string(), + // .osb has only one section ([Events]), so source_section stays + // None — the schema description says "null for .osb". + source_section: None, + source_context: context.to_string(), + beatmap_uid: None, + reference_kind: kind, + raw_reference: raw, + animation_frame_index: None, + raw_line: Some(elem.raw_line.clone()), + }); + if elem.element_kind == "animation" { + push_animation_frame_references( + &mut out, + &source_logical_file_id, + source_path, + None, + None, + elem.file_reference_raw.as_deref(), + elem.frame_count, + Some(elem.raw_line.clone()), + ); + } + } + out +} + +/// Walk an `[Events]` section's raw text and extract Background / Video / +/// Sprite / Sample / Animation refs. Used by both .osu (with Background/Video +/// included) and .osb extraction paths. +fn extract_from_events( + events_text: &str, + source_logical_file_id: &str, + source_path: &str, + beatmap_uid: Option<&str>, + include_background_video: bool, + out: &mut Vec, +) { + for raw_line in events_text.lines() { + let trimmed = raw_line.trim_end_matches('\r'); + let body = trimmed.trim_start_matches([' ', '_', '\t']); + if body.is_empty() || body.starts_with("//") || body.starts_with('[') { + continue; + } + // Only depth-0 lines declare elements (and thus carry file refs). + if trimmed.len() != body.len() { + continue; + } + let parts = split_storyboard_fields(body); + if parts.is_empty() { + continue; + } + let kw = parts[0].trim(); + + // (filename_index, kind, context). + let dispatch: Option<(usize, ReferenceKind, &str)> = + if kw == "0" || kw.eq_ignore_ascii_case("Background") { + if include_background_video { + Some((2, ReferenceKind::BackgroundImage, "background_event")) + } else { + None + } + } else if kw == "1" || kw.eq_ignore_ascii_case("Video") { + if include_background_video { + Some((2, ReferenceKind::Video, "video_event")) + } else { + None + } + } else if kw == "4" || kw.eq_ignore_ascii_case("Sprite") { + Some((3, ReferenceKind::StoryboardSprite, "storyboard_sprite")) + } else if kw == "6" || kw.eq_ignore_ascii_case("Animation") { + Some(( + 3, + ReferenceKind::StoryboardAnimation, + "storyboard_animation", + )) + } else if kw == "5" || kw.eq_ignore_ascii_case("Sample") { + Some(( + 3, + ReferenceKind::StoryboardAudioSample, + "storyboard_audio_sample", + )) + } else { + None + }; + + let Some((idx, kind, context)) = dispatch else { + continue; + }; + let Some(raw_field) = parts.get(idx) else { + continue; + }; + let cleaned = clean_filename(raw_field); + if cleaned.is_empty() { + continue; + } + out.push(ExtractedReference { + source_logical_file_id: source_logical_file_id.to_string(), + source_path: source_path.to_string(), + source_section: Some("[Events]".to_string()), + source_context: context.to_string(), + beatmap_uid: beatmap_uid.map(String::from), + reference_kind: kind, + raw_reference: cleaned, + animation_frame_index: None, + raw_line: Some(trimmed.to_string()), + }); + if matches!(kind, ReferenceKind::StoryboardAnimation) { + let frame_count = parts.get(6).and_then(|s| s.trim().parse::().ok()); + push_animation_frame_references( + out, + source_logical_file_id, + source_path, + beatmap_uid, + Some("[Events]"), + parts.get(idx).map(|s| clean_filename(s)).as_deref(), + frame_count, + Some(trimmed.to_string()), + ); + } + } +} + +fn push_animation_frame_references( + out: &mut Vec, + source_logical_file_id: &str, + source_path: &str, + beatmap_uid: Option<&str>, + source_section: Option<&str>, + raw_reference: Option<&str>, + frame_count: Option, + raw_line: Option, +) { + let Some(raw) = raw_reference else { + return; + }; + if raw.trim().is_empty() { + return; + } + let Some(frame_count) = frame_count else { + return; + }; + if frame_count <= 0 { + return; + } + for frame_index in 0..frame_count { + out.push(ExtractedReference { + source_logical_file_id: source_logical_file_id.to_string(), + source_path: source_path.to_string(), + source_section: source_section.map(String::from), + source_context: format!("storyboard_animation_frame:index={frame_index}"), + beatmap_uid: beatmap_uid.map(String::from), + reference_kind: ReferenceKind::StoryboardAnimationFrame, + raw_reference: raw.to_string(), + animation_frame_index: Some(frame_index), + raw_line: raw_line.clone(), + }); + } +} + +fn extract_from_hit_objects( + hit_objects: &[RawHitObject], + timing_points: &[RawTimingPoint], + default_sample_set: SampleSet, + source_logical_file_id: &str, + source_path: &str, + beatmap_uid: Option<&str>, + out: &mut Vec, +) { + // Explicit overrides: dedup by filename per beatmap (one row per unique + // explicit filename, even if 100 hit objects use it). + let mut seen_explicit: BTreeSet = BTreeSet::new(); + for ho in hit_objects { + let Some(field) = ho.hit_sample_raw.as_deref() else { + continue; + }; + if let Some(filename) = hitsounds::explicit_from_hit_sample_field(field) { + if seen_explicit.insert(filename.clone()) { + out.push(ExtractedReference { + source_logical_file_id: source_logical_file_id.to_string(), + source_path: source_path.to_string(), + source_section: Some("[HitObjects]".to_string()), + source_context: "hit_object_hit_sample".to_string(), + beatmap_uid: beatmap_uid.map(String::from), + reference_kind: ReferenceKind::ExplicitHitsoundSample, + raw_reference: filename, + animation_frame_index: None, + raw_line: Some(ho.raw_line.clone()), + }); + } + } + } + + // Derived candidates from (sample_set, addition_set, index, hit_sound_flags). + let candidates = + hitsounds::derived_candidates_for_beatmap(hit_objects, timing_points, default_sample_set); + let mut seen_derived: BTreeSet = BTreeSet::new(); + for (filename, context) in candidates { + if seen_derived.insert(filename.clone()) { + out.push(ExtractedReference { + source_logical_file_id: source_logical_file_id.to_string(), + source_path: source_path.to_string(), + source_section: Some("[HitObjects]".to_string()), + source_context: context, + beatmap_uid: beatmap_uid.map(String::from), + reference_kind: ReferenceKind::DerivedCustomHitsoundSample, + raw_reference: filename, + animation_frame_index: None, + raw_line: None, + }); + } + } +} + +fn clean_filename(s: &str) -> String { + let t = s.trim(); + let stripped = t.strip_prefix('"').unwrap_or(t); + let stripped = stripped.strip_suffix('"').unwrap_or(stripped); + stripped.to_string() +} + +#[cfg(test)] +mod tests { + use super::*; + + fn entry(path: &str, blob: &str) -> LogicalFileEntry { + let posix = path.replace('\\', "/"); + let nfc: String = posix.nfc().collect(); + let key = nfc.to_lowercase(); + LogicalFileEntry { + logical_file_id: format!("set::{key}"), + blob_sha256: blob.to_string(), + path_raw: Some(path.to_string()), + path_posix: Some(posix), + path_nfc: Some(nfc), + path_key: key, + } + } + + fn audio_ref(raw: &str) -> ExtractedReference { + ExtractedReference { + source_logical_file_id: "set::a.osu".to_string(), + source_path: "a.osu".to_string(), + source_section: Some("[General]".to_string()), + source_context: "AudioFilename".to_string(), + beatmap_uid: Some("osu:1".to_string()), + reference_kind: ReferenceKind::AudioFilename, + raw_reference: raw.to_string(), + animation_frame_index: None, + raw_line: None, + } + } + + fn derived_ref(raw: &str) -> ExtractedReference { + ExtractedReference { + source_logical_file_id: "set::a.osu".to_string(), + source_path: "a.osu".to_string(), + source_section: Some("[HitObjects]".to_string()), + source_context: "derived_hitsound:normal-hitnormal:index=1".to_string(), + beatmap_uid: Some("osu:1".to_string()), + reference_kind: ReferenceKind::DerivedCustomHitsoundSample, + raw_reference: raw.to_string(), + animation_frame_index: None, + raw_line: None, + } + } + + #[test] + fn resolve_phase_1_exact() { + let entries = vec![entry("audio.mp3", "blob1")]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![audio_ref("audio.mp3")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundExact); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blob1")); + assert!(!r[0].is_missing); + } + + #[test] + fn resolve_phase_2_slash_normalized() { + // Archive stores forward-slash; reference uses backslash. + let entries = vec![entry("sb/typography/0030.png", "blob2")]; + let idx = ResolverIndex::build(&entries); + let mut e = audio_ref("sb\\Typography\\0030.png"); + e.reference_kind = ReferenceKind::StoryboardSprite; + let r = resolve(vec![e], &idx); + // Slash-normalize matches via casefold tier (since "Typography" ≠ + // "typography" in the slash-normalized form). + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundCasefolded); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blob2")); + } + + #[test] + fn resolve_phase_4_casefold() { + let entries = vec![entry("AUDIO.MP3", "blob3")]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![audio_ref("audio.mp3")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundCasefolded); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blob3")); + } + + #[test] + fn resolve_phase_3_unicode_normalization() { + // Archive holds NFC-precomposed, reference is NFD-decomposed. + // Composed "Å" = U+00C5; decomposed = "A" + U+030A. + let composed = format!("{}.png", "\u{00C5}"); + let decomposed = format!("{}{}.png", "A", "\u{030A}"); + let entries = vec![entry(&composed, "blob4")]; + let idx = ResolverIndex::build(&entries); + let mut r_in = audio_ref(&decomposed); + r_in.reference_kind = ReferenceKind::BackgroundImage; + let r = resolve(vec![r_in], &idx); + // Both NFC normalization and casefolding agree, so we hit the NFC + // tier first. + assert!(matches!( + r[0].resolution_status, + ResolutionStatus::FoundUnicodeNormalized | ResolutionStatus::FoundCasefolded + )); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blob4")); + } + + #[test] + fn resolve_missing_when_no_match() { + let entries = vec![entry("other.mp3", "blob5")]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![audio_ref("audio.mp3")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::Missing); + assert!(r[0].is_missing); + assert!(r[0].resolved_blob_sha256.is_none()); + } + + #[test] + fn resolve_invalid_path_for_empty_raw() { + let entries: Vec = vec![]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![audio_ref(" ")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::InvalidPath); + assert!(r[0].is_missing); + } + + #[test] + fn resolve_derived_hitsound_external_when_not_found() { + let entries = vec![entry("audio.mp3", "blob6")]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![derived_ref("normal-hitnormal.wav")], &idx); + assert_eq!( + r[0].resolution_status, + ResolutionStatus::ExternalOrDefaultResource + ); + // External-or-default is NOT a missing failure. + assert!(!r[0].is_missing); + } + + #[test] + fn resolve_derived_hitsound_found_by_convention() { + let entries = vec![entry("normal-hitnormal.wav", "blob7")]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![derived_ref("normal-hitnormal.wav")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundByConvention); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blob7")); + } + + #[test] + fn resolve_derived_hitsound_extension_swap() { + // Archive ships .ogg even though the convention names .wav. + let entries = vec![entry("normal-hitnormal.ogg", "blob8")]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![derived_ref("normal-hitnormal.wav")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundByConvention); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blob8")); + } + + #[test] + fn resolve_animation_frame_via_convention() { + // Reference points at "name.png" but the archive only has the + // frame variants "name0.png" / "name1.png". + let entries = vec![ + entry("anim/name0.png", "frame0"), + entry("anim/name1.png", "frame1"), + ]; + let idx = ResolverIndex::build(&entries); + let mut e = audio_ref("anim/name.png"); + e.reference_kind = ReferenceKind::StoryboardAnimation; + let r = resolve(vec![e], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundByConvention); + assert!(r[0].resolved_blob_sha256.is_some()); + } + + #[test] + fn resolve_animation_with_leading_zeros() { + let entries = vec![entry("sb/star_0000.png", "blobZ")]; + let idx = ResolverIndex::build(&entries); + let mut e = audio_ref("sb/star_.png"); + e.reference_kind = ReferenceKind::StoryboardAnimation; + let r = resolve(vec![e], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundByConvention); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("blobZ")); + } + + #[test] + fn resolve_animation_frame_uses_requested_frame_index() { + let entries = vec![ + entry("anim/name0.png", "frame0"), + entry("anim/name1.png", "frame1"), + ]; + let idx = ResolverIndex::build(&entries); + let mut e = audio_ref("anim/name.png"); + e.reference_kind = ReferenceKind::StoryboardAnimationFrame; + e.animation_frame_index = Some(1); + let r = resolve(vec![e], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::FoundByConvention); + assert_eq!(r[0].resolved_blob_sha256.as_deref(), Some("frame1")); + } + + #[test] + fn extract_events_keeps_comma_in_quoted_storyboard_path() { + let events = "[Events]\nSprite,Foreground,Centre,\"sb/title, part 1.png\",0,0\n"; + let mut refs = Vec::new(); + extract_from_events( + events, + "set::map.osu", + "map.osu", + Some("osu:1"), + true, + &mut refs, + ); + assert_eq!(refs.len(), 1); + assert_eq!(refs[0].raw_reference, "sb/title, part 1.png"); + } + + #[test] + fn extract_animation_emits_frame_references() { + let events = "[Events]\nAnimation,Foreground,Centre,\"sb/a,b.png\",0,0,3,50\n"; + let mut refs = Vec::new(); + extract_from_events( + events, + "set::map.osu", + "map.osu", + Some("osu:1"), + true, + &mut refs, + ); + let frame_refs: Vec<_> = refs + .iter() + .filter(|r| r.reference_kind == ReferenceKind::StoryboardAnimationFrame) + .collect(); + assert_eq!(frame_refs.len(), 3); + assert_eq!(frame_refs[2].animation_frame_index, Some(2)); + assert_eq!(frame_refs[0].raw_reference, "sb/a,b.png"); + } + + #[test] + fn resolve_ambiguous_when_two_distinct_blobs_share_path_key() { + // Two physical files differing only in case, with different blob shas. + let entries = vec![ + LogicalFileEntry { + logical_file_id: "set::audio.mp3".to_string(), + blob_sha256: "blobA".to_string(), + path_raw: Some("Audio.mp3".to_string()), + path_posix: Some("Audio.mp3".to_string()), + path_nfc: Some("Audio.mp3".to_string()), + path_key: "audio.mp3".to_string(), + }, + LogicalFileEntry { + logical_file_id: "set::audio.mp3".to_string(), + blob_sha256: "blobB".to_string(), + path_raw: Some("AUDIO.mp3".to_string()), + path_posix: Some("AUDIO.mp3".to_string()), + path_nfc: Some("AUDIO.mp3".to_string()), + path_key: "audio.mp3".to_string(), + }, + ]; + let idx = ResolverIndex::build(&entries); + let r = resolve(vec![audio_ref("audio.mp3")], &idx); + assert_eq!(r[0].resolution_status, ResolutionStatus::Ambiguous); + assert!(r[0].is_ambiguous); + assert!(r[0].is_missing); + } +} diff --git a/crates/osu_indexer/src/rows.rs b/crates/osu_indexer/src/rows.rs new file mode 100644 index 0000000000000000000000000000000000000000..4f5860bb97eade31506e2473969baa7198753ef2 --- /dev/null +++ b/crates/osu_indexer/src/rows.rs @@ -0,0 +1,448 @@ +//! Serde structs for every NDJSON row the indexer emits. +//! +//! Each struct mirrors a Parquet table defined in `schemas/v1/`. The +//! `output::emit` helper splices a `_table` discriminator into the JSON object +//! at write time, so these structs do not carry it. +//! +//! Timestamps are i64 unix milliseconds. The Python orchestrator converts to +//! PyArrow `timestamp[ms]` when writing Parquet. + +use serde::Serialize; + +#[derive(Serialize, Debug, Clone)] +pub struct ArchiveRevisionRow { + pub archive_revision_id: String, + pub archive_sha256: String, + pub archive_path: String, + pub original_filename: Option, + pub size_bytes: i64, + pub member_count: i32, + pub zip_comment: Option, + pub zip_warning: Option, + pub source_kind: Option, + pub source_url: Option, + pub ingested_at: i64, + pub ingest_batch_id: String, + pub ingest_tool_version: String, + pub schema_version: String, + pub ingest_decision: String, + pub ingest_decision_reason: Option, + pub ingest_decision_at: i64, +} + +#[derive(Serialize, Debug, Clone)] +pub struct LogicalFileRow { + pub logical_file_id: String, + pub set_revision_id: String, + pub archive_revision_id: String, + pub beatmapset_id: Option, + pub path_raw: Option, + pub path_posix: Option, + pub path_nfc: Option, + pub path_key: String, + pub path_raw_bytes_base64: Option, + pub blob_sha256: String, + pub size_bytes: i64, + pub extension: Option, + pub mime_guess: Option, + pub media_kind: String, + pub roles: Vec, + pub is_referenced: bool, + pub is_unreferenced_extra: bool, + pub crc32: Option, + pub compressed_size: Option, + pub uncompressed_size: Option, + pub zip_mtime: Option, + pub path_warning: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct ProblemRow { + pub problem_id: String, + pub set_revision_id: String, + pub beatmap_uid: Option, + pub logical_file_id: Option, + pub severity: String, + pub category: String, + pub message: String, + pub raw_context: Option, + pub parser_name: Option, + pub parser_version: Option, + pub ingest_batch_id: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct SetRevisionRow { + pub set_revision_id: String, + pub archive_revision_id: String, + pub beatmapset_id: Option, + pub beatmapset_id_source: String, + pub title: Option, + pub title_unicode: Option, + pub artist: Option, + pub artist_unicode: Option, + pub creator: Option, + pub source: Option, + pub tags: Option>, + pub mode_set: Vec, + pub num_beatmaps: i32, + pub num_files: i32, + pub num_blobs: i32, + pub num_missing_references: i32, +} + +#[derive(Serialize, Debug, Clone)] +pub struct BeatmapRow { + pub beatmap_uid: String, + pub beatmap_id: Option, + pub beatmapset_id: Option, + pub set_revision_id: String, + pub archive_revision_id: String, + pub osu_logical_file_id: String, + pub osu_blob_sha256: String, + pub osu_path_raw: Option, + pub osu_path_posix: Option, + + pub format_version: Option, + pub mode: i8, + pub ruleset: String, + pub ruleset_aliases: Option>, + + pub title: Option, + pub title_unicode: Option, + pub artist: Option, + pub artist_unicode: Option, + pub creator: Option, + pub version: Option, + pub source: Option, + pub tags: Option>, + + pub audio_filename_raw: Option, + pub audio_lead_in_ms: Option, + pub audio_reference_id: Option, + pub audio_blob_sha256: Option, + pub background_reference_id: Option, + pub background_blob_sha256: Option, + pub background_x: Option, + pub background_y: Option, + pub video_reference_id: Option, + pub video_blob_sha256: Option, + pub video_start_time_ms: Option, + + pub hp_drain_rate: f32, + pub circle_size: f32, + pub overall_difficulty: f32, + pub approach_rate: Option, + pub slider_multiplier: Option, + pub slider_tick_rate: Option, + + pub preview_time_ms: Option, + pub countdown: Option, + pub sample_set: Option, + pub stack_leniency: Option, + pub special_style: Option, + pub widescreen_storyboard: Option, + pub letterbox_in_breaks: Option, + pub epilepsy_warning: Option, + pub samples_match_playback_rate: Option, + + pub hit_object_count: i32, + pub timing_point_count: i32, + pub break_count: i32, + pub event_count: i32, + + pub has_osb: bool, + pub has_local_storyboard: bool, + pub has_effective_storyboard: bool, + pub has_video: bool, + pub has_missing_references: bool, + + pub parser_name: String, + pub parser_version: String, + pub parse_status: String, + pub parse_error: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct OsuSectionRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub section_name: String, + pub line_index_start: i32, + pub line_index_end: i32, + pub byte_start: i64, + pub byte_end: i64, + pub raw_text: String, + pub parse_status: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct TimingPointRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub row_index: i32, + pub time_ms: f64, + pub beat_length: f64, + pub meter: Option, + pub sample_set: Option, + pub sample_index: Option, + pub volume: Option, + pub uninherited: bool, + pub effects: Option, + pub bpm: Option, + pub slider_velocity_multiplier: Option, + pub is_kiai: bool, + pub raw_line: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct HitObjectsCommonRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub ruleset: String, + /// Mania key count derived from `circle_size` (mirrors `hit_objects_mania.key_count`). + /// Sentinel `0` for non-mania rulesets so the partition tuple is well-defined. + pub key_count: i32, + pub object_index: i32, + pub x: i32, + pub y: i32, + pub time_ms: i32, + pub end_time_ms: Option, + pub type_flags: i32, + pub hit_sound_flags: i32, + pub common_object_kind: String, + pub is_new_combo: bool, + pub combo_skip: Option, + pub raw_params: Option>, + pub raw_line: String, + pub parse_status: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct HitObjectsOsuRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub object_index: i32, + pub osu_kind: String, + pub start_time_ms: i32, + pub end_time_ms: Option, + pub x: i32, + pub y: i32, + pub slider_curve_type: Option, + pub slider_control_points_json: Option, + pub slider_repeats: Option, + pub slider_pixel_length: Option, + pub edge_sounds_raw: Option, + pub edge_sets_raw: Option, + pub edge_sounds: Option>, + pub edge_sets: Option>, + pub hit_sample_raw: Option, + pub hit_sample_normal_set: Option, + pub hit_sample_addition_set: Option, + pub hit_sample_index: Option, + pub hit_sample_volume: Option, + pub hit_sample_filename: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct HitObjectsTaikoRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub object_index: i32, + pub taiko_kind: String, + pub start_time_ms: i32, + pub end_time_ms: Option, + pub is_big: bool, + pub hit_sound_flags: i32, + pub inherited_sample_set: Option, + pub sample_index: Option, + pub hit_sample_raw: Option, + pub hit_sample_normal_set: Option, + pub hit_sample_addition_set: Option, + pub hit_sample_index: Option, + pub hit_sample_volume: Option, + pub hit_sample_filename: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct HitObjectsCatchRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub object_index: i32, + pub catch_kind: String, + pub start_time_ms: i32, + pub end_time_ms: Option, + pub x: i32, + pub y: i32, + pub slider_curve_type: Option, + pub slider_control_points_json: Option, + pub slider_repeats: Option, + pub slider_pixel_length: Option, + pub hit_sample_raw: Option, + pub hit_sample_normal_set: Option, + pub hit_sample_addition_set: Option, + pub hit_sample_index: Option, + pub hit_sample_volume: Option, + pub hit_sample_filename: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct HitObjectsManiaRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub object_index: i32, + pub mania_kind: String, + pub start_time_ms: i32, + pub end_time_ms: Option, + pub x: i32, + pub column_index: i32, + pub key_count: i32, + pub circle_size: f32, + pub hit_sound_flags: i32, + pub hit_sample_raw: Option, + pub hit_sample_normal_set: Option, + pub hit_sample_addition_set: Option, + pub hit_sample_index: Option, + pub hit_sample_volume: Option, + pub hit_sample_filename: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct ColoursRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub combo_count: i32, + pub combo_colors_json: String, + pub slider_track_override_r: Option, + pub slider_track_override_g: Option, + pub slider_track_override_b: Option, + pub slider_border_r: Option, + pub slider_border_g: Option, + pub slider_border_b: Option, + pub raw_section_text: String, + pub parse_status: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct BreakRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub break_index: i32, + pub start_time_ms: i32, + pub end_time_ms: i32, + pub duration_ms: i32, + pub raw_line: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct StoryboardSourceRow { + pub storyboard_source_id: String, + pub set_revision_id: String, + pub beatmap_uid: Option, + pub scope: String, + pub source_logical_file_id: String, + pub source_path: String, + pub source_blob_sha256: String, + pub parser_name: String, + pub parser_version: String, + pub parse_status: String, + pub parse_error: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct StoryboardElementRow { + pub storyboard_element_id: String, + pub storyboard_source_id: String, + pub set_revision_id: String, + pub beatmap_uid: Option, + pub element_index: i32, + pub layer: String, + pub origin: Option, + pub element_kind: String, + pub file_reference_raw: Option, + pub file_reference_id: Option, + pub resolved_blob_sha256: Option, + pub x: Option, + pub y: Option, + pub frame_count: Option, + pub frame_delay: Option, + pub loop_type: Option, + pub sample_time_ms: Option, + pub sample_volume: Option, + pub raw_line: String, + pub parse_status: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct StoryboardCommandRow { + pub storyboard_command_id: String, + pub storyboard_element_id: String, + pub storyboard_source_id: String, + pub set_revision_id: String, + pub beatmap_uid: Option, + pub scope: String, + pub element_index: i32, + pub command_index: i32, + pub parent_command_id: Option, + pub command_code: String, + pub easing: Option, + pub start_time_ms: Option, + pub end_time_ms: Option, + pub params_json: String, + pub raw_line: String, + pub parse_status: String, +} + +#[derive(Serialize, Debug, Clone)] +pub struct StoryboardVariableRow { + pub storyboard_source_id: String, + pub set_revision_id: String, + pub beatmap_uid: Option, + pub scope: String, + pub variable_name: String, + pub raw_value: String, + pub expanded_value: Option, + pub line_index: i32, +} + +#[derive(Serialize, Debug, Clone)] +pub struct DifficultyAttributesRow { + pub beatmap_uid: String, + pub set_revision_id: String, + pub ruleset: String, + pub calculator: String, + pub calculator_version: String, + pub lazer_commit: Option, + pub tools_commit: Option, + pub mods_acronym: String, + pub mods_bitmask: Option, + pub clock_rate: Option, + pub stars: f64, + pub max_combo: Option, + pub attributes_json: String, + pub calculation_status: String, + pub calculation_error: Option, +} + +#[derive(Serialize, Debug, Clone)] +pub struct AssetReferenceRow { + pub reference_id: String, + pub set_revision_id: String, + pub beatmap_uid: Option, + pub source_logical_file_id: String, + pub source_path: String, + pub source_section: Option, + pub source_context: String, + pub reference_kind: String, + pub raw_reference: String, + pub normalized_reference: String, + pub lookup_key: String, + pub resolved_logical_file_id: Option, + pub resolved_blob_sha256: Option, + pub resolved_path_posix: Option, + pub resolution_status: String, + pub resolution_strategy: String, + pub is_missing: bool, + pub is_ambiguous: bool, + pub raw_line: Option, +} diff --git a/crates/osu_indexer/src/storyboard_parse.rs b/crates/osu_indexer/src/storyboard_parse.rs new file mode 100644 index 0000000000000000000000000000000000000000..d8bc201eac7435ecd6e94ed5fca65cf107b4a65b --- /dev/null +++ b/crates/osu_indexer/src/storyboard_parse.rs @@ -0,0 +1,1225 @@ +//! Storyboard parsing. +//! +//! Three logical scopes per beatmapset: +//! * `shared_set` — from `.osb` +//! * `difficulty_local` — from each `.osu [Events]` +//! * `effective` — computed view (shared + local), assembled downstream +//! +//! rosu-storyboard 0.1 provides a usable validity oracle but exposes +//! `CommandTimeline.commands` as `pub(crate)` and offers no accessor for +//! `[Variables]`. So we reparse the raw text ourselves — same pattern as +//! `[TimingPoints]` and `[HitObjects]` — and only call `Storyboard::from_bytes` +//! to derive `parse_status` for `.osb` sources. Variables are substituted +//! before comma-splitting (matching rosu's behavior) but the raw `[Variables]` +//! lines are preserved as their own table so round-trip stays possible. + +use std::collections::HashMap; + +use rosu_storyboard::Storyboard; + +use crate::osu_parse::{scan_sections, ParseStatus, RawSection}; + +pub const PARSER_NAME: &str = "rosu-storyboard"; +pub const PARSER_VERSION: &str = "0.1"; + +/// Logical scope of a storyboard source. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Scope { + SharedSet, + DifficultyLocal, +} + +impl Scope { + pub fn as_str(self) -> &'static str { + match self { + Scope::SharedSet => "shared_set", + Scope::DifficultyLocal => "difficulty_local", + } + } +} + +/// Outcome of parsing one storyboard source (a `.osb` file or one `.osu` +/// `[Events]` section). +#[derive(Debug, Clone)] +pub struct StoryboardParse { + pub elements: Vec, + pub commands: Vec, + pub variables: Vec, + pub parse_status: ParseStatus, + pub parse_error: Option, +} + +#[derive(Debug, Clone)] +pub struct StoryboardElement { + pub element_index: i32, + pub layer: String, + pub origin: Option, + pub element_kind: String, + pub file_reference_raw: Option, + pub x: Option, + pub y: Option, + pub frame_count: Option, + pub frame_delay: Option, + pub loop_type: Option, + pub sample_time_ms: Option, + pub sample_volume: Option, + pub raw_line: String, + pub parse_status: &'static str, +} + +#[derive(Debug, Clone)] +pub struct StoryboardCommand { + pub element_index: i32, + pub command_index: i32, + pub parent_command_index: Option, + pub command_code: String, + pub easing: Option, + pub start_time_ms: Option, + pub end_time_ms: Option, + pub params_json: String, + pub raw_line: String, + pub parse_status: &'static str, +} + +#[derive(Debug, Clone)] +pub struct StoryboardVariable { + pub name: String, + pub raw_value: String, + pub line_index: i32, +} + +/// Parse a `.osb` file. Looks at both `[Variables]` and `[Events]` sections. +/// Uses `rosu_storyboard::Storyboard::from_bytes` as a validity oracle to +/// derive `parse_status`. +pub fn parse_osb(bytes: &[u8]) -> StoryboardParse { + let text = decode_for_scan(bytes); + let sections = scan_sections(&text); + + let variables = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Variables]")) + .map(|s| parse_variables_section(&s.raw_text)) + .unwrap_or_default(); + + let var_map: HashMap = variables + .iter() + .map(|v| (v.name.clone(), v.raw_value.clone())) + .collect(); + + let (elements, commands) = sections + .iter() + .find(|s| s.section_name.eq_ignore_ascii_case("[Events]")) + .map(|s| parse_events_section(s, &var_map)) + .unwrap_or_default(); + + let (parse_status, parse_error) = match Storyboard::from_bytes(bytes) { + Ok(_) => (ParseStatus::Ok, None), + Err(e) => { + // rosu-storyboard rejected, but our scan may still have produced + // rows — partial vs failed depends on whether anything came out. + let status = if !elements.is_empty() || !commands.is_empty() { + ParseStatus::Partial + } else { + ParseStatus::Failed + }; + (status, Some(e.to_string())) + } + }; + + StoryboardParse { + elements, + commands, + variables, + parse_status, + parse_error, + } +} + +/// Parse the `[Events]` section of a `.osu` file as a difficulty-local +/// storyboard. The `.osu` itself was already validated by `rosu-map`, so we +/// only run our raw scan and skip the rosu-storyboard re-validation. +/// +/// `events_section_text` is the raw text of the section as produced by +/// `osu_parse::scan_sections` — it includes the `[Events]` header line. +pub fn parse_difficulty_local(events_section_text: &str) -> StoryboardParse { + // Build a synthetic RawSection so we can reuse the events parser. + let synthetic = RawSection { + section_name: "[Events]".to_string(), + line_index_start: 0, + line_index_end: 0, + byte_start: 0, + byte_end: 0, + raw_text: events_section_text.to_string(), + parse_status: "ok".to_string(), + }; + // .osu files have no [Variables] section — that's .osb-only per the wiki. + let (elements, commands) = parse_events_section(&synthetic, &HashMap::new()); + + let parse_status = if elements.is_empty() && commands.is_empty() { + ParseStatus::Failed + } else { + ParseStatus::Ok + }; + + StoryboardParse { + elements, + commands, + variables: Vec::new(), + parse_status, + parse_error: None, + } +} + +fn decode_for_scan(bytes: &[u8]) -> String { + let text = String::from_utf8_lossy(bytes); + let stripped = text.strip_prefix('\u{FEFF}').unwrap_or(&text); + stripped.to_string() +} + +/// Parse a `[Variables]` section into ordered `StoryboardVariable` rows. +/// Each line is `$name=value` — names start with `$` and values may contain +/// commas (e.g. `$colour_green=0,255,0`), so we split only on the *first* `=`. +pub fn parse_variables_section(section_text: &str) -> Vec { + let mut out = Vec::new(); + for (line_index, line) in section_text.lines().enumerate() { + let trimmed = line.trim_end_matches('\r'); + let body = trimmed.trim_start_matches([' ', '_', '\t']); + if body.is_empty() || body.starts_with("//") || body.starts_with('[') { + continue; + } + // Split only on the first '=' so values containing '=' are kept intact. + let Some((name, value)) = body.split_once('=') else { + continue; + }; + let name = name.trim(); + if name.is_empty() { + continue; + } + out.push(StoryboardVariable { + name: name.to_string(), + raw_value: value.to_string(), + line_index: line_index as i32, + }); + } + out +} + +/// Parse a `[Events]` section into element + command rows. `vars` is the +/// `$name -> raw_value` map (empty for `.osu`-local storyboards). +fn parse_events_section( + section: &RawSection, + vars: &HashMap, +) -> (Vec, Vec) { + let mut elements: Vec = Vec::new(); + let mut commands: Vec = Vec::new(); + let mut current_element_index: i32 = -1; + let mut last_compound_idx: Option = None; + + for (line_idx, raw_line) in section.raw_text.lines().enumerate() { + // Skip the bracketed header itself (always the first line of the + // section as produced by scan_sections). + if line_idx == 0 && raw_line.trim_start().starts_with('[') { + continue; + } + let line = raw_line.trim_end_matches('\r'); + if line.is_empty() { + continue; + } + // Comments may appear at any depth; "//" starts a comment regardless + // of leading whitespace. + let after_indent = line.trim_start_matches([' ', '_', '\t']); + if after_indent.is_empty() || after_indent.starts_with("//") { + continue; + } + + let depth = line.len() - after_indent.len(); + let body_substituted = substitute_variables(after_indent, vars); + + if depth == 0 { + // Element declaration. Background (0/Background) and Break + // (2/Break) and Color (3) are metadata, not storyboard elements, + // so we skip them but reset the compound parent. + last_compound_idx = None; + if let Some(elem) = parse_element_line(&body_substituted, line.to_string()) { + let next_idx = elements.len() as i32; + let mut elem_with_idx = elem; + elem_with_idx.element_index = next_idx; + elements.push(elem_with_idx); + current_element_index = next_idx; + } else { + // Background/Break/Color/unknown declaration — no row, but + // any subsequent indented commands have no parent element. + current_element_index = -1; + } + } else { + // Command line. Orphan commands (no element above) are dropped: + // there's nothing to attach them to. + if current_element_index < 0 { + continue; + } + let cmd_idx = commands.len() as i32; + // Direct depth-1 commands belong to the element; depth>=2 + // commands belong to the most recent depth-1 L/T compound. + let parent_idx = if depth == 1 { None } else { last_compound_idx }; + let cmd = parse_command_line( + &body_substituted, + current_element_index, + cmd_idx, + parent_idx, + line.to_string(), + ); + // Track L/T as the active compound parent for the next nested block. + // Any non-compound depth-1 command resets the active compound. + if depth == 1 { + if cmd.command_code == "L" || cmd.command_code == "T" { + last_compound_idx = Some(cmd_idx); + } else { + last_compound_idx = None; + } + } + commands.push(cmd); + } + } + + (elements, commands) +} + +/// Replace `$varname` occurrences in `line` using `vars`, repeating until no +/// more substitutions happen (matches rosu-storyboard's `decode_variables`). +/// Variable names per the wiki include the leading `$` and may not contain +/// `=` or whitespace; we preserve that by storing the literal key from the +/// `[Variables]` section. +/// +/// Each pass replaces ALL occurrences of EVERY known variable (single-pass +/// flat expansion); the outer 16-pass cap exists to bound the case where a +/// variable's value itself contains another variable token, which needs an +/// extra pass to resolve. +/// +/// Defensive length cap: if substitution would push the working string past +/// `MAX_SUBSTITUTED_LINE_BYTES` (10 MiB), we abort that pass and return the +/// pre-pass string. This bounds the worst case where a self-referential +/// variable like `$x = "$x foo"` would otherwise grow `s` exponentially per +/// pass and OOM the indexer mid-chunk on a malicious or pathological `.osb`. +fn substitute_variables(line: &str, vars: &HashMap) -> String { + const MAX_SUBSTITUTED_LINE_BYTES: usize = 10 * 1024 * 1024; + if vars.is_empty() || !line.contains('$') { + return line.to_string(); + } + let mut s = line.to_string(); + for _ in 0..16 { + if !s.contains('$') { + break; + } + let mut changed = false; + for (key, value) in vars.iter() { + if !s.contains(key.as_str()) { + continue; + } + // Cheap upper bound: if every occurrence expanded to `value` would + // exceed the cap, bail before allocating. `s.replace` builds a new + // String, so we want to avoid the alloc, not just guard the result. + let occurrences = s.matches(key.as_str()).count(); + let key_len = key.len(); + let val_len = value.len(); + let projected_len = if val_len > key_len { + s.len() + .saturating_add(occurrences.saturating_mul(val_len - key_len)) + } else { + s.len() + }; + if projected_len > MAX_SUBSTITUTED_LINE_BYTES { + // Stop expanding; the partially-substituted `s` is what + // downstream sees. raw_line on the row preserves the + // pre-substitution form for traceability. + return s; + } + s = s.replace(key, value); + changed = true; + } + if !changed { + break; + } + } + s +} + +/// Parse one element-declaration line. Returns `None` for Background, Break, +/// and Color event types (not storyboard elements). `raw_line` is preserved +/// pre-variable-substitution. +fn parse_element_line(body: &str, raw_line: String) -> Option { + let parts = split_storyboard_fields(body); + if parts.is_empty() { + return None; + } + let kw = parts[0].trim(); + + // Numeric event-type prefixes: + // 0=Background, 1=Video, 2=Break, 3=Colour, 4=Sprite, 5=Sample, 6=Animation. + // Keyword prefixes: Background, Video, Break, Colour/Color, Sprite, Sample, Animation. + let kind: ElementKind = if kw.eq_ignore_ascii_case("Sprite") || kw == "4" { + ElementKind::Sprite + } else if kw.eq_ignore_ascii_case("Animation") || kw == "6" { + ElementKind::Animation + } else if kw.eq_ignore_ascii_case("Sample") || kw == "5" { + ElementKind::Sample + } else if kw.eq_ignore_ascii_case("Video") || kw == "1" { + ElementKind::Video + } else { + // Background / Break / Colour or unknown — not an element. + return None; + }; + + Some(build_element(kind, &parts, raw_line)) +} + +#[derive(Copy, Clone)] +enum ElementKind { + Sprite, + Animation, + Sample, + Video, +} + +impl ElementKind { + fn as_str(self) -> &'static str { + match self { + ElementKind::Sprite => "sprite", + ElementKind::Animation => "animation", + ElementKind::Sample => "sample", + ElementKind::Video => "video", + } + } +} + +fn build_element(kind: ElementKind, parts: &[&str], raw_line: String) -> StoryboardElement { + let mut row = StoryboardElement { + element_index: -1, // patched by caller + layer: layer_default_for(kind).to_string(), + origin: None, + element_kind: kind.as_str().to_string(), + file_reference_raw: None, + x: None, + y: None, + frame_count: None, + frame_delay: None, + loop_type: None, + sample_time_ms: None, + sample_volume: None, + raw_line, + parse_status: "ok", + }; + + match kind { + // Sprite,layer,origin,"path",x,y + ElementKind::Sprite => { + row.layer = parts + .get(1) + .map(|s| layer_name(s)) + .unwrap_or_else(|| "Background".to_string()); + row.origin = parts.get(2).map(|s| origin_name(s)); + row.file_reference_raw = parts.get(3).map(|s| clean_filename(s)); + row.x = parts.get(4).and_then(|s| s.trim().parse::().ok()); + row.y = parts.get(5).and_then(|s| s.trim().parse::().ok()); + if parts.len() < 6 { + row.parse_status = "partial"; + } + } + // Animation,layer,origin,"path",x,y,frame_count,frame_delay[,loop_type] + ElementKind::Animation => { + row.layer = parts + .get(1) + .map(|s| layer_name(s)) + .unwrap_or_else(|| "Background".to_string()); + row.origin = parts.get(2).map(|s| origin_name(s)); + row.file_reference_raw = parts.get(3).map(|s| clean_filename(s)); + row.x = parts.get(4).and_then(|s| s.trim().parse::().ok()); + row.y = parts.get(5).and_then(|s| s.trim().parse::().ok()); + row.frame_count = parts.get(6).and_then(|s| s.trim().parse::().ok()); + row.frame_delay = parts.get(7).and_then(|s| s.trim().parse::().ok()); + row.loop_type = parts.get(8).map(|s| loop_type_name(s)); + if parts.len() < 8 { + row.parse_status = "partial"; + } + } + // Sample,time,layer,"path"[,volume] + ElementKind::Sample => { + row.sample_time_ms = parts.get(1).and_then(|s| parse_int_field(s)); + row.layer = parts + .get(2) + .map(|s| layer_name(s)) + .unwrap_or_else(|| "Sample".to_string()); + row.file_reference_raw = parts.get(3).map(|s| clean_filename(s)); + row.sample_volume = parts.get(4).and_then(|s| s.trim().parse::().ok()); + if parts.len() < 4 { + row.parse_status = "partial"; + } + } + // Video,offset,"path" + ElementKind::Video => { + row.layer = "Video".to_string(); + row.sample_time_ms = parts.get(1).and_then(|s| parse_int_field(s)); + row.file_reference_raw = parts.get(2).map(|s| clean_filename(s)); + if parts.len() < 3 { + row.parse_status = "partial"; + } + } + } + + row +} + +fn layer_default_for(kind: ElementKind) -> &'static str { + match kind { + ElementKind::Video => "Video", + ElementKind::Sample => "Sample", + _ => "Background", + } +} + +/// Map a layer field (numeric or keyword) to the canonical layer name. +/// Numeric values per the wiki: 0=Background, 1=Fail, 2=Pass, 3=Foreground, +/// 4=Overlay, 5=Video. +fn layer_name(s: &str) -> String { + let t = s.trim(); + match t { + "0" => "Background".to_string(), + "1" => "Fail".to_string(), + "2" => "Pass".to_string(), + "3" => "Foreground".to_string(), + "4" => "Overlay".to_string(), + "5" => "Video".to_string(), + _ => t.to_string(), + } +} + +/// Map an origin field (numeric or keyword) to the canonical origin name. +fn origin_name(s: &str) -> String { + let t = s.trim(); + match t { + "0" => "TopLeft".to_string(), + "1" => "Centre".to_string(), + "2" => "CentreLeft".to_string(), + "3" => "TopRight".to_string(), + "4" => "BottomCentre".to_string(), + "5" => "TopCentre".to_string(), + "6" => "Custom".to_string(), + "7" => "CentreRight".to_string(), + "8" => "BottomLeft".to_string(), + "9" => "BottomRight".to_string(), + _ => t.to_string(), + } +} + +fn loop_type_name(s: &str) -> String { + let t = s.trim(); + match t { + "0" => "LoopForever".to_string(), + "1" => "LoopOnce".to_string(), + _ => t.to_string(), + } +} + +/// Strip the optional surrounding double-quotes from a path field. Quotes are +/// optional in the file format unless the path contains spaces. +fn clean_filename(s: &str) -> String { + let t = s.trim(); + let stripped = t.strip_prefix('"').unwrap_or(t); + let stripped = stripped.strip_suffix('"').unwrap_or(stripped); + stripped.to_string() +} + +/// Parse one command line. The body has been variable-substituted already and +/// stripped of its leading `[ _]+` indentation. +fn parse_command_line( + body: &str, + element_index: i32, + command_index: i32, + parent_command_index: Option, + raw_line: String, +) -> StoryboardCommand { + let parts = split_storyboard_fields(body); + let cmd = parts.first().map(|s| s.trim()).unwrap_or(""); + let mut row = StoryboardCommand { + element_index, + command_index, + parent_command_index, + command_code: cmd.to_string(), + easing: None, + start_time_ms: None, + end_time_ms: None, + params_json: "{}".to_string(), + raw_line, + parse_status: "ok", + }; + + match cmd { + // L,start_time,loop_count + "L" => { + row.start_time_ms = parts.get(1).and_then(|s| parse_int_field(s)); + let loop_count = parts.get(2).and_then(|s| s.trim().parse::().ok()); + row.params_json = match loop_count { + Some(n) => format!("{{\"loop_count\":{n}}}"), + None => { + row.parse_status = "partial"; + "{}".to_string() + } + }; + if row.start_time_ms.is_none() { + row.parse_status = "partial"; + } + } + // T,trigger_name,start_time,end_time[,group_num] + "T" => { + let trigger_name = parts.get(1).map(|s| s.trim().to_string()); + row.start_time_ms = parts.get(2).and_then(|s| parse_int_field(s)); + row.end_time_ms = parts.get(3).and_then(|s| parse_int_field(s)); + let group_num = parts + .get(4) + .and_then(|s| s.trim().parse::().ok()) + .unwrap_or(0); + row.params_json = match trigger_name { + Some(name) => format!( + "{{\"trigger_name\":{},\"group_num\":{group_num}}}", + json_string(&name) + ), + None => { + row.parse_status = "partial"; + "{}".to_string() + } + }; + if row.start_time_ms.is_none() { + row.parse_status = "partial"; + } + } + // P,easing,start_time,end_time,flag (flag in {H, V, A}) + "P" => { + row.easing = parts.get(1).and_then(|s| s.trim().parse::().ok()); + row.start_time_ms = parts.get(2).and_then(|s| parse_int_field(s)); + row.end_time_ms = parts + .get(3) + .and_then(|s| parse_int_field(s)) + .or(row.start_time_ms); + let flag = parts + .get(4) + .map(|s| s.trim().to_string()) + .unwrap_or_default(); + if flag.is_empty() { + row.parse_status = "partial"; + } + row.params_json = format!("{{\"flag\":{}}}", json_string(&flag)); + } + // F, MX, MY, S, R: scalar values (1 per endpoint) + "F" | "MX" | "MY" | "S" | "R" => { + row.easing = parts.get(1).and_then(|s| s.trim().parse::().ok()); + row.start_time_ms = parts.get(2).and_then(|s| parse_int_field(s)); + // end_time defaults to start_time when omitted (per shorthand). + row.end_time_ms = parts + .get(3) + .and_then(|s| { + let t = s.trim(); + if t.is_empty() { + None + } else { + parse_int_field(t) + } + }) + .or(row.start_time_ms); + let values: Vec = parts[parts.len().min(4)..] + .iter() + .filter_map(|s| s.trim().parse::().ok()) + .collect(); + if values.is_empty() { + row.parse_status = "partial"; + } + row.params_json = format!( + "{{\"values\":[{}]}}", + values + .iter() + .map(|v| format_f64(*v)) + .collect::>() + .join(",") + ); + } + // M, V: 2-vector values (x, y per endpoint) + "M" | "V" => { + row.easing = parts.get(1).and_then(|s| s.trim().parse::().ok()); + row.start_time_ms = parts.get(2).and_then(|s| parse_int_field(s)); + row.end_time_ms = parts + .get(3) + .and_then(|s| { + let t = s.trim(); + if t.is_empty() { + None + } else { + parse_int_field(t) + } + }) + .or(row.start_time_ms); + let tail = if parts.len() >= 4 { &parts[4..] } else { &[] }; + let mut points: Vec<(f64, f64)> = Vec::new(); + let mut i = 0; + while i + 1 < tail.len() { + let x = tail[i].trim().parse::().ok(); + let y = tail[i + 1].trim().parse::().ok(); + if let (Some(x), Some(y)) = (x, y) { + points.push((x, y)); + } + i += 2; + } + if points.is_empty() { + row.parse_status = "partial"; + } + row.params_json = format!( + "{{\"pairs\":[{}]}}", + points + .iter() + .map(|(x, y)| format!("[{},{}]", format_f64(*x), format_f64(*y))) + .collect::>() + .join(",") + ); + } + // C: RGB triples (r, g, b per endpoint) + "C" => { + row.easing = parts.get(1).and_then(|s| s.trim().parse::().ok()); + row.start_time_ms = parts.get(2).and_then(|s| parse_int_field(s)); + row.end_time_ms = parts + .get(3) + .and_then(|s| { + let t = s.trim(); + if t.is_empty() { + None + } else { + parse_int_field(t) + } + }) + .or(row.start_time_ms); + let tail = if parts.len() >= 4 { &parts[4..] } else { &[] }; + let mut colors: Vec<(i32, i32, i32)> = Vec::new(); + let mut i = 0; + while i + 2 < tail.len() { + let r = tail[i].trim().parse::().ok().map(|v| v as i32); + let g = tail[i + 1].trim().parse::().ok().map(|v| v as i32); + let b = tail[i + 2].trim().parse::().ok().map(|v| v as i32); + if let (Some(r), Some(g), Some(b)) = (r, g, b) { + colors.push((r, g, b)); + } + i += 3; + } + if colors.is_empty() { + row.parse_status = "partial"; + } + row.params_json = format!( + "{{\"colors\":[{}]}}", + colors + .iter() + .map(|(r, g, b)| format!("[{r},{g},{b}]")) + .collect::>() + .join(",") + ); + } + _ => { + // Unknown command code — preserve raw_params for future analysis. + row.parse_status = "partial"; + let raw_params: Vec = parts.iter().skip(1).map(|s| json_string(s)).collect(); + row.params_json = format!("{{\"raw_params\":[{}]}}", raw_params.join(",")); + } + } + + row +} + +fn parse_int_field(s: &str) -> Option { + let t = s.trim(); + if t.is_empty() { + return None; + } + t.parse::().ok().map(|v| v.round() as i32) +} + +/// Split a storyboard CSV-like line on commas that are not inside double +/// quotes. Storyboard filenames are quoted when they contain spaces and can +/// also contain commas, so a plain `split(',')` corrupts valid paths. +pub fn split_storyboard_fields(line: &str) -> Vec<&str> { + let mut out = Vec::new(); + let mut start = 0usize; + let mut in_quotes = false; + for (idx, ch) in line.char_indices() { + match ch { + '"' => in_quotes = !in_quotes, + ',' if !in_quotes => { + out.push(&line[start..idx]); + start = idx + ch.len_utf8(); + } + _ => {} + } + } + out.push(&line[start..]); + out +} + +/// JSON-encode a string. Only the characters JSON requires are escaped (`"` +/// and `\\`) plus control chars; the input is small (single CSV field). +fn json_string(s: &str) -> String { + let mut out = String::with_capacity(s.len() + 2); + out.push('"'); + for c in s.chars() { + match c { + '"' => out.push_str("\\\""), + '\\' => out.push_str("\\\\"), + '\n' => out.push_str("\\n"), + '\r' => out.push_str("\\r"), + '\t' => out.push_str("\\t"), + c if (c as u32) < 0x20 => { + use std::fmt::Write; + let _ = write!(out, "\\u{:04x}", c as u32); + } + c => out.push(c), + } + } + out.push('"'); + out +} + +/// Format an f64 such that integers stay integers (`120.0` → `"120"`) and the +/// result is always JSON-parseable. `NaN` and `Infinity` collapse to `0` so +/// the row stays valid JSON; the line was already marked `partial` in that case. +fn format_f64(v: f64) -> String { + if !v.is_finite() { + return "0".to_string(); + } + if v.fract() == 0.0 && v.abs() < 1e15 { + format!("{}", v as i64) + } else { + format!("{v}") + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn variables_parses_basic() { + let s = "[Variables]\r\n$colour=0,255,0\r\n$path=\"image.png\"\r\n"; + let v = parse_variables_section(s); + assert_eq!(v.len(), 2); + assert_eq!(v[0].name, "$colour"); + assert_eq!(v[0].raw_value, "0,255,0"); + assert_eq!(v[1].name, "$path"); + assert_eq!(v[1].raw_value, "\"image.png\""); + } + + #[test] + fn variables_skips_comments_and_blanks() { + let s = "[Variables]\n\n// a comment\n$x=1\n"; + let v = parse_variables_section(s); + assert_eq!(v.len(), 1); + assert_eq!(v[0].name, "$x"); + assert_eq!(v[0].raw_value, "1"); + } + + #[test] + fn substitute_variables_replaces_repeatedly() { + let mut vars = HashMap::new(); + vars.insert("$x".to_string(), "1,2".to_string()); + vars.insert("$y".to_string(), "3,4".to_string()); + let out = substitute_variables("F,$x,$y", &vars); + assert_eq!(out, "F,1,2,3,4"); + } + + #[test] + fn substitute_variables_empty_passthrough() { + let vars = HashMap::new(); + assert_eq!(substitute_variables("F,1,2", &vars), "F,1,2"); + } + + #[test] + fn substitute_variables_replaces_every_occurrence_in_one_line() { + // Regression: storyboards often splat the same coord var across many + // M/MX command lines, e.g. `M,0,0,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t`. + // The old `s.find(key)` + `replace_range` + `break` only handled the + // first occurrence per pass and capped at 16 passes total, so lines + // with more than 16 occurrences leaked unsubstituted `$t` tokens. + let mut vars = HashMap::new(); + vars.insert("$t".to_string(), "100".to_string()); + let line = "M,0,0,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t,$t"; + let out = substitute_variables(line, &vars); + assert!( + !out.contains('$'), + "expected every $t to be substituted, got {out}" + ); + assert_eq!(out.matches("100").count(), 19); + } + + #[test] + fn substitute_variables_resolves_nested_references() { + // $a expands to a value containing $b; needs at least two passes. + let mut vars = HashMap::new(); + vars.insert("$a".to_string(), "$b,$b".to_string()); + vars.insert("$b".to_string(), "7".to_string()); + let out = substitute_variables("F,$a", &vars); + assert_eq!(out, "F,7,7"); + } + + #[test] + fn substitute_variables_caps_self_referential_growth() { + // Pathological self-reference: $x → "$x $x" would double `s` per pass + // (16 passes ⇒ 2^16 × original ≈ tens of MB per command line). The + // 10 MiB defensive cap should short-circuit before OOM. + let mut vars = HashMap::new(); + vars.insert("$x".to_string(), "$x $x".to_string()); + let out = substitute_variables("F,$x", &vars); + // Capped — the result must be <= MAX_SUBSTITUTED_LINE_BYTES (10 MiB) + // and may still contain unsubstituted `$x` tokens (that's fine; the + // raw_line on the row preserves the original). + assert!( + out.len() <= 10 * 1024 * 1024, + "expected capped output, got {} bytes", + out.len() + ); + } + + #[test] + fn substitute_variables_caps_single_huge_value() { + // A single substitution that would inflate one occurrence past the + // cap must also bail out cleanly without allocating the giant string. + let huge = "x".repeat(11 * 1024 * 1024); // 11 MiB + let mut vars = HashMap::new(); + vars.insert("$big".to_string(), huge); + let out = substitute_variables("F,$big", &vars); + // The pass aborts; output stays pre-substitution. + assert_eq!(out, "F,$big"); + } + + #[test] + fn parse_sprite_basic() { + let elem = parse_element_line( + "Sprite,Foreground,Centre,\"sb/star.png\",320,240", + "raw".to_string(), + ) + .expect("element"); + assert_eq!(elem.element_kind, "sprite"); + assert_eq!(elem.layer, "Foreground"); + assert_eq!(elem.origin.as_deref(), Some("Centre")); + assert_eq!(elem.file_reference_raw.as_deref(), Some("sb/star.png")); + assert_eq!(elem.x, Some(320.0)); + assert_eq!(elem.y, Some(240.0)); + } + + #[test] + fn parse_sprite_with_comma_in_quoted_filename() { + let elem = parse_element_line( + "Sprite,Foreground,Centre,\"sb/title, part 1.png\",320,240", + "raw".to_string(), + ) + .expect("element"); + assert_eq!( + elem.file_reference_raw.as_deref(), + Some("sb/title, part 1.png") + ); + assert_eq!(elem.x, Some(320.0)); + assert_eq!(elem.y, Some(240.0)); + } + + #[test] + fn parse_sprite_numeric_layer_and_origin() { + let elem = parse_element_line("4,3,1,bg.jpg,0,0", "raw".to_string()).expect("element"); + assert_eq!(elem.element_kind, "sprite"); + assert_eq!(elem.layer, "Foreground"); + assert_eq!(elem.origin.as_deref(), Some("Centre")); + } + + #[test] + fn parse_animation_with_loop_type() { + let elem = parse_element_line( + "Animation,Background,TopLeft,\"sb/anim.png\",100,200,8,33.33,LoopOnce", + "raw".to_string(), + ) + .expect("element"); + assert_eq!(elem.element_kind, "animation"); + assert_eq!(elem.frame_count, Some(8)); + assert!(elem.frame_delay.unwrap() > 33.0); + assert_eq!(elem.loop_type.as_deref(), Some("LoopOnce")); + } + + #[test] + fn parse_animation_default_loop_type() { + // No looptype → field stays None per format spec (defaults to LoopForever). + let elem = parse_element_line( + "Animation,Background,TopLeft,sb/anim.png,100,200,4,50", + "raw".to_string(), + ) + .expect("element"); + assert_eq!(elem.loop_type, None); + } + + #[test] + fn parse_sample_with_volume() { + let elem = parse_element_line( + "Sample,12345,Foreground,\"sb/snd.wav\",80", + "raw".to_string(), + ) + .expect("element"); + assert_eq!(elem.element_kind, "sample"); + assert_eq!(elem.sample_time_ms, Some(12345)); + assert_eq!(elem.layer, "Foreground"); + assert_eq!(elem.file_reference_raw.as_deref(), Some("sb/snd.wav")); + assert_eq!(elem.sample_volume, Some(80)); + } + + #[test] + fn parse_video_keyword() { + let elem = parse_element_line("Video,0,\"intro.mp4\"", "raw".to_string()).expect("element"); + assert_eq!(elem.element_kind, "video"); + assert_eq!(elem.layer, "Video"); + assert_eq!(elem.sample_time_ms, Some(0)); + assert_eq!(elem.file_reference_raw.as_deref(), Some("intro.mp4")); + } + + #[test] + fn parse_video_numeric() { + let elem = parse_element_line("1,0,intro.mp4", "raw".to_string()).expect("element"); + assert_eq!(elem.element_kind, "video"); + } + + #[test] + fn parse_background_returns_none() { + // Background = event type 0; not a storyboard element. + assert!(parse_element_line("0,0,\"bg.jpg\",0,0", "raw".to_string()).is_none()); + assert!(parse_element_line("Background,0,bg.jpg,0,0", "raw".to_string()).is_none()); + } + + #[test] + fn parse_break_returns_none() { + assert!(parse_element_line("Break,1000,2000", "raw".to_string()).is_none()); + assert!(parse_element_line("2,1000,2000", "raw".to_string()).is_none()); + } + + #[test] + fn parse_command_fade_full() { + let cmd = parse_command_line("F,0,1000,2000,0,1", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.command_code, "F"); + assert_eq!(cmd.easing, Some(0)); + assert_eq!(cmd.start_time_ms, Some(1000)); + assert_eq!(cmd.end_time_ms, Some(2000)); + assert_eq!(cmd.params_json, "{\"values\":[0,1]}"); + assert_eq!(cmd.parse_status, "ok"); + } + + #[test] + fn parse_command_fade_shorthand_single_value() { + // Start value only — end value is implicit equal to start (per + // shorthand). We preserve the literal value list; downstream + // consumers expand if needed. + let cmd = parse_command_line("F,0,1000,3000,1", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.start_time_ms, Some(1000)); + assert_eq!(cmd.end_time_ms, Some(3000)); + assert_eq!(cmd.params_json, "{\"values\":[1]}"); + } + + #[test] + fn parse_command_fade_shorthand_no_endtime() { + // _F,0,1000,,0.5 — empty end_time field means end_time = start_time. + let cmd = parse_command_line("F,0,1000,,0.5", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.start_time_ms, Some(1000)); + assert_eq!(cmd.end_time_ms, Some(1000)); + } + + #[test] + fn parse_command_move_pair() { + let cmd = parse_command_line("M,0,1000,2000,0,0,320,240", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.command_code, "M"); + assert_eq!(cmd.params_json, "{\"pairs\":[[0,0],[320,240]]}"); + } + + #[test] + fn split_storyboard_fields_ignores_commas_inside_quotes() { + let fields = split_storyboard_fields("Animation,Foreground,Centre,\"sb/a,b.png\",0,0,3,50"); + assert_eq!(fields[3], "\"sb/a,b.png\""); + assert_eq!(fields[6], "3"); + } + + #[test] + fn parse_command_color_triples() { + let cmd = parse_command_line( + "C,0,1000,2000,255,255,255,0,0,0", + 0, + 0, + None, + "raw".to_string(), + ); + assert_eq!(cmd.command_code, "C"); + assert_eq!(cmd.params_json, "{\"colors\":[[255,255,255],[0,0,0]]}"); + } + + #[test] + fn parse_command_parameter_flag() { + let cmd = parse_command_line("P,0,60000,62000,H", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.command_code, "P"); + assert_eq!(cmd.params_json, "{\"flag\":\"H\"}"); + } + + #[test] + fn parse_command_loop() { + let cmd = parse_command_line("L,60000,30", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.command_code, "L"); + assert_eq!(cmd.start_time_ms, Some(60000)); + assert_eq!(cmd.end_time_ms, None); + assert_eq!(cmd.params_json, "{\"loop_count\":30}"); + } + + #[test] + fn parse_command_trigger_with_group() { + let cmd = parse_command_line("T,HitSoundClap,1000,2000,3", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.command_code, "T"); + assert_eq!(cmd.start_time_ms, Some(1000)); + assert_eq!(cmd.end_time_ms, Some(2000)); + assert_eq!( + cmd.params_json, + "{\"trigger_name\":\"HitSoundClap\",\"group_num\":3}" + ); + } + + #[test] + fn parse_command_unknown_marks_partial() { + let cmd = parse_command_line("Q,1,2,3", 0, 0, None, "raw".to_string()); + assert_eq!(cmd.parse_status, "partial"); + assert!(cmd.params_json.contains("raw_params")); + } + + #[test] + fn full_section_walk_threads_indices_and_parents() { + // NOTE: keep this string on one line per chunk — Rust's `\` line + // continuation in string literals eats leading whitespace, which + // would silently destroy the indentation that drives depth detection. + let text = "[Events]\r\n".to_string() + + "//Storyboard Sound Samples\r\n" + + "Sprite,Foreground,Centre,\"sb/star.png\",320,240\r\n" + + " F,0,0,1000,0,1\r\n" + + " L,1000,5\r\n" + + " F,0,0,500,1,0\r\n" + + " F,0,500,1000,0,1\r\n" + + " R,0,1000,2000,0,3.14\r\n" + + "Sample,12000,Foreground,\"sb/snd.wav\",100\r\n"; + let section = RawSection { + section_name: "[Events]".to_string(), + line_index_start: 0, + line_index_end: 0, + byte_start: 0, + byte_end: 0, + raw_text: text.to_string(), + parse_status: "ok".to_string(), + }; + let (elements, commands) = parse_events_section(§ion, &HashMap::new()); + + assert_eq!(elements.len(), 2); + assert_eq!(elements[0].element_kind, "sprite"); + assert_eq!(elements[0].element_index, 0); + assert_eq!(elements[1].element_kind, "sample"); + assert_eq!(elements[1].element_index, 1); + assert_eq!(elements[1].sample_time_ms, Some(12000)); + + // Commands attached to sprite (#0): F, L, F, F, R. + assert_eq!(commands.len(), 5); + assert_eq!(commands[0].command_code, "F"); + assert_eq!(commands[0].element_index, 0); + assert_eq!(commands[0].parent_command_index, None); + + assert_eq!(commands[1].command_code, "L"); + assert_eq!(commands[1].parent_command_index, None); + + assert_eq!(commands[2].command_code, "F"); + assert_eq!(commands[2].parent_command_index, Some(1)); + assert_eq!(commands[3].command_code, "F"); + assert_eq!(commands[3].parent_command_index, Some(1)); + + // Depth-1 R after the L block resets the compound parent. + assert_eq!(commands[4].command_code, "R"); + assert_eq!(commands[4].parent_command_index, None); + } + + #[test] + fn variable_substitution_applies_to_commands() { + let osb = "[Variables]\r\n".to_string() + + "$col=255,128,0\r\n" + + "\r\n" + + "[Events]\r\n" + + "Sprite,Foreground,Centre,\"a.png\",0,0\r\n" + + " C,0,0,1000,$col,$col\r\n"; + let p = parse_osb(osb.as_bytes()); + assert_eq!(p.variables.len(), 1); + assert_eq!(p.elements.len(), 1); + // Color command should have parsed RGB triples after substitution. + assert_eq!(p.commands.len(), 1); + assert_eq!( + p.commands[0].params_json, + "{\"colors\":[[255,128,0],[255,128,0]]}" + ); + // raw_line preserves the $col tokens for round-trip. + assert!(p.commands[0].raw_line.contains("$col")); + } + + #[test] + fn parse_difficulty_local_minimal() { + let events = "[Events]\n".to_string() + + "//Storyboard\n" + + "Sprite,Background,Centre,\"sb.png\",320,240\n" + + " F,0,0,1000,0,1\n"; + let p = parse_difficulty_local(&events); + assert_eq!(p.parse_status, ParseStatus::Ok); + assert_eq!(p.elements.len(), 1); + assert_eq!(p.commands.len(), 1); + } + + #[test] + fn parse_difficulty_local_empty_section() { + // Just background + break events — no storyboard elements. + let events = "[Events]\n0,0,\"bg.jpg\",0,0\n2,1000,2000\n"; + let p = parse_difficulty_local(events); + assert!(p.elements.is_empty()); + assert!(p.commands.is_empty()); + assert_eq!(p.parse_status, ParseStatus::Failed); + } + + #[test] + fn osb_with_no_events_section_failed() { + let osb = "osu file format v14\r\n\r\n"; + let p = parse_osb(osb.as_bytes()); + assert!(p.elements.is_empty()); + assert_eq!(p.parse_status, ParseStatus::Ok); // rosu accepts an empty SB + } + + #[test] + fn osb_round_trip_via_rosu_validation() { + // Minimal valid .osb; rosu-storyboard should accept it. + let osb = "osu file format v14\r\n\r\n[Events]\r\n".to_string() + + "Sprite,Background,Centre,\"a.png\",320,240\r\n" + + " F,0,0,1000,0,1\r\n"; + let p = parse_osb(osb.as_bytes()); + assert_eq!(p.parse_status, ParseStatus::Ok); + assert_eq!(p.elements.len(), 1); + assert_eq!(p.commands.len(), 1); + } + + #[test] + fn comments_and_indentation_with_underscores() { + // Wiki: leading "_" or " " can both indicate command depth. + let events = "[Events]\nSprite,Foreground,Centre,\"sb.png\",100,100\n_F,0,0,1000,0,1\n__F,0,0,500,1,0\n"; + let section = RawSection { + section_name: "[Events]".to_string(), + line_index_start: 0, + line_index_end: 0, + byte_start: 0, + byte_end: 0, + raw_text: events.to_string(), + parse_status: "ok".to_string(), + }; + let (elements, commands) = parse_events_section(§ion, &HashMap::new()); + assert_eq!(elements.len(), 1); + assert_eq!(commands.len(), 2); + assert_eq!(commands[0].parent_command_index, None); + // depth-2 with no preceding L/T → parent stays None (last_compound_idx + // was never set), but the row is still emitted. + assert_eq!(commands[1].parent_command_index, None); + } +} diff --git a/docs/PIPELINE_RUNBOOK.md b/docs/PIPELINE_RUNBOOK.md index 39508ef27624c198d2d311c6bdfa67514afeb5da..6793425b7147173de3891864f1ef15fbf9242ab7 100644 --- a/docs/PIPELINE_RUNBOOK.md +++ b/docs/PIPELINE_RUNBOOK.md @@ -204,7 +204,7 @@ The validator checks: are non-empty; - no local `blobs/` or `manifests/` files exist; - no `data/v1/all_revisions/blobs` registry exists; -- `all_revisions` has no physical partition directories; +- metadata views have no physical partition directories; - the compact metadata file count stays below the configured ceiling. Deep local validation scans the compact metadata for exact archive path parity, diff --git a/osu_fetcher.toml.example b/osu_fetcher.toml.example new file mode 100644 index 0000000000000000000000000000000000000000..bf4ab5da39743f0f8388fc9cd8e42fd15ceb647f --- /dev/null +++ b/osu_fetcher.toml.example @@ -0,0 +1,18 @@ +# osu_fetcher.toml — credentials and per-mirror auth. +# +# Copy to `osu_fetcher.toml` and fill in. The real file is gitignored. +# +# Resolution order at runtime: +# 1. environment variable (e.g. OSU_CLIENT_ID), if set & non-empty +# 2. value below +# 3. error (for required fields) or skip mirror (for optional ones) + +[osu_api] +# Register at https://osu.ppy.sh/home/account/edit#oauth and copy both fields. +client_id = "" +client_secret = "" + +[mirrors.beatconnect] +# Optional. Leave empty / remove to skip beatconnect from the mirror pool. +# Get one at https://beatconnect.io/api/docs/ — used as `?token=` on /b/{id}. +api_key = "" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..6ee3cb25146a377f6af7416d6dfa3195cc0943cf --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[project] +name = "osu-everything" +version = "0.1.0" +description = "Compact osu! beatmapset archive and Parquet metadata workflow for Hugging Face buckets." +readme = "README.md" +requires-python = ">=3.12" +license = { text = "MIT OR Apache-2.0" } +authors = [{ name = "osu-everything maintainers" }] + +dependencies = [ + "pyarrow>=15", + "zstandard>=0.22", + "datasets>=2.18", + "huggingface-hub>=0.20", + "hf_transfer>=0.1.9", + "tqdm>=4.66", +] + +[project.optional-dependencies] +# Reserved for future heavier probe extras. +probe = [ +] + +[tool.uv] +# This repo is a dataset / tooling layout, not an installable Python package. +package = false diff --git a/python/deep_validate_compact_v1.py b/python/deep_validate_compact_v1.py index 681dc5c7bb3873f8597a0d8bdcd3a2976530b8f0..ff99893bfafc22e460e1512185d73c437a4fdbbe 100644 --- a/python/deep_validate_compact_v1.py +++ b/python/deep_validate_compact_v1.py @@ -24,7 +24,6 @@ from tqdm.auto import tqdm from parquet_writer import ( LATEST_TABLE_SPECS, _coerce_ms, - compute_split, derive_set_key, load_schemas, ) @@ -147,7 +146,6 @@ def _build_expected_latest( latest[set_key] = { "set_key": set_key, "set_revision_id": srid, - "split": compute_split(set_key), "first_seen_at": ts, "last_updated_at": ts, "revision_count": 1, @@ -182,11 +180,11 @@ def deep_validate_compact_v1( ) set_rows = _read_rows( all_rev / "set_revisions", - ["set_revision_id", "archive_revision_id", "split"], + ["set_revision_id", "archive_revision_id"], ) latest_rows = _read_rows( all_rev / "latest_revisions", - ["set_key", "set_revision_id", "split", "first_seen_at", "last_updated_at", "revision_count"], + ["set_key", "set_revision_id", "first_seen_at", "last_updated_at", "revision_count"], ) archive_ids = [str(r["archive_revision_id"]) for r in archive_rows] @@ -244,11 +242,6 @@ def deep_validate_compact_v1( bad_set_archive_ids = sum(1 for r in set_rows if str(r["archive_revision_id"]) not in archive_id_set) if bad_set_archive_ids: errors.append(f"{bad_set_archive_ids} set_revisions row(s) reference unknown archive_revision_id") - bad_set_splits = sum( - 1 for r in set_rows if str(r["split"]) != compute_split(derive_set_key(r)) - ) - if bad_set_splits: - errors.append(f"{bad_set_splits} set_revisions row(s) have incorrect split") latest_by_key = {str(r["set_key"]): r for r in latest_rows} if len(latest_by_key) != len(latest_rows): @@ -265,7 +258,7 @@ def deep_validate_compact_v1( if actual is None: latest_mismatches += 1 continue - for col in ("set_revision_id", "split", "revision_count"): + for col in ("set_revision_id", "revision_count"): if str(actual[col]) != str(expected[col]): latest_mismatches += 1 break diff --git a/python/ingest_osz.py b/python/ingest_osz.py index f6748cab8fd3c5eb8a4573e46a2fbf7f4ed32176..a2c7d3da18b1f4b66fc255e3f46fa049c45b182e 100644 --- a/python/ingest_osz.py +++ b/python/ingest_osz.py @@ -7,8 +7,7 @@ End-to-end pipeline (PER CHUNK): member without writing extracted blob files, parses every .osu / .osb, resolves references, computes rosu-pp difficulty attributes, and emits one NDJSON line per row tagged with ``_table``. - 2. Group rows by ``_table``; derive the ``set_shard`` partition column from - ``set_revisions``. + 2. Group rows by ``_table``. 3. Atomically write compact all-revisions Parquet files with ``archive_revisions`` deferred. 4. Atomically commit ``archive_revisions`` as the chunk commit marker. @@ -160,8 +159,8 @@ def repo_lock(repo_root: Path, force: bool = False): Stores ``\\n\\n`` in ``repo_root/.ingest.lock``. On entry, refuses to proceed if the lock already exists and points to a PID that's still alive — two concurrent ingests against the same repo - would race on the orphan-parquet GC and the latest-bucket transaction - promotion, producing duplicate rows and lost work. + would race on orphan-parquet cleanup and output file names, producing + duplicate rows or lost work. Acquisition uses ``O_CREAT | O_EXCL`` so two simultaneous launches can't both pass the existence check before either writes. Stale locks (PID no @@ -211,7 +210,7 @@ def repo_lock(repo_root: Path, force: bool = False): f"{existing_pid} (started {existing_started}). " f"Refusing to launch a second writer against {repo_root} — " f"two concurrent ingests would corrupt the dataset " - f"(orphan-parquet GC and latest-bucket promotion are not " + f"(orphan-parquet cleanup and output file names are not " f"multi-writer safe). If you are certain that PID is gone, " f"remove the lock file or pass --force-lock." ) diff --git a/python/list_batch_archives.py b/python/list_batch_archives.py new file mode 100644 index 0000000000000000000000000000000000000000..db886eb7fb8378ef86932e439ce66e4897521970 --- /dev/null +++ b/python/list_batch_archives.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +"""List raw archive CAS paths committed by a compact ingest batch.""" + +from __future__ import annotations + +import argparse +from pathlib import Path + +import pyarrow.compute as pc +import pyarrow.dataset as ds + + +def list_batch_archive_paths( + repo_root: Path, + batch_id: str, + *, + schema_version: str = "v1", +) -> list[str]: + archive_revisions = ( + repo_root + / "data" + / schema_version + / "all_revisions" + / "archive_revisions" + ) + files = [str(p) for p in sorted(archive_revisions.rglob("*.parquet"))] + if not files: + return [] + + dataset = ds.dataset(files, format="parquet") + table = dataset.to_table(columns=["ingest_batch_id", "archive_path"]) + batch_col = table["ingest_batch_id"] + mask = pc.or_( + pc.equal(batch_col, batch_id), + pc.starts_with(batch_col, f"{batch_id}-chunk-"), + ) + filtered = table.filter(mask) + paths = { + str(path) + for path in filtered["archive_path"].to_pylist() + if path and str(path).startswith("archives/") + } + return sorted(paths) + + +def parse_args(argv: list[str] | None = None) -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--repo-root", default=".") + parser.add_argument("--schema-version", default="v1") + parser.add_argument("--batch-id", required=True) + return parser.parse_args(argv) + + +def main(argv: list[str] | None = None) -> int: + args = parse_args(argv) + for path in list_batch_archive_paths( + Path(args.repo_root), + args.batch_id, + schema_version=args.schema_version, + ): + print(path) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/python/parquet_writer.py b/python/parquet_writer.py new file mode 100644 index 0000000000000000000000000000000000000000..031adc820954ee859e6825efb6232cc5206b6b05 --- /dev/null +++ b/python/parquet_writer.py @@ -0,0 +1,1003 @@ +"""Schema-driven Parquet writer for compact v1 metadata tables. + +Used by ``python/ingest_osz.py``. Consumes the NDJSON stream produced by +``crates/osu_indexer/`` (one row per line, tagged with ``_table``). + +Key contracts: +- Compact all-revisions writes use one Parquet file per table per chunk. +- Rows are sorted within each output group by the schema's ``sort_keys``. +- Every parquet is written with + ``compression='zstd', use_dictionary=True, + use_content_defined_chunking=True, write_page_index=True`` + for Xet-friendly delta uploads. +""" + +from __future__ import annotations + +import concurrent.futures +import json +import os +import sys +from collections import defaultdict +from dataclasses import dataclass +from pathlib import Path +from typing import Any, Callable, Iterator + +import pyarrow as pa +import pyarrow.parquet as pq + +from tqdm.auto import tqdm + + +# --------------------------------------------------------------------------- +# Progress logging. +# --------------------------------------------------------------------------- +# +# We use ``tqdm`` for any loop or byte-stream where the total is known up +# front, and :func:`_log` for one-off "doing X" / "done X" lines. Bars +# auto-detect TTY: in an interactive terminal they redraw in place; under +# ``tee`` they fall back to +# periodic line writes governed by ``mininterval``. + +_BAR_MININTERVAL = 1.0 + + +def _log(msg: str) -> None: + """Print ``msg`` to stderr with ``flush=True``. + + Once stderr is no longer a TTY, Python switches it to block buffering, + and a one-off "doing X" line for a long-running step stops appearing in + real time. Forcing flush per-call keeps the log live without nudging the + host terminal's buffering policy. ``tqdm`` handles its own flushing. + """ + print(msg, file=sys.stderr, flush=True) + + +def _tqdm(iterable=None, *, total=None, desc=None, unit="it", **kwargs): + """Project-wide tqdm wrapper with sensible defaults. + + ``mininterval=1.0`` keeps the bar feeling live in a TTY without flooding + a tee'd log file (one redraw per second instead of ten). ``leave=True`` + preserves the final state in captured logs. + """ + return tqdm( + iterable, + total=total, + desc=desc, + unit=unit, + file=sys.stderr, + mininterval=_BAR_MININTERVAL, + dynamic_ncols=True, + leave=True, + **kwargs, + ) + + +# --------------------------------------------------------------------------- +# Schema loading: parse JSON schema files into PyArrow schemas. +# --------------------------------------------------------------------------- + + +@dataclass(frozen=True) +class TableSchema: + name: str + columns: tuple[dict[str, Any], ...] + primary_key: tuple[str, ...] + partition_keys: tuple[str, ...] + sort_keys: tuple[str, ...] + arrow_schema: pa.Schema # full schema, including any partition columns + + def file_schema(self) -> pa.Schema: + """Schema for the on-disk parquet. + + Partition columns stay in the file body so HF ``load_dataset`` exposes + them even when it reads files from explicit ``data_files`` globs instead + of reconstructing Hive path partitions. + """ + return self.arrow_schema + + +def parse_arrow_type(spec: str) -> pa.DataType: + s = spec.strip() + if s.startswith("list<") and s.endswith(">"): + return pa.list_(parse_arrow_type(s[len("list<") : -1])) + primitives = { + "string": pa.string(), + "int8": pa.int8(), + "int16": pa.int16(), + "int32": pa.int32(), + "int64": pa.int64(), + "float32": pa.float32(), + "float64": pa.float64(), + "bool": pa.bool_(), + "timestamp[ms]": pa.timestamp("ms"), + } + if s in primitives: + return primitives[s] + raise ValueError(f"unknown type spec: {spec!r}") + + +PARTITION_FIELD_TYPES: dict[str, pa.DataType] = { + "ruleset": pa.string(), + "key_count": pa.int32(), +} + + +def load_schemas(schemas_dir: Path) -> dict[str, TableSchema]: + out: dict[str, TableSchema] = {} + for path in sorted(schemas_dir.glob("*.schema.json")): + with path.open(encoding="utf-8") as f: + doc = json.load(f) + for tname, tspec in doc.get("tables", {}).items(): + cols = tspec["columns"] + column_names = {c["name"] for c in cols} + fields = [ + pa.field( + c["name"], + parse_arrow_type(c["type"]), + nullable=bool(c.get("nullable", True)), + ) + for c in cols + ] + for key in tspec.get("partition_keys", []): + if key in column_names: + continue + field_type = PARTITION_FIELD_TYPES.get(key) + if field_type is None: + raise ValueError( + f"partition key {key!r} in table {tname!r} has no column " + "definition and no registered Arrow type" + ) + fields.append(pa.field(key, field_type, nullable=False)) + out[tname] = TableSchema( + name=tname, + columns=tuple(cols), + primary_key=tuple(tspec.get("primary_key", [])), + partition_keys=tuple(tspec.get("partition_keys", [])), + sort_keys=tuple(tspec.get("sort_keys", [])), + arrow_schema=pa.schema(fields), + ) + return out + + +# --------------------------------------------------------------------------- +# NDJSON ingestion. The Rust indexer emits one row per line with a `_table` +# discriminator added by output::emit. We split by table here. +# --------------------------------------------------------------------------- + + +def iter_ndjson(path: Path) -> Iterator[tuple[str, dict[str, Any]]]: + """Stream ``(table_name, row_dict)`` pairs; the ``_table`` key is removed.""" + with path.open("r", encoding="utf-8") as f: + for line in f: + line = line.strip() + if not line: + continue + row = json.loads(line) + table = row.pop("_table", None) + if table is None: + raise ValueError(f"row missing _table: {row!r}") + yield table, row + + +def _parse_ndjson_chunk(raw_chunk: bytes) -> tuple[dict[str, list[dict[str, Any]]], int]: + """Parse one complete-line NDJSON byte chunk. + + Kept at module top level so ``ProcessPoolExecutor`` can pickle it. + """ + by_table: dict[str, list[dict[str, Any]]] = defaultdict(list) + rows = 0 + for raw_line in raw_chunk.splitlines(): + line = raw_line.strip() + if not line: + continue + row = json.loads(line) + table = row.pop("_table", None) + if table is None: + raise ValueError(f"row missing _table: {row!r}") + by_table[table].append(row) + rows += 1 + return dict(by_table), rows + + +def _iter_complete_ndjson_chunks(path: Path, chunk_bytes: int) -> Iterator[bytes]: + """Yield byte chunks that end on NDJSON line boundaries.""" + carry = b"" + with path.open("rb") as f: + while True: + block = f.read(chunk_bytes) + if not block: + break + data = carry + block + split_at = data.rfind(b"\n") + if split_at < 0: + carry = data + continue + yield data[: split_at + 1] + carry = data[split_at + 1 :] + if carry: + yield carry + + +def _merge_grouped_rows( + target: dict[str, list[dict[str, Any]]], + grouped: dict[str, list[dict[str, Any]]], +) -> None: + for table, rows in grouped.items(): + target[table].extend(rows) + + +def group_rows_by_table(ndjson_path: Path) -> dict[str, list[dict[str, Any]]]: + """Parse the indexer's NDJSON output into ``{table_name: [row_dict, ...]}``. + + Renders a tqdm bar against the file's byte size — chunk_size=1000 NDJSON + is typically 2-5 GB and can take tens of seconds to parse on slow disks, + so a known-total bar gives an accurate ETA. The file is opened in binary + mode because text-mode line iteration disables ``f.tell()`` (read-ahead + buffer); we get byte-progress for free from ``len(raw_line)``. + """ + try: + total_bytes = ndjson_path.stat().st_size + except OSError: + total_bytes = 0 + + # Process-parallel parsing looks attractive, but the parent needs the full + # {table: [row dicts]} object graph. Pickling those rows back from workers + # often costs more than the JSON decode it parallelizes, so keep parallel + # parsing opt-in instead of surprising production runs. + worker_default = 1 + workers = max(1, int(os.environ.get("OSU_NDJSON_PARSE_WORKERS", worker_default))) + chunk_mb = max(1, int(os.environ.get("OSU_NDJSON_PARSE_CHUNK_MB", "8"))) + chunk_bytes = chunk_mb << 20 + min_parallel_bytes = int(os.environ.get("OSU_NDJSON_PARSE_MIN_MB", "64")) << 20 + backend = os.environ.get("OSU_NDJSON_PARSE_BACKEND", "process").strip().lower() + use_parallel = workers > 1 and total_bytes >= min_parallel_bytes + desc = f"parsing {ndjson_path.name}" + if use_parallel: + desc += f" ({workers} {backend} workers)" + + bar = _tqdm( + total=total_bytes or None, + desc=desc, + unit="B", + unit_scale=True, + unit_divisor=1024, + ) + by_table: dict[str, list[dict[str, Any]]] = defaultdict(list) + rows = 0 + try: + if not use_parallel: + for chunk in _iter_complete_ndjson_chunks(ndjson_path, chunk_bytes): + grouped, chunk_rows = _parse_ndjson_chunk(chunk) + _merge_grouped_rows(by_table, grouped) + rows += chunk_rows + bar.update(len(chunk)) + else: + if backend == "thread": + executor_cls = concurrent.futures.ThreadPoolExecutor + elif backend == "process": + executor_cls = concurrent.futures.ProcessPoolExecutor + else: + raise ValueError( + "OSU_NDJSON_PARSE_BACKEND must be 'process' or 'thread', " + f"got {backend!r}" + ) + chunk_iter = iter(_iter_complete_ndjson_chunks(ndjson_path, chunk_bytes)) + pending: list[tuple[concurrent.futures.Future, int]] = [] + + def submit_next(executor) -> bool: + try: + chunk = next(chunk_iter) + except StopIteration: + return False + pending.append((executor.submit(_parse_ndjson_chunk, chunk), len(chunk))) + return True + + with executor_cls(max_workers=workers) as executor: + for _ in range(workers * 2): + if not submit_next(executor): + break + while pending: + future, nbytes = pending.pop(0) + grouped, chunk_rows = future.result() + _merge_grouped_rows(by_table, grouped) + rows += chunk_rows + bar.update(nbytes) + submit_next(executor) + finally: + bar.set_postfix_str(f"{rows:,} rows -> {len(by_table)} table(s)") + bar.close() + return dict(by_table) + + +# --------------------------------------------------------------------------- +# Partition column derivation. +# --------------------------------------------------------------------------- + + +# Map of (ruleset, attributes_json key) → (column name, type-coercer). Used by +# :func:`hoist_difficulty_attributes` to denormalize the most useful rosu-pp +# fields out of the JSON blob and into typed top-level columns. The JSON blob +# remains the source of truth for less common attributes (e.g. is_convert flags +# on edge-case converted maps). +_OSU_DIFFICULTY_HOISTS: tuple[tuple[str, str, str], ...] = ( + ("aim", "aim_difficulty", "f64"), + ("speed", "speed_difficulty", "f64"), + ("flashlight", "flashlight_difficulty", "f64"), + ("slider_factor", "slider_factor", "f64"), + ("speed_note_count", "speed_note_count", "f64"), + ("great_hit_window", "great_hit_window", "f64"), + ("ok_hit_window", "ok_hit_window", "f64"), + ("meh_hit_window", "meh_hit_window", "f64"), + ("ar", "ar", "f64"), + ("hp", "hp", "f64"), + ("n_circles", "n_circles", "i32"), + ("n_sliders", "n_sliders", "i32"), + ("n_spinners", "n_spinners", "i32"), +) +_TAIKO_DIFFICULTY_HOISTS: tuple[tuple[str, str, str], ...] = ( + ("stamina", "stamina", "f64"), + ("rhythm", "rhythm", "f64"), + ("color", "color", "f64"), + ("reading", "reading", "f64"), + ("mono_stamina_factor", "mono_stamina_factor", "f64"), + ("great_hit_window", "great_hit_window", "f64"), + ("ok_hit_window", "ok_hit_window", "f64"), + ("is_convert", "is_convert", "bool"), +) +_CATCH_DIFFICULTY_HOISTS: tuple[tuple[str, str, str], ...] = ( + ("n_fruits", "n_fruits", "i32"), + ("n_droplets", "n_droplets", "i32"), + ("n_tiny_droplets", "n_tiny_droplets", "i32"), + ("is_convert", "is_convert", "bool"), +) +# rosu-pp 4.0.1's ManiaDifficultyAttributes exposes only stars / max_combo / +# n_objects / n_hold_notes / is_convert — no hit windows or post-mod OD. Do not +# add great_hit_window / ok_hit_window / meh_hit_window / od here; the hoist +# would always return null. +_MANIA_DIFFICULTY_HOISTS: tuple[tuple[str, str, str], ...] = ( + ("n_objects", "n_objects", "i32"), + ("n_hold_notes", "n_hold_notes", "i32"), + ("is_convert", "is_convert", "bool"), +) + + +def _coerce_hoist(value: Any, kind: str) -> Any: + if value is None: + return None + if kind == "f64": + try: + return float(value) + except (TypeError, ValueError): + return None + if kind == "i32": + try: + return int(value) + except (TypeError, ValueError): + return None + if kind == "bool": + return bool(value) + return value + + +def hoist_difficulty_attributes( + difficulty_rows: list[dict[str, Any]], +) -> list[dict[str, Any]]: + """Denormalize key ``attributes_json`` fields into typed top-level columns. + + Modifies and returns ``difficulty_rows``. Rows with + ``calculation_status='failed'`` keep nulls in every hoisted column. The + JSON blob is preserved in place so consumers can still recover any field + we don't denormalize. Idempotent: running twice on the same rows is a + no-op. + """ + if not difficulty_rows: + return difficulty_rows + + for row in difficulty_rows: + attrs_text = row.get("attributes_json") or "" + try: + attrs = json.loads(attrs_text) if attrs_text else {} + except (TypeError, json.JSONDecodeError): + attrs = {} + ruleset = (attrs.get("ruleset") or row.get("ruleset") or "").lower() + if ruleset == "osu": + hoists = _OSU_DIFFICULTY_HOISTS + elif ruleset == "taiko": + hoists = _TAIKO_DIFFICULTY_HOISTS + elif ruleset == "catch": + hoists = _CATCH_DIFFICULTY_HOISTS + elif ruleset == "mania": + hoists = _MANIA_DIFFICULTY_HOISTS + else: + hoists = () + for json_key, column_name, kind in hoists: + if column_name not in row or row[column_name] is None: + row[column_name] = _coerce_hoist(attrs.get(json_key), kind) + return difficulty_rows + + +def _mania_key_count_from_cs(cs: Any) -> int | None: + """Mirror of the Rust indexer's ``mania_key_count`` (round + clamp 1..18).""" + if cs is None: + return None + try: + cs_f = float(cs) + except (TypeError, ValueError): + return None + rounded = int(round(cs_f)) + if rounded < 1: + return 1 + if rounded > 18: + return 18 + return rounded + + +def _beatmap_revision_key(row: dict[str, Any]) -> tuple[str, str] | None: + """Composite key for joining beatmap-scoped rows across tables. + + Returns ``(set_revision_id, beatmap_uid)`` — the actual primary key. Joining + on ``beatmap_uid`` alone is wrong because a single chunk can contain two + revisions of the same submitted beatmapset, and ``beatmap_uid`` collapses + to ``'osu:'`` for both. Any in-memory denormalization must use + this composite key to avoid blending values across revisions. + """ + srid = row.get("set_revision_id") + uid = row.get("beatmap_uid") + if srid is None or uid is None: + return None + return (str(srid), str(uid)) + + +def enrich_beatmaps( + beatmaps: list[dict[str, Any]], + hit_objects_common: list[dict[str, Any]], +) -> list[dict[str, Any]]: + """Backfill denormalized columns onto every beatmap row. + + Adds: + - ``key_count``: round(circle_size) clamped to 1..18 for mania, null else. + - ``first_object_time_ms`` / ``last_object_time_ms`` / ``total_length_ms``: + derived from ``hit_objects_common`` of this batch (one pass, O(n)). + + Aggregation key is ``(set_revision_id, beatmap_uid)`` — the schema's + primary key. Keying on ``beatmap_uid`` alone would blend bounds across + revisions when one chunk contains two ``.osz`` revisions of the same + submitted set (same ``BeatmapID`` → same ``beatmap_uid``). + + Audio metadata (``audio_duration_ms`` / ``audio_sample_rate`` / + ``audio_channels``) is filled separately by :func:`backfill_beatmap_audio_metadata` + when a caller provides probe results. The compact v1 workflow does not + probe extracted blobs, so those fields are normally null. + Idempotent: running twice on the same rows is a no-op. + """ + if not beatmaps: + return beatmaps + + # Aggregate per (set_revision_id, beatmap_uid): (min_start, max_end). end is + # max(start, end_ms) so spinners and slider tail times count toward + # total_length_ms. + bounds: dict[tuple[str, str], list[int | None]] = {} + for ho in hit_objects_common: + key = _beatmap_revision_key(ho) + if key is None: + continue + start = ho.get("time_ms") + if start is None: + continue + try: + start = int(start) + except (TypeError, ValueError): + continue + end_raw = ho.get("end_time_ms") + try: + end = int(end_raw) if end_raw is not None else start + except (TypeError, ValueError): + end = start + bucket = bounds.get(key) + if bucket is None: + bounds[key] = [start, max(start, end)] + else: + if bucket[0] is None or start < bucket[0]: + bucket[0] = start + if bucket[1] is None or end > bucket[1]: + bucket[1] = end + + for bm in beatmaps: + ruleset = (bm.get("ruleset") or "").lower() + if "key_count" not in bm or bm["key_count"] is None: + bm["key_count"] = ( + _mania_key_count_from_cs(bm.get("circle_size")) + if ruleset == "mania" + else None + ) + key = _beatmap_revision_key(bm) + b = bounds.get(key) if key is not None else None + if b is not None: + bm.setdefault("first_object_time_ms", b[0]) + bm.setdefault("last_object_time_ms", b[1]) + if b[0] is not None and b[1] is not None and b[1] >= b[0]: + bm.setdefault("total_length_ms", b[1] - b[0]) + else: + bm.setdefault("total_length_ms", None) + else: + bm.setdefault("first_object_time_ms", None) + bm.setdefault("last_object_time_ms", None) + bm.setdefault("total_length_ms", None) + return beatmaps + + +def backfill_beatmap_audio_metadata( + beatmaps: list[dict[str, Any]], + audio_probe_by_sha: dict[str, dict[str, Any]], +) -> list[dict[str, Any]]: + """Stamp audio probe results onto each beatmap row from a sha→probe map. + + ``audio_probe_by_sha`` maps ``audio_blob_sha256`` to a dict carrying at + least ``audio_duration_ms`` / ``audio_sample_rate`` / ``audio_channels``; + compact v1 normally passes an empty map because extracted blob probing is + not part of the maintained workflow. Beatmaps with a null/missing audio + reference get nulls. Idempotent. + """ + if not beatmaps: + return beatmaps + for bm in beatmaps: + sha = bm.get("audio_blob_sha256") + if not sha: + bm.setdefault("audio_duration_ms", None) + bm.setdefault("audio_sample_rate", None) + bm.setdefault("audio_channels", None) + continue + probe = audio_probe_by_sha.get(sha) or {} + if "audio_duration_ms" not in bm or bm["audio_duration_ms"] is None: + bm["audio_duration_ms"] = probe.get("audio_duration_ms") + if "audio_sample_rate" not in bm or bm["audio_sample_rate"] is None: + bm["audio_sample_rate"] = probe.get("audio_sample_rate") + if "audio_channels" not in bm or bm["audio_channels"] is None: + bm["audio_channels"] = probe.get("audio_channels") + return beatmaps + + +# Per-mode tables that should carry the denormalized ``audio_blob_sha256``. +_HIT_OBJECTS_TABLES_FOR_AUDIO_BACKFILL: tuple[str, ...] = ( + "hit_objects_common", + "hit_objects_osu", + "hit_objects_taiko", + "hit_objects_catch", + "hit_objects_mania", +) + + +def backfill_hit_objects_audio_blob( + rows_by_table: dict[str, list[dict[str, Any]]], +) -> None: + """Stamp ``audio_blob_sha256`` from beatmaps onto every hit-objects row. + + Audio-conditioned models that stream `hit_objects_*` partition-pruned by + ``key_count`` / ``ruleset`` would otherwise need a join to ``beatmaps`` to + locate the audio blob. Denormalize so the join is unnecessary. + + The mapping key is ``(set_revision_id, beatmap_uid)`` — the schema's + primary key. Keying on ``beatmap_uid`` alone is wrong because a single + chunk can contain two ``.osz`` revisions of the same submitted set with + different audio blobs; the second revision's sha would silently overwrite + the first, and hit objects from revision A would be stamped with revision + B's audio. That would corrupt audio-conditioned modeling pairs. + + Mutates rows in place. Idempotent: rows already carrying + ``audio_blob_sha256`` are not overwritten. + """ + beatmaps = rows_by_table.get("beatmaps", []) + if not beatmaps: + return + audio_by_key: dict[tuple[str, str], str | None] = {} + for bm in beatmaps: + key = _beatmap_revision_key(bm) + if key is None: + continue + audio_by_key[key] = bm.get("audio_blob_sha256") + if not audio_by_key: + return + for table_name in _HIT_OBJECTS_TABLES_FOR_AUDIO_BACKFILL: + rows = rows_by_table.get(table_name) + if not rows: + continue + for row in rows: + if row.get("audio_blob_sha256") is not None: + continue + key = _beatmap_revision_key(row) + if key is None: + continue + if key in audio_by_key: + row["audio_blob_sha256"] = audio_by_key[key] + + +def derive_storyboard_source_to_set_revision_map( + storyboard_sources: list[dict[str, Any]], +) -> dict[str, str]: + return {r["storyboard_source_id"]: r["set_revision_id"] for r in storyboard_sources} + + +def derive_partition_values( + table_name: str, + row: dict[str, Any], + partition_keys: tuple[str, ...], +) -> dict[str, Any]: + """Read physical partition values from a single row.""" + values: dict[str, Any] = {} + for k in partition_keys: + if k in row: + values[k] = row[k] + else: + raise ValueError( + f"cannot derive partition value for {k!r} in table {table_name}" + ) + return values + + +def partition_dir_name(key: str, value: Any) -> str: + """Physical directory name for a logical partition value. + + The ``p_`` prefix prevents PyArrow's automatic Hive partition discovery + from inventing a second column with the same name as the real in-file + column. That keeps ``pq.read_table()`` and ``ds.dataset(..., + partitioning="hive")`` from failing on duplicate logical fields while HF + still sees those fields in the Parquet body. + """ + return f"p_{key}={value}" + + +# --------------------------------------------------------------------------- +# Sort + Arrow conversion. +# --------------------------------------------------------------------------- + + +def _sort_key_for(row: dict[str, Any], keys: tuple[str, ...]) -> tuple: + """Stable sort key handling None values (puts nulls first within a tier).""" + out = [] + for k in keys: + v = row.get(k) + if v is None: + out.append((0, 0)) + elif isinstance(v, bool): + out.append((1, int(v))) + elif isinstance(v, (int, float)): + out.append((1, v)) + else: + out.append((2, str(v))) + return tuple(out) + + +def rows_to_arrow_table( + rows: list[dict[str, Any]], file_schema: pa.Schema +) -> pa.Table: + """Convert rows (dicts) to a PyArrow Table conforming to ``file_schema``. + + Missing keys become nulls. Extra keys are ignored. Type coercion is + delegated to PyArrow (ints accepted for timestamp[ms], etc.). + """ + columns: dict[str, list[Any]] = {name: [] for name in file_schema.names} + for row in rows: + for name in columns: + columns[name].append(row.get(name)) + arrays = [] + for field in file_schema: + arrays.append(pa.array(columns[field.name], type=field.type)) + return pa.Table.from_arrays(arrays, schema=file_schema) + + +# --------------------------------------------------------------------------- +# Parquet writing. +# --------------------------------------------------------------------------- + + +PARQUET_WRITE_KWARGS = dict( + compression="zstd", + use_dictionary=True, + use_content_defined_chunking=True, + write_page_index=True, +) + + +def _atomic_write_parquet( + arrow_table: pa.Table, + target: Path, + **kwargs: Any, +) -> Path: + """Write a parquet file via tmp-sidecar + rename — crash-safe. + + A SIGINT / power loss between ``pq.write_table`` and ``replace`` leaves + a ``.tmp.`` file on disk (no corrupt ````); our startup + GC pass (``ingest_osz.cleanup_orphan_tmp_files``) sweeps these. The + final ``replace`` is atomic on NTFS within a volume (``MoveFileExW`` + with ``MOVEFILE_REPLACE_EXISTING``), so readers never observe a + truncated parquet. + """ + target.parent.mkdir(parents=True, exist_ok=True) + tmp = target.with_name(f"{target.name}.tmp.{os.getpid()}") + pq.write_table(arrow_table, tmp, **kwargs) + tmp.replace(target) + return target + + +def write_table_partitioned( + rows: list[dict[str, Any]], + table: TableSchema, + output_root: Path, + batch_id: str, + physical_partition_keys: tuple[str, ...] | None = None, +) -> list[Path]: + """Partition rows by partition_keys, sort, and write Parquet files. + + Returns the list of files written. No-op (returns ``[]``) when ``rows`` + is empty — partition directories aren't created for empty tables. + Each parquet write is atomic (tmp+rename) so a crash mid-write never + leaves a truncated file at the canonical path. + """ + if not rows: + return [] + + if physical_partition_keys is None: + physical_partition_keys = table.partition_keys + + # Group rows by the tuple of partition values and keep those values in the + # file-body row. + by_partition: dict[tuple, list[dict[str, Any]]] = defaultdict(list) + for row in rows: + pvs = derive_partition_values( + table.name, row, table.partition_keys + ) + ptuple = tuple(pvs[k] for k in physical_partition_keys) + body_row = dict(row) + body_row.update(pvs) + by_partition[ptuple].append(body_row) + + file_schema = table.file_schema() + paths_written: list[Path] = [] + + for ptuple, prows in by_partition.items(): + prows.sort(key=lambda r: _sort_key_for(r, table.sort_keys)) + + if physical_partition_keys: + parts = [ + partition_dir_name(k, v) + for k, v in zip(physical_partition_keys, ptuple) + ] + target_dir = output_root / table.name + for p in parts: + target_dir = target_dir / p + else: + target_dir = output_root / table.name + + arrow_table = rows_to_arrow_table(prows, file_schema) + target_path = target_dir / f"part-{batch_id}.parquet" + _atomic_write_parquet(arrow_table, target_path, **PARQUET_WRITE_KWARGS) + paths_written.append(target_path) + + return paths_written + + +# --------------------------------------------------------------------------- +# Top-level convenience: write every table from one batch's grouped rows. +# --------------------------------------------------------------------------- + + +def write_all_revisions_tables( + rows_by_table: dict[str, list[dict[str, Any]]], + schemas: dict[str, TableSchema], + all_revisions_root: Path, + batch_id: str, + defer_tables: tuple[str, ...] = (), + audio_probe_by_sha: dict[str, dict[str, Any]] | None = None, + physical_partitioning: str = "schema", +) -> dict[str, list[Path]]: + """Write every recognized table from this batch into all_revisions/. + + ``defer_tables`` lets the caller skip selected tables here so it can + write them in a controlled order (e.g. defer ``archive_revisions`` so + it lands LAST as a chunk-level commit marker; then a crashed run + leaves no archive_revisions row, and ``ingest_osz`` skip-already- + ingested correctly re-tries the chunk). The deferred tables can be + written via :func:`commit_archive_revisions` (or directly via + :func:`write_table_partitioned`). + + Returns ``{table_name: [paths_written, ...]}``. Tables with zero rows + in the batch produce zero files. Deferred tables map to ``[]``. + """ + if physical_partitioning == "schema": + physical_keys_by_table: dict[str, tuple[str, ...]] | None = None + elif physical_partitioning == "none": + physical_keys_by_table = {name: () for name in schemas} + else: + raise ValueError(f"unknown physical partitioning mode: {physical_partitioning!r}") + + # Denormalize the most useful rosu-pp attribute fields out of the JSON + # blob and into typed top-level columns. Done before partitioning so the + # latest writer sees the same enriched rows. + if "difficulty_attributes" in rows_by_table: + hoist_difficulty_attributes(rows_by_table["difficulty_attributes"]) + + # Denormalize beatmap-level fields (key_count for mania; first/last/total + # object times) and audio probe metadata. + if "beatmaps" in rows_by_table: + enrich_beatmaps( + rows_by_table["beatmaps"], + rows_by_table.get("hit_objects_common", []), + ) + if audio_probe_by_sha: + backfill_beatmap_audio_metadata( + rows_by_table["beatmaps"], audio_probe_by_sha + ) + + # Denormalize audio_blob_sha256 onto every hit_objects_* row so audio- + # conditioned models can stream hit objects partition-pruned without a join. + # Must run AFTER beatmap audio enrichment (above) so the source column is + # populated; before partitioning so the latest writer sees the same rows. + backfill_hit_objects_audio_blob(rows_by_table) + + deferred = set(defer_tables) + written: dict[str, list[Path]] = {} + eligible = [ + (name, rows) + for name, rows in rows_by_table.items() + if name not in deferred and name in schemas and rows + ] + total_rows = sum(len(rs) for _, rs in eligible) + bar = _tqdm( + total=len(eligible) or None, + desc=f"writing all_revisions ({total_rows:,} rows)", + unit="table", + ) + try: + for table_name, rows in rows_by_table.items(): + if table_name in deferred: + written[table_name] = [] + continue + if table_name not in schemas: + # Unknown table — skip silently; caller sees [] in the result. + written[table_name] = [] + continue + bar.set_postfix_str(f"{table_name} ({len(rows):,} rows)") + paths = write_table_partitioned( + rows, + schemas[table_name], + all_revisions_root, + batch_id, + physical_partition_keys=( + None if physical_keys_by_table is None else physical_keys_by_table[table_name] + ), + ) + written[table_name] = paths + bar.update(1) + finally: + bar.close() + return written + + +def commit_archive_revisions( + rows_by_table: dict[str, list[dict[str, Any]]], + schemas: dict[str, TableSchema], + all_revisions_root: Path, + batch_id: str, + physical_partitioning: str = "schema", +) -> list[Path]: + """Atomically write the chunk's ``archive_revisions`` parquet. + + This is the **chunk commit marker**. ``ingest_osz``'s skip-already- + ingested treats ``archive_sha256`` rows in ``archive_revisions/`` as + proof that the chunk's other tables are already on disk. So this MUST + be the last write in a chunk's pipeline. Only call it after + ``write_all_revisions_tables(defer_tables=("archive_revisions",))`` has + completed. + """ + rows = rows_by_table.get("archive_revisions", []) + if not rows: + return [] + if physical_partitioning == "schema": + physical_partition_keys = None + elif physical_partitioning == "none": + physical_partition_keys = () + else: + raise ValueError(f"unknown physical partitioning mode: {physical_partitioning!r}") + return write_table_partitioned( + rows, + schemas["archive_revisions"], + all_revisions_root, + batch_id, + physical_partition_keys=physical_partition_keys, + ) + + +# --------------------------------------------------------------------------- +# Latest view helpers. +# --------------------------------------------------------------------------- + +# Tables that get a ``data/v1/latest/`` view, in the order they're written. +# Each entry: (schema_table_name, latest_dir_basename, optional row filter). +# The filter, when present, decides whether a row of the source schema goes +# into THIS latest_dir; ``logical_files`` is separated into two siblings by +# ``media_kind``. +LATEST_TABLE_SPECS: tuple[tuple[str, str, Callable[[dict], bool] | None], ...] = ( + ("logical_files", "logical_files", lambda r: (r.get("media_kind") or "") != "video"), + ("logical_files", "logical_files_video", lambda r: (r.get("media_kind") or "") == "video"), + ("beatmaps", "beatmaps", None), + ("hit_objects_common", "hit_objects_common", None), + ("hit_objects_osu", "hit_objects_osu", None), + ("hit_objects_taiko", "hit_objects_taiko", None), + ("hit_objects_catch", "hit_objects_catch", None), + ("hit_objects_mania", "hit_objects_mania", None), + ("storyboard_sources", "storyboard_sources", None), + ("storyboard_elements", "storyboard_elements", None), + ("storyboard_commands", "storyboard_commands", None), + ("storyboard_variables", "storyboard_variables", None), + ("asset_references", "asset_references", None), + ("difficulty_attributes", "difficulty_attributes", None), + ("colours", "colours", None), + ("breaks", "breaks", None), +) + + +def derive_set_key(set_revision_row: dict[str, Any]) -> str: + """Compute the canonical ``set_key`` for a ``set_revisions`` row. + + The set revision id includes the per-archive SHA suffix. ``set_key`` strips + that suffix for known and fingerprinted sets so all revisions of the same + logical set share one key. Unknown archives keep their full id because + there is no stable cross-archive identity to merge on. + """ + srid = set_revision_row.get("set_revision_id") or "" + if not srid: + return srid + parts = str(srid).split(":", 2) + prefix = parts[0] + if prefix == "fingerprint" and len(parts) >= 2: + return f"fingerprint:{parts[1]}" + if prefix == "unknown": + return str(srid) + try: + return str(int(prefix)) + except ValueError: + return str(srid) + + +def _coerce_ms(value: Any) -> int: + """Coerce a timestamp-like value (int / datetime) to unix milliseconds. + + Avoids ``datetime.timestamp()`` because it makes an OS-level mktime call + that fails on Windows for sub-1970 (or sub-1980 on some locales) values. + Use direct epoch math instead. + """ + if value is None: + return 0 + if isinstance(value, bool): + return int(value) + if isinstance(value, int): + return value + # datetime — both naive and aware + import datetime as _dt + if isinstance(value, _dt.datetime): + if value.tzinfo is None: + epoch = _dt.datetime(1970, 1, 1) + else: + epoch = _dt.datetime(1970, 1, 1, tzinfo=_dt.timezone.utc) + delta = value - epoch + return delta.days * 86400_000 + delta.seconds * 1000 + delta.microseconds // 1000 + return int(value) + + +def write_latest_revisions( + new_latest: dict[str, dict[str, Any]], + path: Path, + schemas: dict[str, TableSchema], +) -> Path: + """Write the canonical ``latest_revisions.parquet`` atomically. + + Single small file (no partitioning per the schema). Atomic semantics + are critical here — this file is the COMMIT MARKER for a batch's + promotion of latest set_revisions; readers must never see a half- + written or empty version. + """ + table_schema = schemas["latest_revisions"] + rows = sorted(new_latest.values(), key=lambda r: r["set_key"]) + arrow_table = rows_to_arrow_table(rows, table_schema.file_schema()) + return _atomic_write_parquet(arrow_table, path, **PARQUET_WRITE_KWARGS) diff --git a/python/rebuild_latest_snapshot.py b/python/rebuild_latest_snapshot.py index 37bb74259d208c8388b51cf284a9a02922d82c19..8f0ea5f6bf7437d3d79939209dc1da0ca47f9fa7 100644 --- a/python/rebuild_latest_snapshot.py +++ b/python/rebuild_latest_snapshot.py @@ -4,7 +4,7 @@ This is intended for destructive full rebuilds where chunked ingest writes ``all_revisions`` only. It computes the latest set revision globally, writes ``latest_revisions/part.parquet``, and materializes latest table views as -split-scoped parquet shards without the old per-set-shard fan-out. +compact parquet shards. """ from __future__ import annotations @@ -28,14 +28,12 @@ from parquet_writer import ( PARQUET_WRITE_KWARGS, _atomic_write_parquet, _coerce_ms, - compute_split, derive_set_key, load_schemas, write_latest_revisions, ) -SPLITS = ("train", "validation", "test") DEFAULT_LATEST_REBUILD_WORKERS = min(8, max(1, os.cpu_count() or 1)) @@ -79,7 +77,6 @@ def build_latest_revisions(repo_root: Path, schemas: dict, schema_version: str) latest[set_key] = { "set_key": set_key, "set_revision_id": srid, - "split": compute_split(set_key), "first_seen_at": ts, "last_updated_at": ts, "revision_count": 1, @@ -130,28 +127,11 @@ def _rebuild_latest_source_file( table = _filter_latest(table, latest_srid_values, latest_dir) if table.num_rows == 0: return 0 - if "split" not in table.column_names: - raise RuntimeError( - f"{source} has no split column; compact latest rebuild " - "requires v1 all_revisions rows with split stamped in-body" - ) - - written = 0 schema_names = schema.names - for split in SPLITS: - split_table = table.filter(pc.equal(table["split"], split)) - if split_table.num_rows == 0: - continue - split_table = split_table.select(schema_names) - target = ( - latest_root - / latest_dir - / f"p_split={split}" - / f"part-{source_idx:05d}.parquet" - ) - _atomic_write_parquet(split_table, target, **PARQUET_WRITE_KWARGS) - written += 1 - return written + table = table.select(schema_names) + target = latest_root / latest_dir / f"part-{source_idx:05d}.parquet" + _atomic_write_parquet(table, target, **PARQUET_WRITE_KWARGS) + return 1 def rebuild_latest_tables( diff --git a/python/seed_fetcher_state.py b/python/seed_fetcher_state.py new file mode 100644 index 0000000000000000000000000000000000000000..b350ed589d35011edc88234e2cc4ffcd38334d70 --- /dev/null +++ b/python/seed_fetcher_state.py @@ -0,0 +1,222 @@ +#!/usr/bin/env python +"""Seed ``osu_fetcher`` state from compact v1 metadata. + +An update worker should not download the historical ``archives/`` tree just to +learn which sets already exist. This helper reads compact +``latest_revisions`` Parquet, extracts numeric beatmapset IDs, and inserts +missing rows into the fetcher SQLite DB as already acquired. Existing fetcher +rows are left untouched so pending updates, failures, API watermarks, and +download audit data survive reruns. +""" + +from __future__ import annotations + +import argparse +import sqlite3 +import sys +import time +from pathlib import Path +from typing import Any + +import pyarrow.dataset as ds + + +SCHEMA_SQL = """ +CREATE TABLE IF NOT EXISTS meta ( + key TEXT PRIMARY KEY, + value TEXT NOT NULL, + updated_at INTEGER NOT NULL +); + +CREATE TABLE IF NOT EXISTS sets ( + set_id INTEGER PRIMARY KEY, + wanted INTEGER NOT NULL DEFAULT 0, + ranked_status TEXT, + artist TEXT, + title TEXT, + creator TEXT, + api_last_updated TEXT, + discovered_at INTEGER, + + download_status TEXT NOT NULL DEFAULT 'pending', + attempts INTEGER NOT NULL DEFAULT 0, + last_error TEXT, + last_mirror TEXT, + last_attempt_at INTEGER, + bytes INTEGER, + sha256 TEXT, + flavor TEXT, + saved_path TEXT, + completed_at INTEGER +); + +CREATE INDEX IF NOT EXISTS idx_sets_status ON sets(download_status); +CREATE INDEX IF NOT EXISTS idx_sets_wanted_st ON sets(wanted, download_status); + +CREATE TABLE IF NOT EXISTS mirror_attempts ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + set_id INTEGER NOT NULL, + mirror TEXT NOT NULL, + attempted_at INTEGER NOT NULL, + duration_ms INTEGER, + http_status INTEGER, + bytes INTEGER, + outcome TEXT NOT NULL, + error TEXT, + FOREIGN KEY(set_id) REFERENCES sets(set_id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_attempts_set ON mirror_attempts(set_id); +CREATE INDEX IF NOT EXISTS idx_attempts_mirror ON mirror_attempts(mirror, outcome); + +CREATE TABLE IF NOT EXISTS mirror_discoveries ( + set_id INTEGER NOT NULL, + mirror TEXT NOT NULL, + claimed_status TEXT NOT NULL, + has_osu_std INTEGER NOT NULL, + mirror_last_updated TEXT, + last_seen_at INTEGER NOT NULL, + PRIMARY KEY(set_id, mirror) +); + +CREATE INDEX IF NOT EXISTS idx_disc_set ON mirror_discoveries(set_id); +CREATE INDEX IF NOT EXISTS idx_disc_mirror ON mirror_discoveries(mirror); +CREATE INDEX IF NOT EXISTS idx_disc_status ON mirror_discoveries(claimed_status, has_osu_std); +""" + + +def _parquet_files(path: Path) -> list[str]: + return [str(p) for p in sorted(path.rglob("*.parquet"))] if path.exists() else [] + + +def numeric_latest_set_ids(repo_root: Path, schema_version: str = "v1") -> set[int]: + latest_dir = ( + repo_root + / "data" + / schema_version + / "all_revisions" + / "latest_revisions" + ) + files = _parquet_files(latest_dir) + if not files: + raise SystemExit(f"missing latest_revisions parquet under {latest_dir}") + + table = ds.dataset(files, format="parquet").to_table(columns=["set_key"]) + out: set[int] = set() + for value in table.column("set_key").to_pylist(): + if value is None: + continue + text = str(value) + if text.isdecimal(): + n = int(text) + if n > 0: + out.add(n) + return out + + +def open_state_db(path: Path) -> sqlite3.Connection: + path.parent.mkdir(parents=True, exist_ok=True) + conn = sqlite3.connect(path) + conn.execute("PRAGMA journal_mode=WAL") + conn.execute("PRAGMA synchronous=NORMAL") + conn.execute("PRAGMA foreign_keys=ON") + conn.executescript(SCHEMA_SQL) + now = int(time.time()) + conn.execute( + """ + INSERT INTO meta(key, value, updated_at) + VALUES('schema_version', '2', ?) + ON CONFLICT(key) DO UPDATE SET + value=excluded.value, + updated_at=excluded.updated_at + """, + (now,), + ) + return conn + + +def seed_state( + repo_root: Path, + state_db: Path, + *, + schema_version: str = "v1", +) -> dict[str, Any]: + set_ids = numeric_latest_set_ids(repo_root, schema_version=schema_version) + now = int(time.time()) + conn = open_state_db(state_db) + try: + before = conn.total_changes + rows = [ + ( + set_id, + now, + f"compact://data/{schema_version}/latest_revisions/{set_id}", + now, + ) + for set_id in sorted(set_ids) + ] + conn.executemany( + """ + INSERT OR IGNORE INTO sets( + set_id, wanted, discovered_at, download_status, saved_path, + completed_at + ) + VALUES(?, 0, ?, 'success', ?, ?) + """, + rows, + ) + inserted = conn.total_changes - before + conn.commit() + conn.execute("PRAGMA wal_checkpoint(TRUNCATE)") + finally: + conn.close() + + return { + "known_numeric_sets": len(set_ids), + "inserted_success_rows": inserted, + "state_db": str(state_db), + } + + +def checkpoint_state_db(state_db: Path) -> None: + conn = open_state_db(state_db) + try: + conn.commit() + conn.execute("PRAGMA wal_checkpoint(TRUNCATE)") + finally: + conn.close() + + +def parse_args(argv: list[str] | None = None) -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--repo-root", default=".") + parser.add_argument("--schema-version", default="v1") + parser.add_argument("--state-db", default=".fetcher/state.db") + parser.add_argument( + "--checkpoint-only", + action="store_true", + help="initialize/checkpoint the DB without reading compact metadata", + ) + return parser.parse_args(argv) + + +def main(argv: list[str] | None = None) -> int: + args = parse_args(argv) + repo_root = Path(args.repo_root).resolve() + state_db = Path(args.state_db) + if not state_db.is_absolute(): + state_db = repo_root / state_db + + if args.checkpoint_only: + checkpoint_state_db(state_db) + print(f"state_db_checkpointed={state_db}") + return 0 + + summary = seed_state(repo_root, state_db, schema_version=args.schema_version) + for key, value in summary.items(): + print(f"{key}={value}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/python/test_compact_v1.py b/python/test_compact_v1.py index dde2fcb1980796d52dc6e9b0ab04b3adf8292172..30d6e92810190973c9ee17cd40bf060edc1a588f 100644 --- a/python/test_compact_v1.py +++ b/python/test_compact_v1.py @@ -67,9 +67,8 @@ class CompactV1ValidatorTests(unittest.TestCase): / "v1" / "latest" / "beatmaps" - / "p_split=train" / "part.parquet", - [{"set_revision_id": "1:" + "a" * 64, "split": "train"}], + [{"set_revision_id": "1:" + "a" * 64}], ) def tearDown(self) -> None: @@ -113,7 +112,7 @@ class CompactV1ValidatorTests(unittest.TestCase): / "v1" / "all_revisions" / "beatmaps" - / "p_split=train" + / "p_bucket=x" ) bad_dir.mkdir(parents=True, exist_ok=True) diff --git a/python/validate_compact_v1.py b/python/validate_compact_v1.py new file mode 100644 index 0000000000000000000000000000000000000000..b090fa5f3c1e3351263c6693629ef32ee0941340 --- /dev/null +++ b/python/validate_compact_v1.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python +"""Validate the compact v1 dataset layout. + +The compact workflow keeps raw ``.osz`` archives plus Parquet metadata only. +It must not recreate the discarded extracted blob store, per-revision +manifests, or the old global blobs registry. +""" + +from __future__ import annotations + +import argparse +import json +import sys +from pathlib import Path +from typing import Any + +import pyarrow.dataset as ds + + +def _count_rows(path: Path) -> int: + files = sorted(path.rglob("*.parquet")) if path.exists() else [] + if not files: + return 0 + return int(ds.dataset([str(p) for p in files], format="parquet").count_rows()) + + +def _count_files(path: Path, pattern: str = "*") -> int: + if not path.exists(): + return 0 + return sum(1 for p in path.rglob(pattern) if p.is_file()) + + +def validate_compact_v1( + repo_root: Path, + *, + schema_version: str = "v1", + require_archive_file_match: bool = False, + expected_archive_rows: int | None = None, + max_data_files: int | None = 10_000, + allow_empty: bool = False, +) -> dict[str, Any]: + repo_root = repo_root.resolve() + all_revisions = repo_root / "data" / schema_version / "all_revisions" + latest = repo_root / "data" / schema_version / "latest" + + summary: dict[str, Any] = { + "archive_files": _count_files(repo_root / "archives", "*.osz"), + "data_files": _count_files(repo_root / "data"), + "blob_files": _count_files(repo_root / "blobs"), + "manifest_files": _count_files(repo_root / "manifests"), + "archive_rows": _count_rows(all_revisions / "archive_revisions"), + "set_rows": _count_rows(all_revisions / "set_revisions"), + "latest_revision_rows": _count_rows(all_revisions / "latest_revisions"), + "latest_files": _count_files(latest, "*.parquet"), + "blobs_registry_files": _count_files(all_revisions / "blobs", "*.parquet"), + "partition_dirs_in_all_revisions": sorted( + str(p.relative_to(repo_root)) + for p in all_revisions.rglob("p_*=*") + if p.is_dir() + ) + if all_revisions.exists() + else [], + "partition_dirs_in_latest": sorted( + str(p.relative_to(repo_root)) + for p in latest.rglob("p_*=*") + if p.is_dir() + ) + if latest.exists() + else [], + } + + errors: list[str] = [] + if expected_archive_rows is not None and summary["archive_rows"] != expected_archive_rows: + errors.append( + "archive row count mismatch: " + f"rows={summary['archive_rows']}, expected={expected_archive_rows}" + ) + if require_archive_file_match and summary["archive_rows"] != summary["archive_files"]: + errors.append( + "archive row/file mismatch: " + f"rows={summary['archive_rows']}, files={summary['archive_files']}" + ) + if not allow_empty: + if summary["archive_rows"] <= 0: + errors.append("archive_revisions has no rows") + if summary["set_rows"] <= 0: + errors.append("set_revisions has no rows") + if summary["latest_revision_rows"] <= 0: + errors.append("latest_revisions has no rows") + if summary["latest_files"] <= 0: + errors.append("latest/ has no parquet files") + if summary["blob_files"]: + errors.append(f"compact layout contains {summary['blob_files']} blob file(s)") + if summary["manifest_files"]: + errors.append( + f"compact layout contains {summary['manifest_files']} manifest file(s)" + ) + if summary["blobs_registry_files"]: + errors.append( + "compact layout contains data/v1/all_revisions/blobs parquet files" + ) + if summary["partition_dirs_in_all_revisions"]: + errors.append("all_revisions contains physical partition directories") + if summary["partition_dirs_in_latest"]: + errors.append("latest contains physical partition directories") + if max_data_files is not None and summary["data_files"] > max_data_files: + errors.append( + f"compact layout produced too many data files: " + f"{summary['data_files']} > {max_data_files}" + ) + + summary["ok"] = not errors + summary["errors"] = errors + return summary + + +def parse_args(argv: list[str] | None = None) -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--repo-root", default=".") + parser.add_argument("--schema-version", default="v1") + parser.add_argument("--require-archive-file-match", action="store_true") + parser.add_argument("--expected-archive-rows", type=int, default=None) + parser.add_argument("--max-data-files", type=int, default=10_000) + parser.add_argument("--allow-empty", action="store_true") + parser.add_argument("--json", action="store_true", help="emit JSON summary") + return parser.parse_args(argv) + + +def main(argv: list[str] | None = None) -> int: + args = parse_args(argv) + summary = validate_compact_v1( + Path(args.repo_root), + schema_version=args.schema_version, + require_archive_file_match=args.require_archive_file_match, + expected_archive_rows=args.expected_archive_rows, + max_data_files=args.max_data_files, + allow_empty=args.allow_empty, + ) + if args.json: + print(json.dumps(summary, indent=2, sort_keys=True)) + else: + for key, value in summary.items(): + if key in {"errors", "ok"}: + continue + print(f"{key}={value}") + if summary["errors"]: + print("errors:", file=sys.stderr) + for err in summary["errors"]: + print(f"- {err}", file=sys.stderr) + return 0 if summary["ok"] else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/schemas/v1/archive_revisions.schema.json b/schemas/v1/archive_revisions.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..83a4eaccb964b4e5a7fdc90c42313567276b0965 --- /dev/null +++ b/schemas/v1/archive_revisions.schema.json @@ -0,0 +1,270 @@ +{ + "schema_version": "v1", + "description": "Archive- and set-level revision tables. One row per .osz (archive_revisions) and one row per logical beatmapset interpretation of that archive (set_revisions).", + "tables": { + "archive_revisions": { + "description": "One row per distinct .osz archive attempt committed by the compact ingest pipeline, keyed by SHA-256 of archive bytes.", + "row_grain": "one .osz", + "primary_key": [ + "archive_revision_id" + ], + "partition_keys": [], + "sort_keys": [ + "archive_revision_id" + ], + "columns": [ + { + "name": "archive_revision_id", + "type": "string", + "nullable": false, + "description": "Equal to archive_sha256; canonical archive identity." + }, + { + "name": "archive_sha256", + "type": "string", + "nullable": false, + "description": "Hex-encoded SHA-256 of the .osz bytes." + }, + { + "name": "archive_path", + "type": "string", + "nullable": false, + "description": "Repo-relative storage path under archives/sha256/aa/bb/...osz." + }, + { + "name": "original_filename", + "type": "string", + "nullable": true, + "description": "Filename as ingested (e.g. '2534007 Artist - Title.osz')." + }, + { + "name": "size_bytes", + "type": "int64", + "nullable": false, + "description": "Size of the .osz file in bytes." + }, + { + "name": "member_count", + "type": "int32", + "nullable": false, + "description": "Number of ZIP members. 0 when ingest_decision='quarantined' and the archive could not be opened." + }, + { + "name": "zip_comment", + "type": "string", + "nullable": true, + "description": "Top-level ZIP comment, if any." + }, + { + "name": "zip_warning", + "type": "string", + "nullable": true, + "description": "Concatenated structural warnings (e.g. unsupported entry types, ZIP64)." + }, + { + "name": "source_kind", + "type": "string", + "nullable": true, + "description": "How the archive was acquired: 'osu_official', 'mirror', 'user_upload', 'unknown'." + }, + { + "name": "source_url", + "type": "string", + "nullable": true, + "description": "Origin URL when known." + }, + { + "name": "ingested_at", + "type": "timestamp[ms]", + "nullable": false, + "description": "Ingest wall-clock time (UTC) for this committed archive row." + }, + { + "name": "ingest_batch_id", + "type": "string", + "nullable": false, + "description": "Stable id of the batch that committed this archive row." + }, + { + "name": "ingest_tool_version", + "type": "string", + "nullable": false, + "description": "Version string of osu_indexer + ingest_osz.py for this committed row." + }, + { + "name": "schema_version", + "type": "string", + "nullable": false, + "description": "Schema version this row was written against (e.g. 'v1')." + }, + { + "name": "ingest_decision", + "type": "string", + "nullable": false, + "description": "Committed ingest state — 'accepted' for successfully indexed archives or 'quarantined' for fatal ZIP-open failures. Storage/callback failures and indexer crashes abort the chunk before this row commits." + }, + { + "name": "ingest_decision_reason", + "type": "string", + "nullable": true, + "description": "Free-form reason for the ingest_decision when not 'accepted' (for example, 'central directory not found')." + }, + { + "name": "ingest_decision_at", + "type": "timestamp[ms]", + "nullable": false, + "description": "When ingest_decision was set (UTC)." + } + ] + }, + "set_revisions": { + "description": "One row per logical beatmapset revision (a (beatmapset_id, archive_sha256) pair).", + "row_grain": "one beatmapset revision", + "primary_key": [ + "set_revision_id" + ], + "partition_keys": [], + "sort_keys": [ + "set_revision_id" + ], + "columns": [ + { + "name": "set_revision_id", + "type": "string", + "nullable": false, + "description": "':'." + }, + { + "name": "archive_revision_id", + "type": "string", + "nullable": false, + "description": "FK to archive_revisions.archive_revision_id." + }, + { + "name": "beatmapset_id", + "type": "int64", + "nullable": true, + "description": "Submitted set ID, null if unknown/unsubmitted." + }, + { + "name": "beatmapset_id_source", + "type": "string", + "nullable": false, + "description": "How the ID was determined: 'osu_header', 'filename', 'fingerprint', 'unknown'." + }, + { + "name": "title", + "type": "string", + "nullable": true, + "description": "Romanized title (consensus across difficulties)." + }, + { + "name": "title_unicode", + "type": "string", + "nullable": true, + "description": "Unicode title." + }, + { + "name": "artist", + "type": "string", + "nullable": true, + "description": "Romanized artist." + }, + { + "name": "artist_unicode", + "type": "string", + "nullable": true, + "description": "Unicode artist." + }, + { + "name": "creator", + "type": "string", + "nullable": true, + "description": "Mapper username." + }, + { + "name": "source", + "type": "string", + "nullable": true, + "description": "Source field from .osu (game/anime/album)." + }, + { + "name": "tags", + "type": "list", + "nullable": true, + "description": "Union of tag tokens across difficulties." + }, + { + "name": "mode_set", + "type": "list", + "nullable": false, + "description": "Distinct rulesets present: subset of ['osu','taiko','catch','mania']." + }, + { + "name": "num_beatmaps", + "type": "int32", + "nullable": false, + "description": "Number of .osu difficulties." + }, + { + "name": "num_files", + "type": "int32", + "nullable": false, + "description": "Number of logical files in the archive." + }, + { + "name": "num_blobs", + "type": "int32", + "nullable": false, + "description": "Number of unique uncompressed archive-member hashes referenced by this revision." + }, + { + "name": "num_missing_references", + "type": "int32", + "nullable": false, + "description": "Count of asset_references with resolution_status='missing'." + } + ] + }, + "latest_revisions": { + "description": "Single source of truth for which set_revision_id is currently 'latest' for each beatmapset_id (or unknown set fingerprint).", + "row_grain": "one beatmapset", + "primary_key": [ + "set_key" + ], + "partition_keys": [], + "sort_keys": [ + "set_key" + ], + "columns": [ + { + "name": "set_key", + "type": "string", + "nullable": false, + "description": "beatmapset_id as string, or 'fingerprint:' / 'unknown:' when unknown." + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false, + "description": "Currently-latest revision." + }, + { + "name": "first_seen_at", + "type": "timestamp[ms]", + "nullable": false + }, + { + "name": "last_updated_at", + "type": "timestamp[ms]", + "nullable": false + }, + { + "name": "revision_count", + "type": "int32", + "nullable": false + } + ] + } + } +} diff --git a/schemas/v1/beatmaps.schema.json b/schemas/v1/beatmaps.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..3e54041c01f1cbabf3978f0b8894e4464aa2f574 --- /dev/null +++ b/schemas/v1/beatmaps.schema.json @@ -0,0 +1,683 @@ +{ + "schema_version": "v1", + "description": "Parsed .osu beatmap tables: per-difficulty header (beatmaps), raw section preservation (osu_sections), timing points, [Colours] section, and [Events] break ranges.", + "tables": { + "beatmaps": { + "description": "One row per .osu difficulty.", + "row_grain": "one .osu file", + "primary_key": [ + "beatmap_uid", + "set_revision_id" + ], + "partition_keys": [ + "ruleset" + ], + "sort_keys": [ + "beatmap_uid", + "set_revision_id" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false, + "description": "'osu:' if BeatmapID > 0 else 'sha256:'." + }, + { + "name": "beatmap_id", + "type": "int64", + "nullable": true, + "description": "Submitted beatmap id, null if unsubmitted." + }, + { + "name": "beatmapset_id", + "type": "int64", + "nullable": true + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false, + "description": "FK to set_revisions." + }, + { + "name": "archive_revision_id", + "type": "string", + "nullable": false, + "description": "FK to archive_revisions." + }, + { + "name": "osu_logical_file_id", + "type": "string", + "nullable": false, + "description": "FK to logical_files." + }, + { + "name": "osu_blob_sha256", + "type": "string", + "nullable": false, + "description": "SHA-256 of the uncompressed .osu archive member bytes." + }, + { + "name": "osu_path_raw", + "type": "string", + "nullable": true + }, + { + "name": "osu_path_posix", + "type": "string", + "nullable": true + }, + { + "name": "format_version", + "type": "int32", + "nullable": true, + "description": "From `osu file format vN` line." + }, + { + "name": "mode", + "type": "int8", + "nullable": false, + "description": "0=osu, 1=taiko, 2=catch, 3=mania." + }, + { + "name": "ruleset", + "type": "string", + "nullable": false, + "description": "Stringified mode: osu | taiko | catch | mania." + }, + { + "name": "ruleset_aliases", + "type": "list", + "nullable": true, + "description": "Display aliases (e.g. ['ctb'] for catch)." + }, + { + "name": "title", + "type": "string", + "nullable": true + }, + { + "name": "title_unicode", + "type": "string", + "nullable": true + }, + { + "name": "artist", + "type": "string", + "nullable": true + }, + { + "name": "artist_unicode", + "type": "string", + "nullable": true + }, + { + "name": "creator", + "type": "string", + "nullable": true + }, + { + "name": "version", + "type": "string", + "nullable": true, + "description": "Difficulty name." + }, + { + "name": "source", + "type": "string", + "nullable": true + }, + { + "name": "tags", + "type": "list", + "nullable": true + }, + { + "name": "audio_filename_raw", + "type": "string", + "nullable": true, + "description": "AudioFilename from [General] as written." + }, + { + "name": "audio_lead_in_ms", + "type": "int32", + "nullable": true, + "description": "[General] AudioLeadIn: ms of silence prepended before the audio file plays. Hit object times are referenced to the original audio's t=0; subtract this when aligning audio samples to objects. Null when the .osu parse failed; defaults to 0 in the .osu spec when omitted." + }, + { + "name": "audio_reference_id", + "type": "string", + "nullable": true, + "description": "FK to asset_references." + }, + { + "name": "audio_blob_sha256", + "type": "string", + "nullable": true + }, + { + "name": "audio_duration_ms", + "type": "int64", + "nullable": true, + "description": "Reserved for probed audio duration. Compact v1 ingest skips extracted-blob probing, so this is normally null." + }, + { + "name": "audio_sample_rate", + "type": "int32", + "nullable": true, + "description": "Probed audio sample rate (Hz)." + }, + { + "name": "audio_channels", + "type": "int32", + "nullable": true, + "description": "Probed audio channel count." + }, + { + "name": "background_reference_id", + "type": "string", + "nullable": true + }, + { + "name": "background_blob_sha256", + "type": "string", + "nullable": true + }, + { + "name": "background_x", + "type": "int32", + "nullable": true, + "description": "Optional pixel offset on the [Events] background line (0,0,\"bg.jpg\",x,y). Null when omitted or no background event." + }, + { + "name": "background_y", + "type": "int32", + "nullable": true, + "description": "Optional pixel offset on the [Events] background line." + }, + { + "name": "video_reference_id", + "type": "string", + "nullable": true + }, + { + "name": "video_blob_sha256", + "type": "string", + "nullable": true + }, + { + "name": "video_start_time_ms", + "type": "int32", + "nullable": true, + "description": "Offset (ms) on the [Events] video line: Video,start,\"video.mp4\". Negative when the video starts before the audio." + }, + { + "name": "hp_drain_rate", + "type": "float32", + "nullable": false + }, + { + "name": "circle_size", + "type": "float32", + "nullable": false + }, + { + "name": "overall_difficulty", + "type": "float32", + "nullable": false + }, + { + "name": "approach_rate", + "type": "float32", + "nullable": true, + "description": "Defaults to OD when missing in old maps." + }, + { + "name": "slider_multiplier", + "type": "float32", + "nullable": true + }, + { + "name": "slider_tick_rate", + "type": "float32", + "nullable": true + }, + { + "name": "key_count", + "type": "int32", + "nullable": true, + "description": "Mania key count derived from circle_size (round, clamped 1..18). Null for non-mania rulesets." + }, + { + "name": "first_object_time_ms", + "type": "int32", + "nullable": true, + "description": "time_ms of the first hit object, or null when the map has no hit objects." + }, + { + "name": "last_object_time_ms", + "type": "int32", + "nullable": true, + "description": "max(start_time_ms, end_time_ms) over all hit objects, or null when the map has no hit objects." + }, + { + "name": "total_length_ms", + "type": "int32", + "nullable": true, + "description": "last_object_time_ms - first_object_time_ms; 0 for single-object maps; null when the map has no hit objects." + }, + { + "name": "preview_time_ms", + "type": "int32", + "nullable": true + }, + { + "name": "countdown", + "type": "int32", + "nullable": true + }, + { + "name": "sample_set", + "type": "string", + "nullable": true + }, + { + "name": "stack_leniency", + "type": "float32", + "nullable": true + }, + { + "name": "special_style", + "type": "bool", + "nullable": true + }, + { + "name": "widescreen_storyboard", + "type": "bool", + "nullable": true + }, + { + "name": "letterbox_in_breaks", + "type": "bool", + "nullable": true + }, + { + "name": "epilepsy_warning", + "type": "bool", + "nullable": true + }, + { + "name": "samples_match_playback_rate", + "type": "bool", + "nullable": true + }, + { + "name": "hit_object_count", + "type": "int32", + "nullable": false + }, + { + "name": "timing_point_count", + "type": "int32", + "nullable": false + }, + { + "name": "break_count", + "type": "int32", + "nullable": false + }, + { + "name": "event_count", + "type": "int32", + "nullable": false + }, + { + "name": "has_osb", + "type": "bool", + "nullable": false, + "description": "Whether the set carries a sibling .osb file." + }, + { + "name": "has_local_storyboard", + "type": "bool", + "nullable": false, + "description": "Whether [Events] contains storyboard commands." + }, + { + "name": "has_effective_storyboard", + "type": "bool", + "nullable": false + }, + { + "name": "has_video", + "type": "bool", + "nullable": false + }, + { + "name": "has_missing_references", + "type": "bool", + "nullable": false + }, + { + "name": "parser_name", + "type": "string", + "nullable": false, + "description": "e.g. 'rosu-map'." + }, + { + "name": "parser_version", + "type": "string", + "nullable": false + }, + { + "name": "parse_status", + "type": "string", + "nullable": false, + "description": "ok | partial | failed." + }, + { + "name": "parse_error", + "type": "string", + "nullable": true + } + ] + }, + "osu_sections": { + "description": "Raw section-by-section preservation of each .osu file. Lets us reconstruct or diff source even when the parsed semantic tables drift.", + "row_grain": "one section per beatmap", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "section_name" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "byte_start" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "section_name", + "type": "string", + "nullable": false, + "description": "[General], [Editor], [Metadata], [Difficulty], [Events], [TimingPoints], [Colours], [HitObjects], [Variables], or _header for the format declaration." + }, + { + "name": "line_index_start", + "type": "int32", + "nullable": false + }, + { + "name": "line_index_end", + "type": "int32", + "nullable": false + }, + { + "name": "byte_start", + "type": "int64", + "nullable": false + }, + { + "name": "byte_end", + "type": "int64", + "nullable": false + }, + { + "name": "raw_text", + "type": "string", + "nullable": false, + "description": "Verbatim section contents including header line." + }, + { + "name": "parse_status", + "type": "string", + "nullable": false + } + ] + }, + "timing_points": { + "description": "Parsed [TimingPoints] entries. Both uninherited (red) and inherited (green) lines.", + "row_grain": "one timing point", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "row_index" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "row_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "row_index", + "type": "int32", + "nullable": false, + "description": "Order in the [TimingPoints] section." + }, + { + "name": "time_ms", + "type": "float64", + "nullable": false + }, + { + "name": "beat_length", + "type": "float64", + "nullable": false, + "description": "Positive for uninherited (BPM = 60000/beat_length); negative percentage for inherited slider velocity." + }, + { + "name": "meter", + "type": "int32", + "nullable": true + }, + { + "name": "sample_set", + "type": "int32", + "nullable": true + }, + { + "name": "sample_index", + "type": "int32", + "nullable": true + }, + { + "name": "volume", + "type": "int32", + "nullable": true + }, + { + "name": "uninherited", + "type": "bool", + "nullable": false + }, + { + "name": "effects", + "type": "int32", + "nullable": true, + "description": "Bitfield: bit0=kiai, bit3=omit barline." + }, + { + "name": "bpm", + "type": "float64", + "nullable": true, + "description": "60000/beat_length when uninherited; else null." + }, + { + "name": "slider_velocity_multiplier", + "type": "float64", + "nullable": true, + "description": "-100/beat_length when inherited; else null (treat as 1.0 for uninherited)." + }, + { + "name": "is_kiai", + "type": "bool", + "nullable": false + }, + { + "name": "raw_line", + "type": "string", + "nullable": false + } + ] + }, + "colours": { + "description": "Parsed [Colours] section. One row per beatmap with combo color overrides and the slider track / border overrides as separate columns.", + "row_grain": "one .osu file (only emitted when the beatmap has a non-empty [Colours] section)", + "primary_key": [ + "beatmap_uid", + "set_revision_id" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "combo_count", + "type": "int32", + "nullable": false, + "description": "Number of Combo entries declared (0..8)." + }, + { + "name": "combo_colors_json", + "type": "string", + "nullable": false, + "description": "JSON array of [r,g,b] triples in declared Combo1..ComboN order. '[]' when no combo entries are declared." + }, + { + "name": "slider_track_override_r", + "type": "int32", + "nullable": true, + "description": "SliderTrackOverride red channel (0-255), null when not declared." + }, + { + "name": "slider_track_override_g", + "type": "int32", + "nullable": true + }, + { + "name": "slider_track_override_b", + "type": "int32", + "nullable": true + }, + { + "name": "slider_border_r", + "type": "int32", + "nullable": true, + "description": "SliderBorder red channel (0-255), null when not declared." + }, + { + "name": "slider_border_g", + "type": "int32", + "nullable": true + }, + { + "name": "slider_border_b", + "type": "int32", + "nullable": true + }, + { + "name": "raw_section_text", + "type": "string", + "nullable": false, + "description": "Verbatim [Colours] section text including the bracketed header. Lets consumers recover any non-standard keys we don't denormalize." + }, + { + "name": "parse_status", + "type": "string", + "nullable": false, + "description": "ok | partial — partial when a Combo entry could not be parsed." + } + ] + }, + "breaks": { + "description": "Parsed break events from the [Events] section. One row per `2,start,end` (or `Break,start,end`) line. Used for rest-aware density features in ML.", + "row_grain": "one break event", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "break_index" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "break_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "break_index", + "type": "int32", + "nullable": false, + "description": "Order within [Events] (0-based)." + }, + { + "name": "start_time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "duration_ms", + "type": "int32", + "nullable": false, + "description": "end_time_ms - start_time_ms; negative when malformed." + }, + { + "name": "raw_line", + "type": "string", + "nullable": false + } + ] + } + } +} diff --git a/schemas/v1/difficulty_attributes.schema.json b/schemas/v1/difficulty_attributes.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..b8ea94a339b1b43eeac01349d65f3b69de0f5f8f --- /dev/null +++ b/schemas/v1/difficulty_attributes.schema.json @@ -0,0 +1,263 @@ +{ + "schema_version": "v1", + "description": "Computed difficulty/performance attributes. Always include the calculator version + lazer/tools commit because rosu-pp output drifts as upstream lazer changes.", + "tables": { + "difficulty_attributes": { + "description": "One row per (beatmap_uid, mods_acronym, calculator_version). Stars + JSON blob of mode-specific attributes.", + "row_grain": "one (beatmap, mods, calculator) tuple", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "mods_acronym", + "calculator_version" + ], + "partition_keys": [ + "ruleset" + ], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "mods_acronym", + "calculator_version" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "ruleset", + "type": "string", + "nullable": false, + "description": "osu | taiko | catch | mania." + }, + { + "name": "calculator", + "type": "string", + "nullable": false, + "description": "Currently always 'rosu-pp'." + }, + { + "name": "calculator_version", + "type": "string", + "nullable": false, + "description": "Crate version pulled from Cargo.lock." + }, + { + "name": "lazer_commit", + "type": "string", + "nullable": true, + "description": "Upstream osu!lazer commit the calculator tracks, when known." + }, + { + "name": "tools_commit", + "type": "string", + "nullable": true, + "description": "Upstream osu-tools commit, when known." + }, + { + "name": "mods_acronym", + "type": "string", + "nullable": false, + "description": "NM, HD, HR, DT, HT, EZ, FL, HDHR, HDDT, etc. Use 'NM' for no mods." + }, + { + "name": "mods_bitmask", + "type": "int64", + "nullable": true, + "description": "Legacy osu! mod bitmask, when applicable." + }, + { + "name": "clock_rate", + "type": "float32", + "nullable": true, + "description": "Effective clock rate (1.0 NM, 1.5 DT, 0.75 HT)." + }, + { + "name": "stars", + "type": "float64", + "nullable": false, + "description": "Star rating." + }, + { + "name": "max_combo", + "type": "int32", + "nullable": true + }, + { + "name": "attributes_json", + "type": "string", + "nullable": false, + "description": "JSON blob with mode-specific fields (aim, speed, jump_aim, n_circles, hit_window, ...). The most common fields are denormalized below for fast filtering, but the JSON remains the source of truth for less common attributes (e.g. flashlight_difficulty under HDFL)." + }, + { + "name": "aim_difficulty", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. osu!standard only." + }, + { + "name": "speed_difficulty", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. osu!standard only." + }, + { + "name": "flashlight_difficulty", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. osu!standard only; only populated when an FL-modified row is calculated." + }, + { + "name": "slider_factor", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. osu!standard only." + }, + { + "name": "speed_note_count", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. osu!standard only." + }, + { + "name": "great_hit_window", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. Perfect-hit (300) window in ms. Populated for osu!standard and taiko; null for catch and mania (rosu-pp 4.x does not expose hit windows on those attribute structs)." + }, + { + "name": "ok_hit_window", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. 100/ok hit window in ms. Populated for osu!standard and taiko; null for catch and mania." + }, + { + "name": "meh_hit_window", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. 50/meh hit window in ms. osu!standard only — taiko has no meh judgement, mania/catch unavailable." + }, + { + "name": "ar", + "type": "float64", + "nullable": true, + "description": "Effective AR after mods (osu!standard only)." + }, + { + "name": "od", + "type": "float64", + "nullable": true, + "description": "Effective OD after mods (osu!standard only). rosu-pp 4.x does not expose post-mod OD on the taiko/catch/mania attribute structs." + }, + { + "name": "hp", + "type": "float64", + "nullable": true, + "description": "Effective HP after mods (osu!standard only)." + }, + { + "name": "stamina", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. taiko only." + }, + { + "name": "rhythm", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. taiko only." + }, + { + "name": "color", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. taiko only." + }, + { + "name": "reading", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. taiko only." + }, + { + "name": "mono_stamina_factor", + "type": "float64", + "nullable": true, + "description": "Hoisted from attributes_json. taiko only." + }, + { + "name": "n_circles", + "type": "int32", + "nullable": true, + "description": "Object counts (osu! / catch). Hoisted from attributes_json." + }, + { + "name": "n_sliders", + "type": "int32", + "nullable": true, + "description": "Object counts (osu! / catch). Hoisted from attributes_json." + }, + { + "name": "n_spinners", + "type": "int32", + "nullable": true, + "description": "Object counts (osu! / catch). Hoisted from attributes_json." + }, + { + "name": "n_fruits", + "type": "int32", + "nullable": true, + "description": "Catch only." + }, + { + "name": "n_droplets", + "type": "int32", + "nullable": true, + "description": "Catch only." + }, + { + "name": "n_tiny_droplets", + "type": "int32", + "nullable": true, + "description": "Catch only." + }, + { + "name": "n_objects", + "type": "int32", + "nullable": true, + "description": "Mania only." + }, + { + "name": "n_hold_notes", + "type": "int32", + "nullable": true, + "description": "Mania only." + }, + { + "name": "is_convert", + "type": "bool", + "nullable": true, + "description": "True when the diff was calculated against an osu!standard map converted to another ruleset." + }, + { + "name": "calculation_status", + "type": "string", + "nullable": false, + "description": "ok | failed." + }, + { + "name": "calculation_error", + "type": "string", + "nullable": true + } + ] + } + } +} diff --git a/schemas/v1/hit_objects.schema.json b/schemas/v1/hit_objects.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..f252234e1669b3c841265279c710c41e76a76004 --- /dev/null +++ b/schemas/v1/hit_objects.schema.json @@ -0,0 +1,611 @@ +{ + "schema_version": "v1", + "description": "Hit object tables. Common columns plus four ruleset-specific projection tables. Do NOT try to unify osu/taiko/catch/mania into one schema; each has different semantics for x/y/columns/durations.", + "tables": { + "hit_objects_common": { + "description": "Raw, ruleset-agnostic representation of every hit object. One row per object across all rulesets.", + "row_grain": "one hit object", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "partition_keys": [ + "ruleset", + "key_count" + ], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "ruleset", + "type": "string", + "nullable": false, + "description": "osu | taiko | catch | mania." + }, + { + "name": "key_count", + "type": "int32", + "nullable": false, + "description": "Mania key count derived from circle_size (round, clamped 1..18). Sentinel 0 for non-mania rulesets. Filter `key_count > 0` to scope to mania, or `WHERE ruleset='mania' AND key_count=4` for 4K mode-mixed loads." + }, + { + "name": "object_index", + "type": "int32", + "nullable": false + }, + { + "name": "x", + "type": "int32", + "nullable": false, + "description": "Raw X from .osu (0-512); meaning differs by ruleset." + }, + { + "name": "y", + "type": "int32", + "nullable": false, + "description": "Raw Y from .osu (0-384); meaning differs by ruleset." + }, + { + "name": "time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": true, + "description": "Object tail time when present: sliders/spinners/drumrolls/holds; null for instant objects." + }, + { + "name": "type_flags", + "type": "int32", + "nullable": false, + "description": "Bitfield: 1=circle, 2=slider, 8=spinner, 128=mania hold, 4=new combo, etc." + }, + { + "name": "hit_sound_flags", + "type": "int32", + "nullable": false, + "description": "Bitfield: 1=normal, 2=whistle, 4=finish, 8=clap." + }, + { + "name": "common_object_kind", + "type": "string", + "nullable": false, + "description": "circle | slider | spinner | hold | unknown." + }, + { + "name": "is_new_combo", + "type": "bool", + "nullable": false + }, + { + "name": "combo_skip", + "type": "int32", + "nullable": true, + "description": "(type_flags >> 4) & 7." + }, + { + "name": "raw_params", + "type": "list", + "nullable": true, + "description": "Ruleset-specific tail params, comma-split (slider curve, hold end, hit sample, etc.)." + }, + { + "name": "raw_line", + "type": "string", + "nullable": false + }, + { + "name": "parse_status", + "type": "string", + "nullable": false + }, + { + "name": "audio_blob_sha256", + "type": "string", + "nullable": true, + "description": "Denormalized from beatmaps.audio_blob_sha256 so audio-conditioned models can stream hit objects partition-pruned without a join. Null when the source beatmap has no resolved audio." + } + ] + }, + "hit_objects_osu": { + "description": "osu!standard projection. One row per circle/slider/spinner.", + "row_grain": "one hit object", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "object_index", + "type": "int32", + "nullable": false + }, + { + "name": "osu_kind", + "type": "string", + "nullable": false, + "description": "circle | slider | spinner." + }, + { + "name": "start_time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": true, + "description": "For sliders, computed from pixel_length / SV; for spinners, the explicit end. Null for circles." + }, + { + "name": "x", + "type": "int32", + "nullable": false + }, + { + "name": "y", + "type": "int32", + "nullable": false + }, + { + "name": "slider_curve_type", + "type": "string", + "nullable": true, + "description": "B (bezier), C (catmull), L (linear), P (perfect-circle)." + }, + { + "name": "slider_control_points_json", + "type": "string", + "nullable": true, + "description": "JSON array of [x,y] points, anchor-aware." + }, + { + "name": "slider_repeats", + "type": "int32", + "nullable": true + }, + { + "name": "slider_pixel_length", + "type": "float64", + "nullable": true + }, + { + "name": "edge_sounds_raw", + "type": "string", + "nullable": true, + "description": "Pipe-delimited integers from the .osu line." + }, + { + "name": "edge_sets_raw", + "type": "string", + "nullable": true + }, + { + "name": "edge_sounds", + "type": "list", + "nullable": true, + "description": "Parsed edge_sounds_raw — one bitfield per slider edge (head, internal repeats, tail). Length is slider_repeats+1 when present." + }, + { + "name": "edge_sets", + "type": "list", + "nullable": true, + "description": "Parsed edge_sets_raw — one 'normalSet:additionSet' string per slider edge, paired with edge_sounds." + }, + { + "name": "hit_sample_raw", + "type": "string", + "nullable": true, + "description": "Trailing colon-delimited 'normalSet:additionSet:index:volume:filename'." + }, + { + "name": "hit_sample_normal_set", + "type": "int32", + "nullable": true, + "description": "Parsed first colon-field of hit_sample_raw. 0=auto, 1=normal, 2=soft, 3=drum." + }, + { + "name": "hit_sample_addition_set", + "type": "int32", + "nullable": true, + "description": "Parsed second colon-field; 0=match-normal-set." + }, + { + "name": "hit_sample_index", + "type": "int32", + "nullable": true, + "description": "Custom sample index (0=use timing point's). Per-object override." + }, + { + "name": "hit_sample_volume", + "type": "int32", + "nullable": true, + "description": "Per-object volume override (0=use timing point's, else 1-100)." + }, + { + "name": "hit_sample_filename", + "type": "string", + "nullable": true, + "description": "Per-object explicit hitsound filename, when set in the trailing colon field." + }, + { + "name": "audio_blob_sha256", + "type": "string", + "nullable": true, + "description": "Denormalized from beatmaps.audio_blob_sha256 so audio-conditioned models can stream hit objects partition-pruned without a join. Null when the source beatmap has no resolved audio." + } + ] + }, + "hit_objects_taiko": { + "description": "osu!taiko projection. One row per don/kat/drumroll/denden.", + "row_grain": "one hit object", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "object_index", + "type": "int32", + "nullable": false + }, + { + "name": "taiko_kind", + "type": "string", + "nullable": false, + "description": "don | kat | drumroll | denden | unknown." + }, + { + "name": "start_time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": true, + "description": "Drumroll/denden end time." + }, + { + "name": "is_big", + "type": "bool", + "nullable": false, + "description": "Finish flag → big don/kat." + }, + { + "name": "hit_sound_flags", + "type": "int32", + "nullable": false + }, + { + "name": "inherited_sample_set", + "type": "int32", + "nullable": true, + "description": "Sample set from active timing point at start_time_ms." + }, + { + "name": "sample_index", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_raw", + "type": "string", + "nullable": true + }, + { + "name": "hit_sample_normal_set", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_addition_set", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_index", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_volume", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_filename", + "type": "string", + "nullable": true + }, + { + "name": "audio_blob_sha256", + "type": "string", + "nullable": true, + "description": "Denormalized from beatmaps.audio_blob_sha256 so audio-conditioned models can stream hit objects partition-pruned without a join. Null when the source beatmap has no resolved audio." + } + ] + }, + "hit_objects_catch": { + "description": "osu!catch / ctb projection. Stores raw geometry; derived fruit/banana positions can be computed downstream.", + "row_grain": "one hit object", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "partition_keys": [], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "object_index", + "type": "int32", + "nullable": false + }, + { + "name": "catch_kind", + "type": "string", + "nullable": false, + "description": "fruit | juice_stream | banana_shower | unknown." + }, + { + "name": "start_time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": true + }, + { + "name": "x", + "type": "int32", + "nullable": false + }, + { + "name": "y", + "type": "int32", + "nullable": false, + "description": "Stored even though catch ignores Y, to match raw line." + }, + { + "name": "slider_curve_type", + "type": "string", + "nullable": true + }, + { + "name": "slider_control_points_json", + "type": "string", + "nullable": true + }, + { + "name": "slider_repeats", + "type": "int32", + "nullable": true + }, + { + "name": "slider_pixel_length", + "type": "float64", + "nullable": true + }, + { + "name": "hit_sample_raw", + "type": "string", + "nullable": true + }, + { + "name": "hit_sample_normal_set", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_addition_set", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_index", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_volume", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_filename", + "type": "string", + "nullable": true + }, + { + "name": "audio_blob_sha256", + "type": "string", + "nullable": true, + "description": "Denormalized from beatmaps.audio_blob_sha256 so audio-conditioned models can stream hit objects partition-pruned without a join. Null when the source beatmap has no resolved audio." + } + ] + }, + "hit_objects_mania": { + "description": "osu!mania projection. One row per note/hold.", + "row_grain": "one hit object", + "primary_key": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "partition_keys": [ + "key_count" + ], + "sort_keys": [ + "beatmap_uid", + "set_revision_id", + "object_index" + ], + "columns": [ + { + "name": "beatmap_uid", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "object_index", + "type": "int32", + "nullable": false + }, + { + "name": "mania_kind", + "type": "string", + "nullable": false, + "description": "note | hold." + }, + { + "name": "start_time_ms", + "type": "int32", + "nullable": false + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": true, + "description": "Hold end; null for note." + }, + { + "name": "x", + "type": "int32", + "nullable": false, + "description": "Raw X (0-512)." + }, + { + "name": "column_index", + "type": "int32", + "nullable": false, + "description": "floor(x * key_count / 512)." + }, + { + "name": "key_count", + "type": "int32", + "nullable": false, + "description": "Derived from circle_size." + }, + { + "name": "circle_size", + "type": "float32", + "nullable": false, + "description": "Original CS for traceability." + }, + { + "name": "hit_sound_flags", + "type": "int32", + "nullable": false + }, + { + "name": "hit_sample_raw", + "type": "string", + "nullable": true + }, + { + "name": "hit_sample_normal_set", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_addition_set", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_index", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_volume", + "type": "int32", + "nullable": true + }, + { + "name": "hit_sample_filename", + "type": "string", + "nullable": true + }, + { + "name": "audio_blob_sha256", + "type": "string", + "nullable": true, + "description": "Denormalized from beatmaps.audio_blob_sha256 so audio-conditioned models can stream hit objects partition-pruned without a join. Null when the source beatmap has no resolved audio." + } + ] + } + } +} diff --git a/schemas/v1/logical_files.schema.json b/schemas/v1/logical_files.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..7c600c0883d1a044eb4527a89f06cec527bf15d7 --- /dev/null +++ b/schemas/v1/logical_files.schema.json @@ -0,0 +1,150 @@ +{ + "schema_version": "v1", + "description": "Per-revision logical file table. One row per file as it appeared inside a beatmapset revision; many logical_files may share the same blob_sha256. Compact v1 stores the bytes in the original .osz archive, not in a published extracted blob store.", + "tables": { + "logical_files": { + "description": "One row per (set_revision_id, archive member). Preserves original path metadata and logical content hashes for archive-member lookup.", + "row_grain": "one archive member", + "primary_key": [ + "logical_file_id" + ], + "partition_keys": [], + "sort_keys": [ + "set_revision_id", + "path_key" + ], + "columns": [ + { + "name": "logical_file_id", + "type": "string", + "nullable": false, + "description": "Stable id: '::'; duplicate path keys in one archive append '::memberNNNN' to keep one id per archive member." + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false, + "description": "FK to set_revisions." + }, + { + "name": "archive_revision_id", + "type": "string", + "nullable": false, + "description": "FK to archive_revisions." + }, + { + "name": "beatmapset_id", + "type": "int64", + "nullable": true, + "description": "Convenience denormalization." + }, + { + "name": "path_raw", + "type": "string", + "nullable": true, + "description": "Decoded path as seen in the archive, if decodable." + }, + { + "name": "path_posix", + "type": "string", + "nullable": true, + "description": "path_raw with backslashes normalized to forward slashes." + }, + { + "name": "path_nfc", + "type": "string", + "nullable": true, + "description": "Unicode-NFC-normalized path_posix." + }, + { + "name": "path_key", + "type": "string", + "nullable": false, + "description": "casefold(path_nfc). LOOKUP ONLY; never use for filesystem materialization." + }, + { + "name": "path_raw_bytes_base64", + "type": "string", + "nullable": true, + "description": "Base64 of original path bytes when undecodable. Source of truth for reconstruction." + }, + { + "name": "blob_sha256", + "type": "string", + "nullable": false, + "description": "SHA-256 of this archive member's uncompressed bytes." + }, + { + "name": "size_bytes", + "type": "int64", + "nullable": false, + "description": "Uncompressed archive member size." + }, + { + "name": "extension", + "type": "string", + "nullable": true, + "description": "Lowercase extension parsed from path_posix." + }, + { + "name": "mime_guess", + "type": "string", + "nullable": true + }, + { + "name": "media_kind", + "type": "string", + "nullable": false, + "description": "Coarse media class inferred from the archive member." + }, + { + "name": "roles", + "type": "list", + "nullable": false, + "description": "Subset of: beatmap_osu, storyboard_osb, song_audio, background_image, video, storyboard_sprite, storyboard_animation_frame, storyboard_audio_sample, custom_hitsound, custom_skin_asset, font, unused, unknown." + }, + { + "name": "is_referenced", + "type": "bool", + "nullable": false, + "description": "True if any asset_references row resolved to this logical_file_id." + }, + { + "name": "is_unreferenced_extra", + "type": "bool", + "nullable": false, + "description": "True for files present in the archive but not referenced anywhere." + }, + { + "name": "crc32", + "type": "string", + "nullable": true, + "description": "ZIP CRC-32 of the member content (hex)." + }, + { + "name": "compressed_size", + "type": "int64", + "nullable": true, + "description": "ZIP compressed size." + }, + { + "name": "uncompressed_size", + "type": "int64", + "nullable": true, + "description": "ZIP uncompressed size." + }, + { + "name": "zip_mtime", + "type": "timestamp[ms]", + "nullable": true + }, + { + "name": "path_warning", + "type": "string", + "nullable": true, + "description": "One of: path_traversal, absolute_path, duplicate_path_key, invalid_unicode, zero_byte_file, case_collision, unsafe_name; semicolon-separated if multiple." + } + ] + } + } +} diff --git a/schemas/v1/problems.schema.json b/schemas/v1/problems.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..3cb531611a05a2a764761ae933a50c76fb7cced5 --- /dev/null +++ b/schemas/v1/problems.schema.json @@ -0,0 +1,80 @@ +{ + "schema_version": "v1", + "description": "Single problems table for everything that went wrong during ingest, parsing, reference resolution, or media probing. Failure to write a problem is itself a bug.", + "tables": { + "problems": { + "description": "Append-only problem log. Rows are scoped by set_revision_id (always), beatmap_uid (when applicable), and logical_file_id (when applicable).", + "row_grain": "one problem occurrence", + "primary_key": [ + "problem_id" + ], + "partition_keys": [], + "sort_keys": [ + "set_revision_id", + "category", + "problem_id" + ], + "columns": [ + { + "name": "problem_id", + "type": "string", + "nullable": false, + "description": "'::::'." + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "beatmap_uid", + "type": "string", + "nullable": true + }, + { + "name": "logical_file_id", + "type": "string", + "nullable": true + }, + { + "name": "severity", + "type": "string", + "nullable": false, + "description": "info | warning | error | fatal." + }, + { + "name": "category", + "type": "string", + "nullable": false, + "description": "zip | path | parse | reference | media_probe | rosu_pp | schema | io | junk. The 'junk' category covers archive members deliberately skipped as noise (Thumbs.db, .DS_Store, __MACOSX/, *.bak, etc.) and zero-byte files; these have severity='info'." + }, + { + "name": "message", + "type": "string", + "nullable": false + }, + { + "name": "raw_context", + "type": "string", + "nullable": true, + "description": "Free-form context: failing line, candidate paths, etc." + }, + { + "name": "parser_name", + "type": "string", + "nullable": true + }, + { + "name": "parser_version", + "type": "string", + "nullable": true + }, + { + "name": "ingest_batch_id", + "type": "string", + "nullable": false + } + ] + } + } +} diff --git a/schemas/v1/references.schema.json b/schemas/v1/references.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..5e24293f6a80be6bbd9de1e3152c2e2e95d4b8b6 --- /dev/null +++ b/schemas/v1/references.schema.json @@ -0,0 +1,130 @@ +{ + "schema_version": "v1", + "description": "Asset reference table. One row per reference from a source file (a .osu, .osb, etc.) to another asset (audio, image, video, hitsound, sprite). Records the resolution outcome.", + "tables": { + "asset_references": { + "description": "All references from .osu/.osb/etc. into other files in the beatmapset, with the resolution attempt result.", + "row_grain": "one reference", + "primary_key": [ + "reference_id" + ], + "partition_keys": [], + "sort_keys": [ + "set_revision_id", + "source_logical_file_id", + "reference_id" + ], + "columns": [ + { + "name": "reference_id", + "type": "string", + "nullable": false, + "description": "'::ref::::'." + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "beatmap_uid", + "type": "string", + "nullable": true, + "description": "Set when the reference originates from a .osu (not from .osb)." + }, + { + "name": "source_logical_file_id", + "type": "string", + "nullable": false, + "description": "FK to logical_files (the file that contains the reference)." + }, + { + "name": "source_path", + "type": "string", + "nullable": false, + "description": "path_posix of source for convenience." + }, + { + "name": "source_section", + "type": "string", + "nullable": true, + "description": "[General] | [Events] | [HitObjects] | etc., or null for .osb." + }, + { + "name": "source_context", + "type": "string", + "nullable": false, + "description": "Free-form context, e.g. 'AudioFilename', 'background_event', 'storyboard_sprite_arg', 'hit_object_hit_sample'." + }, + { + "name": "reference_kind", + "type": "string", + "nullable": false, + "description": "audio_filename | background_image | video | storyboard_sprite | storyboard_animation | storyboard_animation_frame | storyboard_audio_sample | explicit_hitsound_sample | derived_custom_hitsound_sample | custom_skin_asset_conventional | font | unknown." + }, + { + "name": "raw_reference", + "type": "string", + "nullable": false, + "description": "Reference string exactly as written (with surrounding quotes if present)." + }, + { + "name": "normalized_reference", + "type": "string", + "nullable": false, + "description": "Slash-normalized." + }, + { + "name": "lookup_key", + "type": "string", + "nullable": false, + "description": "casefold(NFC(normalized_reference)) for matching against logical_files.path_key." + }, + { + "name": "resolved_logical_file_id", + "type": "string", + "nullable": true, + "description": "Set when resolution succeeded." + }, + { + "name": "resolved_blob_sha256", + "type": "string", + "nullable": true + }, + { + "name": "resolved_path_posix", + "type": "string", + "nullable": true + }, + { + "name": "resolution_status", + "type": "string", + "nullable": false, + "description": "found_exact | found_slash_normalized | found_unicode_normalized | found_casefolded | found_by_convention | missing | ambiguous | external_or_default_resource | invalid_path." + }, + { + "name": "resolution_strategy", + "type": "string", + "nullable": false, + "description": "Same value as resolution_status; kept distinct so future strategies can be differentiated from outcomes." + }, + { + "name": "is_missing", + "type": "bool", + "nullable": false + }, + { + "name": "is_ambiguous", + "type": "bool", + "nullable": false, + "description": "True when 2+ candidates differed only by case/Unicode form." + }, + { + "name": "raw_line", + "type": "string", + "nullable": true + } + ] + } + } +} diff --git a/schemas/v1/storyboards.schema.json b/schemas/v1/storyboards.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..821e6e8ddc242fc77402784e6bb7d1317bd47543 --- /dev/null +++ b/schemas/v1/storyboards.schema.json @@ -0,0 +1,362 @@ +{ + "schema_version": "v1", + "description": "Storyboard tables. Three logical levels: shared_set (.osb), difficulty_local (.osu [Events]), and effective (computed view = shared + local). Sources, elements, commands, and variables are normalized into separate tables.", + "tables": { + "storyboard_sources": { + "description": "One row per parsed storyboard source (one .osb per set, plus one per .osu with [Events] storyboard lines).", + "row_grain": "one storyboard source", + "primary_key": [ + "storyboard_source_id" + ], + "partition_keys": [], + "sort_keys": [ + "storyboard_source_id" + ], + "columns": [ + { + "name": "storyboard_source_id", + "type": "string", + "nullable": false, + "description": "'::sb::::'." + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "beatmap_uid", + "type": "string", + "nullable": true, + "description": "Set only when scope='difficulty_local'." + }, + { + "name": "scope", + "type": "string", + "nullable": false, + "description": "shared_set | difficulty_local." + }, + { + "name": "source_logical_file_id", + "type": "string", + "nullable": false, + "description": "FK to logical_files." + }, + { + "name": "source_path", + "type": "string", + "nullable": false, + "description": "path_posix of the .osb or .osu." + }, + { + "name": "source_blob_sha256", + "type": "string", + "nullable": false + }, + { + "name": "parser_name", + "type": "string", + "nullable": false, + "description": "e.g. 'rosu-storyboard'." + }, + { + "name": "parser_version", + "type": "string", + "nullable": false + }, + { + "name": "parse_status", + "type": "string", + "nullable": false + }, + { + "name": "parse_error", + "type": "string", + "nullable": true + } + ] + }, + "storyboard_elements": { + "description": "One row per storyboard element (sprite, animation, sample).", + "row_grain": "one element", + "primary_key": [ + "storyboard_element_id" + ], + "partition_keys": [], + "sort_keys": [ + "storyboard_source_id", + "storyboard_element_id" + ], + "columns": [ + { + "name": "storyboard_element_id", + "type": "string", + "nullable": false, + "description": "'::'." + }, + { + "name": "storyboard_source_id", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "beatmap_uid", + "type": "string", + "nullable": true + }, + { + "name": "element_index", + "type": "int32", + "nullable": false + }, + { + "name": "layer", + "type": "string", + "nullable": false, + "description": "Background | Fail | Pass | Foreground | Overlay | Video | Sample." + }, + { + "name": "origin", + "type": "string", + "nullable": true, + "description": "TopLeft, Centre, etc." + }, + { + "name": "element_kind", + "type": "string", + "nullable": false, + "description": "sprite | animation | sample | unknown." + }, + { + "name": "file_reference_raw", + "type": "string", + "nullable": true, + "description": "Filename as written in the storyboard line." + }, + { + "name": "file_reference_id", + "type": "string", + "nullable": true, + "description": "FK to asset_references." + }, + { + "name": "resolved_blob_sha256", + "type": "string", + "nullable": true + }, + { + "name": "x", + "type": "float32", + "nullable": true + }, + { + "name": "y", + "type": "float32", + "nullable": true + }, + { + "name": "frame_count", + "type": "int32", + "nullable": true, + "description": "Animation only." + }, + { + "name": "frame_delay", + "type": "float32", + "nullable": true, + "description": "Animation only (ms per frame)." + }, + { + "name": "loop_type", + "type": "string", + "nullable": true, + "description": "LoopForever | LoopOnce." + }, + { + "name": "sample_time_ms", + "type": "int32", + "nullable": true, + "description": "Sample-only: trigger time." + }, + { + "name": "sample_volume", + "type": "int32", + "nullable": true + }, + { + "name": "raw_line", + "type": "string", + "nullable": false + }, + { + "name": "parse_status", + "type": "string", + "nullable": false + } + ] + }, + "storyboard_commands": { + "description": "One row per command attached to a storyboard element. Commands can nest under L (loop) / T (trigger); track parent_command_id when so.", + "row_grain": "one command", + "primary_key": [ + "storyboard_command_id" + ], + "partition_keys": [], + "sort_keys": [ + "storyboard_source_id", + "storyboard_element_id", + "command_index" + ], + "columns": [ + { + "name": "storyboard_command_id", + "type": "string", + "nullable": false + }, + { + "name": "storyboard_element_id", + "type": "string", + "nullable": false + }, + { + "name": "storyboard_source_id", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "beatmap_uid", + "type": "string", + "nullable": true, + "description": "Set when scope='difficulty_local'." + }, + { + "name": "scope", + "type": "string", + "nullable": false, + "description": "shared_set | difficulty_local." + }, + { + "name": "element_index", + "type": "int32", + "nullable": false + }, + { + "name": "command_index", + "type": "int32", + "nullable": false + }, + { + "name": "parent_command_id", + "type": "string", + "nullable": true, + "description": "Set when nested under L/T." + }, + { + "name": "command_code", + "type": "string", + "nullable": false, + "description": "F | M | MX | MY | S | V | R | C | P | L | T." + }, + { + "name": "easing", + "type": "int32", + "nullable": true + }, + { + "name": "start_time_ms", + "type": "int32", + "nullable": true + }, + { + "name": "end_time_ms", + "type": "int32", + "nullable": true + }, + { + "name": "params_json", + "type": "string", + "nullable": false, + "description": "JSON-encoded command parameters (start/end value tuples)." + }, + { + "name": "raw_line", + "type": "string", + "nullable": false + }, + { + "name": "parse_status", + "type": "string", + "nullable": false + } + ] + }, + "storyboard_variables": { + "description": "[Variables] section preservation. Even if the parser expanded these in commands, keep raw definitions for round-trip.", + "row_grain": "one variable definition", + "primary_key": [ + "storyboard_source_id", + "variable_name" + ], + "partition_keys": [], + "sort_keys": [ + "storyboard_source_id", + "line_index" + ], + "columns": [ + { + "name": "storyboard_source_id", + "type": "string", + "nullable": false + }, + { + "name": "set_revision_id", + "type": "string", + "nullable": false + }, + { + "name": "beatmap_uid", + "type": "string", + "nullable": true, + "description": "Set when scope='difficulty_local'." + }, + { + "name": "scope", + "type": "string", + "nullable": false, + "description": "shared_set | difficulty_local." + }, + { + "name": "variable_name", + "type": "string", + "nullable": false, + "description": "Including leading '$'." + }, + { + "name": "raw_value", + "type": "string", + "nullable": false + }, + { + "name": "expanded_value", + "type": "string", + "nullable": true + }, + { + "name": "line_index", + "type": "int32", + "nullable": false + } + ] + } + } +} diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000000000000000000000000000000000000..fc41ed55f1474c1ec5799da47ce454f555be916f --- /dev/null +++ b/uv.lock @@ -0,0 +1,1349 @@ +version = 1 +revision = 3 +requires-python = ">=3.12" +resolution-markers = [ + "python_full_version >= '3.14' and sys_platform == 'win32'", + "python_full_version >= '3.14' and sys_platform == 'emscripten'", + "python_full_version >= '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'", + "python_full_version < '3.14' and sys_platform == 'win32'", + "python_full_version < '3.14' and sys_platform == 'emscripten'", + "python_full_version < '3.14' and sys_platform != 'emscripten' and sys_platform != 'win32'", +] + +[[package]] +name = "aiohappyeyeballs" +version = "2.6.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/26/30/f84a107a9c4331c14b2b586036f40965c128aa4fee4dda5d3d51cb14ad54/aiohappyeyeballs-2.6.1.tar.gz", hash = "sha256:c3f9d0113123803ccadfdf3f0faa505bc78e6a72d1cc4806cbd719826e943558", size = 22760, upload-time = "2025-03-12T01:42:48.764Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0f/15/5bf3b99495fb160b63f95972b81750f18f7f4e02ad051373b669d17d44f2/aiohappyeyeballs-2.6.1-py3-none-any.whl", hash = "sha256:f349ba8f4b75cb25c99c5c2d84e997e485204d2902a9597802b0371f09331fb8", size = 15265, upload-time = "2025-03-12T01:42:47.083Z" }, +] + +[[package]] +name = "aiohttp" +version = "3.13.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "aiohappyeyeballs" }, + { name = "aiosignal" }, + { name = "attrs" }, + { name = "frozenlist" }, + { name = "multidict" }, + { name = "propcache" }, + { name = "yarl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/77/9a/152096d4808df8e4268befa55fba462f440f14beab85e8ad9bf990516918/aiohttp-3.13.5.tar.gz", hash = "sha256:9d98cc980ecc96be6eb4c1994ce35d28d8b1f5e5208a23b421187d1209dbb7d1", size = 7858271, upload-time = "2026-03-31T22:01:03.343Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/be/6f/353954c29e7dcce7cf00280a02c75f30e133c00793c7a2ed3776d7b2f426/aiohttp-3.13.5-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:023ecba036ddd840b0b19bf195bfae970083fd7024ce1ac22e9bba90464620e9", size = 748876, upload-time = "2026-03-31T21:57:36.319Z" }, + { url = "https://files.pythonhosted.org/packages/f5/1b/428a7c64687b3b2e9cd293186695affc0e1e54a445d0361743b231f11066/aiohttp-3.13.5-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:15c933ad7920b7d9a20de151efcd05a6e38302cbf0e10c9b2acb9a42210a2416", size = 499557, upload-time = "2026-03-31T21:57:38.236Z" }, + { url = "https://files.pythonhosted.org/packages/29/47/7be41556bfbb6917069d6a6634bb7dd5e163ba445b783a90d40f5ac7e3a7/aiohttp-3.13.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ab2899f9fa2f9f741896ebb6fa07c4c883bfa5c7f2ddd8cf2aafa86fa981b2d2", size = 500258, upload-time = "2026-03-31T21:57:39.923Z" }, + { url = "https://files.pythonhosted.org/packages/67/84/c9ecc5828cb0b3695856c07c0a6817a99d51e2473400f705275a2b3d9239/aiohttp-3.13.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a60eaa2d440cd4707696b52e40ed3e2b0f73f65be07fd0ef23b6b539c9c0b0b4", size = 1749199, upload-time = "2026-03-31T21:57:41.938Z" }, + { url = "https://files.pythonhosted.org/packages/f0/d3/3c6d610e66b495657622edb6ae7c7fd31b2e9086b4ec50b47897ad6042a9/aiohttp-3.13.5-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:55b3bdd3292283295774ab585160c4004f4f2f203946997f49aac032c84649e9", size = 1721013, upload-time = "2026-03-31T21:57:43.904Z" }, + { url = "https://files.pythonhosted.org/packages/49/a0/24409c12217456df0bae7babe3b014e460b0b38a8e60753d6cb339f6556d/aiohttp-3.13.5-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c2b2355dc094e5f7d45a7bb262fe7207aa0460b37a0d87027dcf21b5d890e7d5", size = 1781501, upload-time = "2026-03-31T21:57:46.285Z" }, + { url = "https://files.pythonhosted.org/packages/98/9d/b65ec649adc5bccc008b0957a9a9c691070aeac4e41cea18559fef49958b/aiohttp-3.13.5-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b38765950832f7d728297689ad78f5f2cf79ff82487131c4d26fe6ceecdc5f8e", size = 1878981, upload-time = "2026-03-31T21:57:48.734Z" }, + { url = "https://files.pythonhosted.org/packages/57/d8/8d44036d7eb7b6a8ec4c5494ea0c8c8b94fbc0ed3991c1a7adf230df03bf/aiohttp-3.13.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b18f31b80d5a33661e08c89e202edabf1986e9b49c42b4504371daeaa11b47c1", size = 1767934, upload-time = "2026-03-31T21:57:51.171Z" }, + { url = "https://files.pythonhosted.org/packages/31/04/d3f8211f273356f158e3464e9e45484d3fb8c4ce5eb2f6fe9405c3273983/aiohttp-3.13.5-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:33add2463dde55c4f2d9635c6ab33ce154e5ecf322bd26d09af95c5f81cfa286", size = 1566671, upload-time = "2026-03-31T21:57:53.326Z" }, + { url = "https://files.pythonhosted.org/packages/41/db/073e4ebe00b78e2dfcacff734291651729a62953b48933d765dc513bf798/aiohttp-3.13.5-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:327cc432fdf1356fb4fbc6fe833ad4e9f6aacb71a8acaa5f1855e4b25910e4a9", size = 1705219, upload-time = "2026-03-31T21:57:55.385Z" }, + { url = "https://files.pythonhosted.org/packages/48/45/7dfba71a2f9fd97b15c95c06819de7eb38113d2cdb6319669195a7d64270/aiohttp-3.13.5-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:7c35b0bf0b48a70b4cb4fc5d7bed9b932532728e124874355de1a0af8ec4bc88", size = 1743049, upload-time = "2026-03-31T21:57:57.341Z" }, + { url = "https://files.pythonhosted.org/packages/18/71/901db0061e0f717d226386a7f471bb59b19566f2cae5f0d93874b017271f/aiohttp-3.13.5-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:df23d57718f24badef8656c49743e11a89fd6f5358fa8a7b96e728fda2abf7d3", size = 1749557, upload-time = "2026-03-31T21:57:59.626Z" }, + { url = "https://files.pythonhosted.org/packages/08/d5/41eebd16066e59cd43728fe74bce953d7402f2b4ddfdfef2c0e9f17ca274/aiohttp-3.13.5-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:02e048037a6501a5ec1f6fc9736135aec6eb8a004ce48838cb951c515f32c80b", size = 1558931, upload-time = "2026-03-31T21:58:01.972Z" }, + { url = "https://files.pythonhosted.org/packages/30/e6/4a799798bf05740e66c3a1161079bda7a3dd8e22ca392481d7a7f9af82a6/aiohttp-3.13.5-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:31cebae8b26f8a615d2b546fee45d5ffb76852ae6450e2a03f42c9102260d6fe", size = 1774125, upload-time = "2026-03-31T21:58:04.007Z" }, + { url = "https://files.pythonhosted.org/packages/84/63/7749337c90f92bc2cb18f9560d67aa6258c7060d1397d21529b8004fcf6f/aiohttp-3.13.5-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:888e78eb5ca55a615d285c3c09a7a91b42e9dd6fc699b166ebd5dee87c9ccf14", size = 1732427, upload-time = "2026-03-31T21:58:06.337Z" }, + { url = "https://files.pythonhosted.org/packages/98/de/cf2f44ff98d307e72fb97d5f5bbae3bfcb442f0ea9790c0bf5c5c2331404/aiohttp-3.13.5-cp312-cp312-win32.whl", hash = "sha256:8bd3ec6376e68a41f9f95f5ed170e2fcf22d4eb27a1f8cb361d0508f6e0557f3", size = 433534, upload-time = "2026-03-31T21:58:08.712Z" }, + { url = "https://files.pythonhosted.org/packages/aa/ca/eadf6f9c8fa5e31d40993e3db153fb5ed0b11008ad5d9de98a95045bed84/aiohttp-3.13.5-cp312-cp312-win_amd64.whl", hash = "sha256:110e448e02c729bcebb18c60b9214a87ba33bac4a9fa5e9a5f139938b56c6cb1", size = 460446, upload-time = "2026-03-31T21:58:10.945Z" }, + { url = "https://files.pythonhosted.org/packages/78/e9/d76bf503005709e390122d34e15256b88f7008e246c4bdbe915cd4f1adce/aiohttp-3.13.5-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:a5029cc80718bbd545123cd8fe5d15025eccaaaace5d0eeec6bd556ad6163d61", size = 742930, upload-time = "2026-03-31T21:58:13.155Z" }, + { url = "https://files.pythonhosted.org/packages/57/00/4b7b70223deaebd9bb85984d01a764b0d7bd6526fcdc73cca83bcbe7243e/aiohttp-3.13.5-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:4bb6bf5811620003614076bdc807ef3b5e38244f9d25ca5fe888eaccea2a9832", size = 496927, upload-time = "2026-03-31T21:58:15.073Z" }, + { url = "https://files.pythonhosted.org/packages/9c/f5/0fb20fb49f8efdcdce6cd8127604ad2c503e754a8f139f5e02b01626523f/aiohttp-3.13.5-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a84792f8631bf5a94e52d9cc881c0b824ab42717165a5579c760b830d9392ac9", size = 497141, upload-time = "2026-03-31T21:58:17.009Z" }, + { url = "https://files.pythonhosted.org/packages/3b/86/b7c870053e36a94e8951b803cb5b909bfbc9b90ca941527f5fcafbf6b0fa/aiohttp-3.13.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:57653eac22c6a4c13eb22ecf4d673d64a12f266e72785ab1c8b8e5940d0e8090", size = 1732476, upload-time = "2026-03-31T21:58:18.925Z" }, + { url = "https://files.pythonhosted.org/packages/b5/e5/4e161f84f98d80c03a238671b4136e6530453d65262867d989bbe78244d0/aiohttp-3.13.5-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:e5e5f7debc7a57af53fdf5c5009f9391d9f4c12867049d509bf7bb164a6e295b", size = 1706507, upload-time = "2026-03-31T21:58:21.094Z" }, + { url = "https://files.pythonhosted.org/packages/d4/56/ea11a9f01518bd5a2a2fcee869d248c4b8a0cfa0bb13401574fa31adf4d4/aiohttp-3.13.5-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c719f65bebcdf6716f10e9eff80d27567f7892d8988c06de12bbbd39307c6e3a", size = 1773465, upload-time = "2026-03-31T21:58:23.159Z" }, + { url = "https://files.pythonhosted.org/packages/eb/40/333ca27fb74b0383f17c90570c748f7582501507307350a79d9f9f3c6eb1/aiohttp-3.13.5-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d97f93fdae594d886c5a866636397e2bcab146fd7a132fd6bb9ce182224452f8", size = 1873523, upload-time = "2026-03-31T21:58:25.59Z" }, + { url = "https://files.pythonhosted.org/packages/f0/d2/e2f77eef1acb7111405433c707dc735e63f67a56e176e72e9e7a2cd3f493/aiohttp-3.13.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3df334e39d4c2f899a914f1dba283c1aadc311790733f705182998c6f7cae665", size = 1754113, upload-time = "2026-03-31T21:58:27.624Z" }, + { url = "https://files.pythonhosted.org/packages/fb/56/3f653d7f53c89669301ec9e42c95233e2a0c0a6dd051269e6e678db4fdb0/aiohttp-3.13.5-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fe6970addfea9e5e081401bcbadf865d2b6da045472f58af08427e108d618540", size = 1562351, upload-time = "2026-03-31T21:58:29.918Z" }, + { url = "https://files.pythonhosted.org/packages/ec/a6/9b3e91eb8ae791cce4ee736da02211c85c6f835f1bdfac0594a8a3b7018c/aiohttp-3.13.5-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:7becdf835feff2f4f335d7477f121af787e3504b48b449ff737afb35869ba7bb", size = 1693205, upload-time = "2026-03-31T21:58:32.214Z" }, + { url = "https://files.pythonhosted.org/packages/98/fc/bfb437a99a2fcebd6b6eaec609571954de2ed424f01c352f4b5504371dd3/aiohttp-3.13.5-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:676e5651705ad5d8a70aeb8eb6936c436d8ebbd56e63436cb7dd9bb36d2a9a46", size = 1730618, upload-time = "2026-03-31T21:58:34.728Z" }, + { url = "https://files.pythonhosted.org/packages/e4/b6/c8534862126191a034f68153194c389addc285a0f1347d85096d349bbc15/aiohttp-3.13.5-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:9b16c653d38eb1a611cc898c41e76859ca27f119d25b53c12875fd0474ae31a8", size = 1745185, upload-time = "2026-03-31T21:58:36.909Z" }, + { url = "https://files.pythonhosted.org/packages/0b/93/4ca8ee2ef5236e2707e0fd5fecb10ce214aee1ff4ab307af9c558bda3b37/aiohttp-3.13.5-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:999802d5fa0389f58decd24b537c54aa63c01c3219ce17d1214cbda3c2b22d2d", size = 1557311, upload-time = "2026-03-31T21:58:39.38Z" }, + { url = "https://files.pythonhosted.org/packages/57/ae/76177b15f18c5f5d094f19901d284025db28eccc5ae374d1d254181d33f4/aiohttp-3.13.5-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:ec707059ee75732b1ba130ed5f9580fe10ff75180c812bc267ded039db5128c6", size = 1773147, upload-time = "2026-03-31T21:58:41.476Z" }, + { url = "https://files.pythonhosted.org/packages/01/a4/62f05a0a98d88af59d93b7fcac564e5f18f513cb7471696ac286db970d6a/aiohttp-3.13.5-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:2d6d44a5b48132053c2f6cd5c8cb14bc67e99a63594e336b0f2af81e94d5530c", size = 1730356, upload-time = "2026-03-31T21:58:44.049Z" }, + { url = "https://files.pythonhosted.org/packages/e4/85/fc8601f59dfa8c9523808281f2da571f8b4699685f9809a228adcc90838d/aiohttp-3.13.5-cp313-cp313-win32.whl", hash = "sha256:329f292ed14d38a6c4c435e465f48bebb47479fd676a0411936cc371643225cc", size = 432637, upload-time = "2026-03-31T21:58:46.167Z" }, + { url = "https://files.pythonhosted.org/packages/c0/1b/ac685a8882896acf0f6b31d689e3792199cfe7aba37969fa91da63a7fa27/aiohttp-3.13.5-cp313-cp313-win_amd64.whl", hash = "sha256:69f571de7500e0557801c0b51f4780482c0ec5fe2ac851af5a92cfce1af1cb83", size = 458896, upload-time = "2026-03-31T21:58:48.119Z" }, + { url = "https://files.pythonhosted.org/packages/5d/ce/46572759afc859e867a5bc8ec3487315869013f59281ce61764f76d879de/aiohttp-3.13.5-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:eb4639f32fd4a9904ab8fb45bf3383ba71137f3d9d4ba25b3b3f3109977c5b8c", size = 745721, upload-time = "2026-03-31T21:58:50.229Z" }, + { url = "https://files.pythonhosted.org/packages/13/fe/8a2efd7626dbe6049b2ef8ace18ffda8a4dfcbe1bcff3ac30c0c7575c20b/aiohttp-3.13.5-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:7e5dc4311bd5ac493886c63cbf76ab579dbe4641268e7c74e48e774c74b6f2be", size = 497663, upload-time = "2026-03-31T21:58:52.232Z" }, + { url = "https://files.pythonhosted.org/packages/9b/91/cc8cc78a111826c54743d88651e1687008133c37e5ee615fee9b57990fac/aiohttp-3.13.5-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:756c3c304d394977519824449600adaf2be0ccee76d206ee339c5e76b70ded25", size = 499094, upload-time = "2026-03-31T21:58:54.566Z" }, + { url = "https://files.pythonhosted.org/packages/0a/33/a8362cb15cf16a3af7e86ed11962d5cd7d59b449202dc576cdc731310bde/aiohttp-3.13.5-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ecc26751323224cf8186efcf7fbcbc30f4e1d8c7970659daf25ad995e4032a56", size = 1726701, upload-time = "2026-03-31T21:58:56.864Z" }, + { url = "https://files.pythonhosted.org/packages/45/0c/c091ac5c3a17114bd76cbf85d674650969ddf93387876cf67f754204bd77/aiohttp-3.13.5-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:10a75acfcf794edf9d8db50e5a7ec5fc818b2a8d3f591ce93bc7b1210df016d2", size = 1683360, upload-time = "2026-03-31T21:58:59.072Z" }, + { url = "https://files.pythonhosted.org/packages/23/73/bcee1c2b79bc275e964d1446c55c54441a461938e70267c86afaae6fba27/aiohttp-3.13.5-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:0f7a18f258d124cd678c5fe072fe4432a4d5232b0657fca7c1847f599233c83a", size = 1773023, upload-time = "2026-03-31T21:59:01.776Z" }, + { url = "https://files.pythonhosted.org/packages/c7/ef/720e639df03004fee2d869f771799d8c23046dec47d5b81e396c7cda583a/aiohttp-3.13.5-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:df6104c009713d3a89621096f3e3e88cc323fd269dbd7c20afe18535094320be", size = 1853795, upload-time = "2026-03-31T21:59:04.568Z" }, + { url = "https://files.pythonhosted.org/packages/bd/c9/989f4034fb46841208de7aeeac2c6d8300745ab4f28c42f629ba77c2d916/aiohttp-3.13.5-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:241a94f7de7c0c3b616627aaad530fe2cb620084a8b144d3be7b6ecfe95bae3b", size = 1730405, upload-time = "2026-03-31T21:59:07.221Z" }, + { url = "https://files.pythonhosted.org/packages/ce/75/ee1fd286ca7dc599d824b5651dad7b3be7ff8d9a7e7b3fe9820d9180f7db/aiohttp-3.13.5-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c974fb66180e58709b6fc402846f13791240d180b74de81d23913abe48e96d94", size = 1558082, upload-time = "2026-03-31T21:59:09.484Z" }, + { url = "https://files.pythonhosted.org/packages/c3/20/1e9e6650dfc436340116b7aa89ff8cb2bbdf0abc11dfaceaad8f74273a10/aiohttp-3.13.5-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:6e27ea05d184afac78aabbac667450c75e54e35f62238d44463131bd3f96753d", size = 1692346, upload-time = "2026-03-31T21:59:12.068Z" }, + { url = "https://files.pythonhosted.org/packages/d8/40/8ebc6658d48ea630ac7903912fe0dd4e262f0e16825aa4c833c56c9f1f56/aiohttp-3.13.5-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:a79a6d399cef33a11b6f004c67bb07741d91f2be01b8d712d52c75711b1e07c7", size = 1698891, upload-time = "2026-03-31T21:59:14.552Z" }, + { url = "https://files.pythonhosted.org/packages/d8/78/ea0ae5ec8ba7a5c10bdd6e318f1ba5e76fcde17db8275188772afc7917a4/aiohttp-3.13.5-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:c632ce9c0b534fbe25b52c974515ed674937c5b99f549a92127c85f771a78772", size = 1742113, upload-time = "2026-03-31T21:59:17.068Z" }, + { url = "https://files.pythonhosted.org/packages/8a/66/9d308ed71e3f2491be1acb8769d96c6f0c47d92099f3bc9119cada27b357/aiohttp-3.13.5-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:fceedde51fbd67ee2bcc8c0b33d0126cc8b51ef3bbde2f86662bd6d5a6f10ec5", size = 1553088, upload-time = "2026-03-31T21:59:19.541Z" }, + { url = "https://files.pythonhosted.org/packages/da/a6/6cc25ed8dfc6e00c90f5c6d126a98e2cf28957ad06fa1036bd34b6f24a2c/aiohttp-3.13.5-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:f92995dfec9420bb69ae629abf422e516923ba79ba4403bc750d94fb4a6c68c1", size = 1757976, upload-time = "2026-03-31T21:59:22.311Z" }, + { url = "https://files.pythonhosted.org/packages/c1/2b/cce5b0ffe0de99c83e5e36d8f828e4161e415660a9f3e58339d07cce3006/aiohttp-3.13.5-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:20ae0ff08b1f2c8788d6fb85afcb798654ae6ba0b747575f8562de738078457b", size = 1712444, upload-time = "2026-03-31T21:59:24.635Z" }, + { url = "https://files.pythonhosted.org/packages/6c/cf/9e1795b4160c58d29421eafd1a69c6ce351e2f7c8d3c6b7e4ca44aea1a5b/aiohttp-3.13.5-cp314-cp314-win32.whl", hash = "sha256:b20df693de16f42b2472a9c485e1c948ee55524786a0a34345511afdd22246f3", size = 438128, upload-time = "2026-03-31T21:59:27.291Z" }, + { url = "https://files.pythonhosted.org/packages/22/4d/eaedff67fc805aeba4ba746aec891b4b24cebb1a7d078084b6300f79d063/aiohttp-3.13.5-cp314-cp314-win_amd64.whl", hash = "sha256:f85c6f327bf0b8c29da7d93b1cabb6363fb5e4e160a32fa241ed2dce21b73162", size = 464029, upload-time = "2026-03-31T21:59:29.429Z" }, + { url = "https://files.pythonhosted.org/packages/79/11/c27d9332ee20d68dd164dc12a6ecdef2e2e35ecc97ed6cf0d2442844624b/aiohttp-3.13.5-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:1efb06900858bb618ff5cee184ae2de5828896c448403d51fb633f09e109be0a", size = 778758, upload-time = "2026-03-31T21:59:31.547Z" }, + { url = "https://files.pythonhosted.org/packages/04/fb/377aead2e0a3ba5f09b7624f702a964bdf4f08b5b6728a9799830c80041e/aiohttp-3.13.5-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:fee86b7c4bd29bdaf0d53d14739b08a106fdda809ca5fe032a15f52fae5fe254", size = 512883, upload-time = "2026-03-31T21:59:34.098Z" }, + { url = "https://files.pythonhosted.org/packages/bb/a6/aa109a33671f7a5d3bd78b46da9d852797c5e665bfda7d6b373f56bff2ec/aiohttp-3.13.5-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:20058e23909b9e65f9da62b396b77dfa95965cbe840f8def6e572538b1d32e36", size = 516668, upload-time = "2026-03-31T21:59:36.497Z" }, + { url = "https://files.pythonhosted.org/packages/79/b3/ca078f9f2fa9563c36fb8ef89053ea2bb146d6f792c5104574d49d8acb63/aiohttp-3.13.5-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8cf20a8d6868cb15a73cab329ffc07291ba8c22b1b88176026106ae39aa6df0f", size = 1883461, upload-time = "2026-03-31T21:59:38.723Z" }, + { url = "https://files.pythonhosted.org/packages/b7/e3/a7ad633ca1ca497b852233a3cce6906a56c3225fb6d9217b5e5e60b7419d/aiohttp-3.13.5-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:330f5da04c987f1d5bdb8ae189137c77139f36bd1cb23779ca1a354a4b027800", size = 1747661, upload-time = "2026-03-31T21:59:41.187Z" }, + { url = "https://files.pythonhosted.org/packages/33/b9/cd6fe579bed34a906d3d783fe60f2fa297ef55b27bb4538438ee49d4dc41/aiohttp-3.13.5-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:6f1cbf0c7926d315c3c26c2da41fd2b5d2fe01ac0e157b78caefc51a782196cf", size = 1863800, upload-time = "2026-03-31T21:59:43.84Z" }, + { url = "https://files.pythonhosted.org/packages/c0/3f/2c1e2f5144cefa889c8afd5cf431994c32f3b29da9961698ff4e3811b79a/aiohttp-3.13.5-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:53fc049ed6390d05423ba33103ded7281fe897cf97878f369a527070bd95795b", size = 1958382, upload-time = "2026-03-31T21:59:46.187Z" }, + { url = "https://files.pythonhosted.org/packages/66/1d/f31ec3f1013723b3babe3609e7f119c2c2fb6ef33da90061a705ef3e1bc8/aiohttp-3.13.5-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:898703aa2667e3c5ca4c54ca36cd73f58b7a38ef87a5606414799ebce4d3fd3a", size = 1803724, upload-time = "2026-03-31T21:59:48.656Z" }, + { url = "https://files.pythonhosted.org/packages/0e/b4/57712dfc6f1542f067daa81eb61da282fab3e6f1966fca25db06c4fc62d5/aiohttp-3.13.5-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0494a01ca9584eea1e5fbd6d748e61ecff218c51b576ee1999c23db7066417d8", size = 1640027, upload-time = "2026-03-31T21:59:51.284Z" }, + { url = "https://files.pythonhosted.org/packages/25/3c/734c878fb43ec083d8e31bf029daae1beafeae582d1b35da234739e82ee7/aiohttp-3.13.5-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:6cf81fe010b8c17b09495cbd15c1d35afbc8fb405c0c9cf4738e5ae3af1d65be", size = 1806644, upload-time = "2026-03-31T21:59:53.753Z" }, + { url = "https://files.pythonhosted.org/packages/20/a5/f671e5cbec1c21d044ff3078223f949748f3a7f86b14e34a365d74a5d21f/aiohttp-3.13.5-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:c564dd5f09ddc9d8f2c2d0a301cd30a79a2cc1b46dd1a73bef8f0038863d016b", size = 1791630, upload-time = "2026-03-31T21:59:56.239Z" }, + { url = "https://files.pythonhosted.org/packages/0b/63/fb8d0ad63a0b8a99be97deac8c04dacf0785721c158bdf23d679a87aa99e/aiohttp-3.13.5-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:2994be9f6e51046c4f864598fd9abeb4fba6e88f0b2152422c9666dcd4aea9c6", size = 1809403, upload-time = "2026-03-31T21:59:59.103Z" }, + { url = "https://files.pythonhosted.org/packages/59/0c/bfed7f30662fcf12206481c2aac57dedee43fe1c49275e85b3a1e1742294/aiohttp-3.13.5-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:157826e2fa245d2ef46c83ea8a5faf77ca19355d278d425c29fda0beb3318037", size = 1634924, upload-time = "2026-03-31T22:00:02.116Z" }, + { url = "https://files.pythonhosted.org/packages/17/d6/fd518d668a09fd5a3319ae5e984d4d80b9a4b3df4e21c52f02251ef5a32e/aiohttp-3.13.5-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:a8aca50daa9493e9e13c0f566201a9006f080e7c50e5e90d0b06f53146a54500", size = 1836119, upload-time = "2026-03-31T22:00:04.756Z" }, + { url = "https://files.pythonhosted.org/packages/78/b7/15fb7a9d52e112a25b621c67b69c167805cb1f2ab8f1708a5c490d1b52fe/aiohttp-3.13.5-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:3b13560160d07e047a93f23aaa30718606493036253d5430887514715b67c9d9", size = 1772072, upload-time = "2026-03-31T22:00:07.494Z" }, + { url = "https://files.pythonhosted.org/packages/7e/df/57ba7f0c4a553fc2bd8b6321df236870ec6fd64a2a473a8a13d4f733214e/aiohttp-3.13.5-cp314-cp314t-win32.whl", hash = "sha256:9a0f4474b6ea6818b41f82172d799e4b3d29e22c2c520ce4357856fced9af2f8", size = 471819, upload-time = "2026-03-31T22:00:10.277Z" }, + { url = "https://files.pythonhosted.org/packages/62/29/2f8418269e46454a26171bfdd6a055d74febf32234e474930f2f60a17145/aiohttp-3.13.5-cp314-cp314t-win_amd64.whl", hash = "sha256:18a2f6c1182c51baa1d28d68fea51513cb2a76612f038853c0ad3c145423d3d9", size = 505441, upload-time = "2026-03-31T22:00:12.791Z" }, +] + +[[package]] +name = "aiosignal" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "frozenlist" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/61/62/06741b579156360248d1ec624842ad0edf697050bbaf7c3e46394e106ad1/aiosignal-1.4.0.tar.gz", hash = "sha256:f47eecd9468083c2029cc99945502cb7708b082c232f9aca65da147157b251c7", size = 25007, upload-time = "2025-07-03T22:54:43.528Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/fb/76/641ae371508676492379f16e2fa48f4e2c11741bd63c48be4b12a6b09cba/aiosignal-1.4.0-py3-none-any.whl", hash = "sha256:053243f8b92b990551949e63930a839ff0cf0b0ebbe0597b0f3fb19e1a0fe82e", size = 7490, upload-time = "2025-07-03T22:54:42.156Z" }, +] + +[[package]] +name = "annotated-doc" +version = "0.0.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz", hash = "sha256:fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4", size = 7288, upload-time = "2025-11-10T22:07:42.062Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/d3/26bf1008eb3d2daa8ef4cacc7f3bfdc11818d111f7e2d0201bc6e3b49d45/annotated_doc-0.0.4-py3-none-any.whl", hash = "sha256:571ac1dc6991c450b25a9c2d84a3705e2ae7a53467b5d111c24fa8baabbed320", size = 5303, upload-time = "2025-11-10T22:07:40.673Z" }, +] + +[[package]] +name = "anyio" +version = "4.13.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/14/2c5dd9f512b66549ae92767a9c7b330ae88e1932ca57876909410251fe13/anyio-4.13.0.tar.gz", hash = "sha256:334b70e641fd2221c1505b3890c69882fe4a2df910cba14d97019b90b24439dc", size = 231622, upload-time = "2026-03-24T12:59:09.671Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/da/42/e921fccf5015463e32a3cf6ee7f980a6ed0f395ceeaa45060b61d86486c2/anyio-4.13.0-py3-none-any.whl", hash = "sha256:08b310f9e24a9594186fd75b4f73f4a4152069e3853f1ed8bfbf58369f4ad708", size = 114353, upload-time = "2026-03-24T12:59:08.246Z" }, +] + +[[package]] +name = "attrs" +version = "26.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", hash = "sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32", size = 952055, upload-time = "2026-03-19T14:22:25.026Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309", size = 67548, upload-time = "2026-03-19T14:22:23.645Z" }, +] + +[[package]] +name = "certifi" +version = "2026.4.22" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/25/ee/6caf7a40c36a1220410afe15a1cc64993a1f864871f698c0f93acb72842a/certifi-2026.4.22.tar.gz", hash = "sha256:8d455352a37b71bf76a79caa83a3d6c25afee4a385d632127b6afb3963f1c580", size = 137077, upload-time = "2026-04-22T11:26:11.191Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/22/30/7cd8fdcdfbc5b869528b079bfb76dcdf6056b1a2097a662e5e8c04f42965/certifi-2026.4.22-py3-none-any.whl", hash = "sha256:3cb2210c8f88ba2318d29b0388d1023c8492ff72ecdde4ebdaddbb13a31b1c4a", size = 135707, upload-time = "2026-04-22T11:26:09.372Z" }, +] + +[[package]] +name = "charset-normalizer" +version = "3.4.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e7/a1/67fe25fac3c7642725500a3f6cfe5821ad557c3abb11c9d20d12c7008d3e/charset_normalizer-3.4.7.tar.gz", hash = "sha256:ae89db9e5f98a11a4bf50407d4363e7b09b31e55bc117b4f7d80aab97ba009e5", size = 144271, upload-time = "2026-04-02T09:28:39.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0c/eb/4fc8d0a7110eb5fc9cc161723a34a8a6c200ce3b4fbf681bc86feee22308/charset_normalizer-3.4.7-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:eca9705049ad3c7345d574e3510665cb2cf844c2f2dcfe675332677f081cbd46", size = 311328, upload-time = "2026-04-02T09:26:24.331Z" }, + { url = "https://files.pythonhosted.org/packages/f8/e3/0fadc706008ac9d7b9b5be6dc767c05f9d3e5df51744ce4cc9605de7b9f4/charset_normalizer-3.4.7-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6178f72c5508bfc5fd446a5905e698c6212932f25bcdd4b47a757a50605a90e2", size = 208061, upload-time = "2026-04-02T09:26:25.568Z" }, + { url = "https://files.pythonhosted.org/packages/42/f0/3dd1045c47f4a4604df85ec18ad093912ae1344ac706993aff91d38773a2/charset_normalizer-3.4.7-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:e1421b502d83040e6d7fb2fb18dff63957f720da3d77b2fbd3187ceb63755d7b", size = 229031, upload-time = "2026-04-02T09:26:26.865Z" }, + { url = "https://files.pythonhosted.org/packages/dc/67/675a46eb016118a2fbde5a277a5d15f4f69d5f3f5f338e5ee2f8948fcf43/charset_normalizer-3.4.7-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:edac0f1ab77644605be2cbba52e6b7f630731fc42b34cb0f634be1a6eface56a", size = 225239, upload-time = "2026-04-02T09:26:28.044Z" }, + { url = "https://files.pythonhosted.org/packages/4b/f8/d0118a2f5f23b02cd166fa385c60f9b0d4f9194f574e2b31cef350ad7223/charset_normalizer-3.4.7-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5649fd1c7bade02f320a462fdefd0b4bd3ce036065836d4f42e0de958038e116", size = 216589, upload-time = "2026-04-02T09:26:29.239Z" }, + { url = "https://files.pythonhosted.org/packages/b1/f1/6d2b0b261b6c4ceef0fcb0d17a01cc5bc53586c2d4796fa04b5c540bc13d/charset_normalizer-3.4.7-cp312-cp312-manylinux_2_31_armv7l.whl", hash = "sha256:203104ed3e428044fd943bc4bf45fa73c0730391f9621e37fe39ecf477b128cb", size = 202733, upload-time = "2026-04-02T09:26:30.5Z" }, + { url = "https://files.pythonhosted.org/packages/6f/c0/7b1f943f7e87cc3db9626ba17807d042c38645f0a1d4415c7a14afb5591f/charset_normalizer-3.4.7-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:298930cec56029e05497a76988377cbd7457ba864beeea92ad7e844fe74cd1f1", size = 212652, upload-time = "2026-04-02T09:26:31.709Z" }, + { url = "https://files.pythonhosted.org/packages/38/dd/5a9ab159fe45c6e72079398f277b7d2b523e7f716acc489726115a910097/charset_normalizer-3.4.7-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:708838739abf24b2ceb208d0e22403dd018faeef86ddac04319a62ae884c4f15", size = 211229, upload-time = "2026-04-02T09:26:33.282Z" }, + { url = "https://files.pythonhosted.org/packages/d5/ff/531a1cad5ca855d1c1a8b69cb71abfd6d85c0291580146fda7c82857caa1/charset_normalizer-3.4.7-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:0f7eb884681e3938906ed0434f20c63046eacd0111c4ba96f27b76084cd679f5", size = 203552, upload-time = "2026-04-02T09:26:34.845Z" }, + { url = "https://files.pythonhosted.org/packages/c1/4c/a5fb52d528a8ca41f7598cb619409ece30a169fbdf9cdce592e53b46c3a6/charset_normalizer-3.4.7-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:4dc1e73c36828f982bfe79fadf5919923f8a6f4df2860804db9a98c48824ce8d", size = 230806, upload-time = "2026-04-02T09:26:36.152Z" }, + { url = "https://files.pythonhosted.org/packages/59/7a/071feed8124111a32b316b33ae4de83d36923039ef8cf48120266844285b/charset_normalizer-3.4.7-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:aed52fea0513bac0ccde438c188c8a471c4e0f457c2dd20cdbf6ea7a450046c7", size = 212316, upload-time = "2026-04-02T09:26:37.672Z" }, + { url = "https://files.pythonhosted.org/packages/fd/35/f7dba3994312d7ba508e041eaac39a36b120f32d4c8662b8814dab876431/charset_normalizer-3.4.7-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:fea24543955a6a729c45a73fe90e08c743f0b3334bbf3201e6c4bc1b0c7fa464", size = 227274, upload-time = "2026-04-02T09:26:38.93Z" }, + { url = "https://files.pythonhosted.org/packages/8a/2d/a572df5c9204ab7688ec1edc895a73ebded3b023bb07364710b05dd1c9be/charset_normalizer-3.4.7-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:bb6d88045545b26da47aa879dd4a89a71d1dce0f0e549b1abcb31dfe4a8eac49", size = 218468, upload-time = "2026-04-02T09:26:40.17Z" }, + { url = "https://files.pythonhosted.org/packages/86/eb/890922a8b03a568ca2f336c36585a4713c55d4d67bf0f0c78924be6315ca/charset_normalizer-3.4.7-cp312-cp312-win32.whl", hash = "sha256:2257141f39fe65a3fdf38aeccae4b953e5f3b3324f4ff0daf9f15b8518666a2c", size = 148460, upload-time = "2026-04-02T09:26:41.416Z" }, + { url = "https://files.pythonhosted.org/packages/35/d9/0e7dffa06c5ab081f75b1b786f0aefc88365825dfcd0ac544bdb7b2b6853/charset_normalizer-3.4.7-cp312-cp312-win_amd64.whl", hash = "sha256:5ed6ab538499c8644b8a3e18debabcd7ce684f3fa91cf867521a7a0279cab2d6", size = 159330, upload-time = "2026-04-02T09:26:42.554Z" }, + { url = "https://files.pythonhosted.org/packages/9e/5d/481bcc2a7c88ea6b0878c299547843b2521ccbc40980cb406267088bc701/charset_normalizer-3.4.7-cp312-cp312-win_arm64.whl", hash = "sha256:56be790f86bfb2c98fb742ce566dfb4816e5a83384616ab59c49e0604d49c51d", size = 147828, upload-time = "2026-04-02T09:26:44.075Z" }, + { url = "https://files.pythonhosted.org/packages/c1/3b/66777e39d3ae1ddc77ee606be4ec6d8cbd4c801f65e5a1b6f2b11b8346dd/charset_normalizer-3.4.7-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:f496c9c3cc02230093d8330875c4c3cdfc3b73612a5fd921c65d39cbcef08063", size = 309627, upload-time = "2026-04-02T09:26:45.198Z" }, + { url = "https://files.pythonhosted.org/packages/2e/4e/b7f84e617b4854ade48a1b7915c8ccfadeba444d2a18c291f696e37f0d3b/charset_normalizer-3.4.7-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0ea948db76d31190bf08bd371623927ee1339d5f2a0b4b1b4a4439a65298703c", size = 207008, upload-time = "2026-04-02T09:26:46.824Z" }, + { url = "https://files.pythonhosted.org/packages/c4/bb/ec73c0257c9e11b268f018f068f5d00aa0ef8c8b09f7753ebd5f2880e248/charset_normalizer-3.4.7-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a277ab8928b9f299723bc1a2dabb1265911b1a76341f90a510368ca44ad9ab66", size = 228303, upload-time = "2026-04-02T09:26:48.397Z" }, + { url = "https://files.pythonhosted.org/packages/85/fb/32d1f5033484494619f701e719429c69b766bfc4dbc61aa9e9c8c166528b/charset_normalizer-3.4.7-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:3bec022aec2c514d9cf199522a802bd007cd588ab17ab2525f20f9c34d067c18", size = 224282, upload-time = "2026-04-02T09:26:49.684Z" }, + { url = "https://files.pythonhosted.org/packages/fa/07/330e3a0dda4c404d6da83b327270906e9654a24f6c546dc886a0eb0ffb23/charset_normalizer-3.4.7-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e044c39e41b92c845bc815e5ae4230804e8e7bc29e399b0437d64222d92809dd", size = 215595, upload-time = "2026-04-02T09:26:50.915Z" }, + { url = "https://files.pythonhosted.org/packages/e3/7c/fc890655786e423f02556e0216d4b8c6bcb6bdfa890160dc66bf52dee468/charset_normalizer-3.4.7-cp313-cp313-manylinux_2_31_armv7l.whl", hash = "sha256:f495a1652cf3fbab2eb0639776dad966c2fb874d79d87ca07f9d5f059b8bd215", size = 201986, upload-time = "2026-04-02T09:26:52.197Z" }, + { url = "https://files.pythonhosted.org/packages/d8/97/bfb18b3db2aed3b90cf54dc292ad79fdd5ad65c4eae454099475cbeadd0d/charset_normalizer-3.4.7-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e712b419df8ba5e42b226c510472b37bd57b38e897d3eca5e8cfd410a29fa859", size = 211711, upload-time = "2026-04-02T09:26:53.49Z" }, + { url = "https://files.pythonhosted.org/packages/6f/a5/a581c13798546a7fd557c82614a5c65a13df2157e9ad6373166d2a3e645d/charset_normalizer-3.4.7-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:7804338df6fcc08105c7745f1502ba68d900f45fd770d5bdd5288ddccb8a42d8", size = 210036, upload-time = "2026-04-02T09:26:54.975Z" }, + { url = "https://files.pythonhosted.org/packages/8c/bf/b3ab5bcb478e4193d517644b0fb2bf5497fbceeaa7a1bc0f4d5b50953861/charset_normalizer-3.4.7-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:481551899c856c704d58119b5025793fa6730adda3571971af568f66d2424bb5", size = 202998, upload-time = "2026-04-02T09:26:56.303Z" }, + { url = "https://files.pythonhosted.org/packages/e7/4e/23efd79b65d314fa320ec6017b4b5834d5c12a58ba4610aa353af2e2f577/charset_normalizer-3.4.7-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:f59099f9b66f0d7145115e6f80dd8b1d847176df89b234a5a6b3f00437aa0832", size = 230056, upload-time = "2026-04-02T09:26:57.554Z" }, + { url = "https://files.pythonhosted.org/packages/b9/9f/1e1941bc3f0e01df116e68dc37a55c4d249df5e6fa77f008841aef68264f/charset_normalizer-3.4.7-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:f59ad4c0e8f6bba240a9bb85504faa1ab438237199d4cce5f622761507b8f6a6", size = 211537, upload-time = "2026-04-02T09:26:58.843Z" }, + { url = "https://files.pythonhosted.org/packages/80/0f/088cbb3020d44428964a6c97fe1edfb1b9550396bf6d278330281e8b709c/charset_normalizer-3.4.7-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:3dedcc22d73ec993f42055eff4fcfed9318d1eeb9a6606c55892a26964964e48", size = 226176, upload-time = "2026-04-02T09:27:00.437Z" }, + { url = "https://files.pythonhosted.org/packages/6a/9f/130394f9bbe06f4f63e22641d32fc9b202b7e251c9aef4db044324dac493/charset_normalizer-3.4.7-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:64f02c6841d7d83f832cd97ccf8eb8a906d06eb95d5276069175c696b024b60a", size = 217723, upload-time = "2026-04-02T09:27:02.021Z" }, + { url = "https://files.pythonhosted.org/packages/73/55/c469897448a06e49f8fa03f6caae97074fde823f432a98f979cc42b90e69/charset_normalizer-3.4.7-cp313-cp313-win32.whl", hash = "sha256:4042d5c8f957e15221d423ba781e85d553722fc4113f523f2feb7b188cc34c5e", size = 148085, upload-time = "2026-04-02T09:27:03.192Z" }, + { url = "https://files.pythonhosted.org/packages/5d/78/1b74c5bbb3f99b77a1715c91b3e0b5bdb6fe302d95ace4f5b1bec37b0167/charset_normalizer-3.4.7-cp313-cp313-win_amd64.whl", hash = "sha256:3946fa46a0cf3e4c8cb1cc52f56bb536310d34f25f01ca9b6c16afa767dab110", size = 158819, upload-time = "2026-04-02T09:27:04.454Z" }, + { url = "https://files.pythonhosted.org/packages/68/86/46bd42279d323deb8687c4a5a811fd548cb7d1de10cf6535d099877a9a9f/charset_normalizer-3.4.7-cp313-cp313-win_arm64.whl", hash = "sha256:80d04837f55fc81da168b98de4f4b797ef007fc8a79ab71c6ec9bc4dd662b15b", size = 147915, upload-time = "2026-04-02T09:27:05.971Z" }, + { url = "https://files.pythonhosted.org/packages/97/c8/c67cb8c70e19ef1960b97b22ed2a1567711de46c4ddf19799923adc836c2/charset_normalizer-3.4.7-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:c36c333c39be2dbca264d7803333c896ab8fa7d4d6f0ab7edb7dfd7aea6e98c0", size = 309234, upload-time = "2026-04-02T09:27:07.194Z" }, + { url = "https://files.pythonhosted.org/packages/99/85/c091fdee33f20de70d6c8b522743b6f831a2f1cd3ff86de4c6a827c48a76/charset_normalizer-3.4.7-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1c2aed2e5e41f24ea8ef1590b8e848a79b56f3a5564a65ceec43c9d692dc7d8a", size = 208042, upload-time = "2026-04-02T09:27:08.749Z" }, + { url = "https://files.pythonhosted.org/packages/87/1c/ab2ce611b984d2fd5d86a5a8a19c1ae26acac6bad967da4967562c75114d/charset_normalizer-3.4.7-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:54523e136b8948060c0fa0bc7b1b50c32c186f2fceee897a495406bb6e311d2b", size = 228706, upload-time = "2026-04-02T09:27:09.951Z" }, + { url = "https://files.pythonhosted.org/packages/a8/29/2b1d2cb00bf085f59d29eb773ce58ec2d325430f8c216804a0a5cd83cbca/charset_normalizer-3.4.7-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:715479b9a2802ecac752a3b0efa2b0b60285cf962ee38414211abdfccc233b41", size = 224727, upload-time = "2026-04-02T09:27:11.175Z" }, + { url = "https://files.pythonhosted.org/packages/47/5c/032c2d5a07fe4d4855fea851209cca2b6f03ebeb6d4e3afdb3358386a684/charset_normalizer-3.4.7-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bd6c2a1c7573c64738d716488d2cdd3c00e340e4835707d8fdb8dc1a66ef164e", size = 215882, upload-time = "2026-04-02T09:27:12.446Z" }, + { url = "https://files.pythonhosted.org/packages/2c/c2/356065d5a8b78ed04499cae5f339f091946a6a74f91e03476c33f0ab7100/charset_normalizer-3.4.7-cp314-cp314-manylinux_2_31_armv7l.whl", hash = "sha256:c45e9440fb78f8ddabcf714b68f936737a121355bf59f3907f4e17721b9d1aae", size = 200860, upload-time = "2026-04-02T09:27:13.721Z" }, + { url = "https://files.pythonhosted.org/packages/0c/cd/a32a84217ced5039f53b29f460962abb2d4420def55afabe45b1c3c7483d/charset_normalizer-3.4.7-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:3534e7dcbdcf757da6b85a0bbf5b6868786d5982dd959b065e65481644817a18", size = 211564, upload-time = "2026-04-02T09:27:15.272Z" }, + { url = "https://files.pythonhosted.org/packages/44/86/58e6f13ce26cc3b8f4a36b94a0f22ae2f00a72534520f4ae6857c4b81f89/charset_normalizer-3.4.7-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e8ac484bf18ce6975760921bb6148041faa8fef0547200386ea0b52b5d27bf7b", size = 211276, upload-time = "2026-04-02T09:27:16.834Z" }, + { url = "https://files.pythonhosted.org/packages/8f/fe/d17c32dc72e17e155e06883efa84514ca375f8a528ba2546bee73fc4df81/charset_normalizer-3.4.7-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:a5fe03b42827c13cdccd08e6c0247b6a6d4b5e3cdc53fd1749f5896adcdc2356", size = 201238, upload-time = "2026-04-02T09:27:18.229Z" }, + { url = "https://files.pythonhosted.org/packages/6a/29/f33daa50b06525a237451cdb6c69da366c381a3dadcd833fa5676bc468b3/charset_normalizer-3.4.7-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:2d6eb928e13016cea4f1f21d1e10c1cebd5a421bc57ddf5b1142ae3f86824fab", size = 230189, upload-time = "2026-04-02T09:27:19.445Z" }, + { url = "https://files.pythonhosted.org/packages/b6/6e/52c84015394a6a0bdcd435210a7e944c5f94ea1055f5cc5d56c5fe368e7b/charset_normalizer-3.4.7-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:e74327fb75de8986940def6e8dee4f127cc9752bee7355bb323cc5b2659b6d46", size = 211352, upload-time = "2026-04-02T09:27:20.79Z" }, + { url = "https://files.pythonhosted.org/packages/8c/d7/4353be581b373033fb9198bf1da3cf8f09c1082561e8e922aa7b39bf9fe8/charset_normalizer-3.4.7-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:d6038d37043bced98a66e68d3aa2b6a35505dc01328cd65217cefe82f25def44", size = 227024, upload-time = "2026-04-02T09:27:22.063Z" }, + { url = "https://files.pythonhosted.org/packages/30/45/99d18aa925bd1740098ccd3060e238e21115fffbfdcb8f3ece837d0ace6c/charset_normalizer-3.4.7-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:7579e913a5339fb8fa133f6bbcfd8e6749696206cf05acdbdca71a1b436d8e72", size = 217869, upload-time = "2026-04-02T09:27:23.486Z" }, + { url = "https://files.pythonhosted.org/packages/5c/05/5ee478aa53f4bb7996482153d4bfe1b89e0f087f0ab6b294fcf92d595873/charset_normalizer-3.4.7-cp314-cp314-win32.whl", hash = "sha256:5b77459df20e08151cd6f8b9ef8ef1f961ef73d85c21a555c7eed5b79410ec10", size = 148541, upload-time = "2026-04-02T09:27:25.146Z" }, + { url = "https://files.pythonhosted.org/packages/48/77/72dcb0921b2ce86420b2d79d454c7022bf5be40202a2a07906b9f2a35c97/charset_normalizer-3.4.7-cp314-cp314-win_amd64.whl", hash = "sha256:92a0a01ead5e668468e952e4238cccd7c537364eb7d851ab144ab6627dbbe12f", size = 159634, upload-time = "2026-04-02T09:27:26.642Z" }, + { url = "https://files.pythonhosted.org/packages/c6/a3/c2369911cd72f02386e4e340770f6e158c7980267da16af8f668217abaa0/charset_normalizer-3.4.7-cp314-cp314-win_arm64.whl", hash = "sha256:67f6279d125ca0046a7fd386d01b311c6363844deac3e5b069b514ba3e63c246", size = 148384, upload-time = "2026-04-02T09:27:28.271Z" }, + { url = "https://files.pythonhosted.org/packages/94/09/7e8a7f73d24dba1f0035fbbf014d2c36828fc1bf9c88f84093e57d315935/charset_normalizer-3.4.7-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:effc3f449787117233702311a1b7d8f59cba9ced946ba727bdc329ec69028e24", size = 330133, upload-time = "2026-04-02T09:27:29.474Z" }, + { url = "https://files.pythonhosted.org/packages/8d/da/96975ddb11f8e977f706f45cddd8540fd8242f71ecdb5d18a80723dcf62c/charset_normalizer-3.4.7-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fbccdc05410c9ee21bbf16a35f4c1d16123dcdeb8a1d38f33654fa21d0234f79", size = 216257, upload-time = "2026-04-02T09:27:30.793Z" }, + { url = "https://files.pythonhosted.org/packages/e5/e8/1d63bf8ef2d388e95c64b2098f45f84758f6d102a087552da1485912637b/charset_normalizer-3.4.7-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:733784b6d6def852c814bce5f318d25da2ee65dd4839a0718641c696e09a2960", size = 234851, upload-time = "2026-04-02T09:27:32.44Z" }, + { url = "https://files.pythonhosted.org/packages/9b/40/e5ff04233e70da2681fa43969ad6f66ca5611d7e669be0246c4c7aaf6dc8/charset_normalizer-3.4.7-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a89c23ef8d2c6b27fd200a42aa4ac72786e7c60d40efdc76e6011260b6e949c4", size = 233393, upload-time = "2026-04-02T09:27:34.03Z" }, + { url = "https://files.pythonhosted.org/packages/be/c1/06c6c49d5a5450f76899992f1ee40b41d076aee9279b49cf9974d2f313d5/charset_normalizer-3.4.7-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6c114670c45346afedc0d947faf3c7f701051d2518b943679c8ff88befe14f8e", size = 223251, upload-time = "2026-04-02T09:27:35.369Z" }, + { url = "https://files.pythonhosted.org/packages/2b/9f/f2ff16fb050946169e3e1f82134d107e5d4ae72647ec8a1b1446c148480f/charset_normalizer-3.4.7-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:a180c5e59792af262bf263b21a3c49353f25945d8d9f70628e73de370d55e1e1", size = 206609, upload-time = "2026-04-02T09:27:36.661Z" }, + { url = "https://files.pythonhosted.org/packages/69/d5/a527c0cd8d64d2eab7459784fb4169a0ac76e5a6fc5237337982fd61347e/charset_normalizer-3.4.7-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:3c9a494bc5ec77d43cea229c4f6db1e4d8fe7e1bbffa8b6f0f0032430ff8ab44", size = 220014, upload-time = "2026-04-02T09:27:38.019Z" }, + { url = "https://files.pythonhosted.org/packages/7e/80/8a7b8104a3e203074dc9aa2c613d4b726c0e136bad1cc734594b02867972/charset_normalizer-3.4.7-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8d828b6667a32a728a1ad1d93957cdf37489c57b97ae6c4de2860fa749b8fc1e", size = 218979, upload-time = "2026-04-02T09:27:39.37Z" }, + { url = "https://files.pythonhosted.org/packages/02/9a/b759b503d507f375b2b5c153e4d2ee0a75aa215b7f2489cf314f4541f2c0/charset_normalizer-3.4.7-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:cf1493cd8607bec4d8a7b9b004e699fcf8f9103a9284cc94962cb73d20f9d4a3", size = 209238, upload-time = "2026-04-02T09:27:40.722Z" }, + { url = "https://files.pythonhosted.org/packages/c2/4e/0f3f5d47b86bdb79256e7290b26ac847a2832d9a4033f7eb2cd4bcf4bb5b/charset_normalizer-3.4.7-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:0c96c3b819b5c3e9e165495db84d41914d6894d55181d2d108cc1a69bfc9cce0", size = 236110, upload-time = "2026-04-02T09:27:42.33Z" }, + { url = "https://files.pythonhosted.org/packages/96/23/bce28734eb3ed2c91dcf93abeb8a5cf393a7b2749725030bb630e554fdd8/charset_normalizer-3.4.7-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:752a45dc4a6934060b3b0dab47e04edc3326575f82be64bc4fc293914566503e", size = 219824, upload-time = "2026-04-02T09:27:43.924Z" }, + { url = "https://files.pythonhosted.org/packages/2c/6f/6e897c6984cc4d41af319b077f2f600fc8214eb2fe2d6bcb79141b882400/charset_normalizer-3.4.7-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:8778f0c7a52e56f75d12dae53ae320fae900a8b9b4164b981b9c5ce059cd1fcb", size = 233103, upload-time = "2026-04-02T09:27:45.348Z" }, + { url = "https://files.pythonhosted.org/packages/76/22/ef7bd0fe480a0ae9b656189ec00744b60933f68b4f42a7bb06589f6f576a/charset_normalizer-3.4.7-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:ce3412fbe1e31eb81ea42f4169ed94861c56e643189e1e75f0041f3fe7020abe", size = 225194, upload-time = "2026-04-02T09:27:46.706Z" }, + { url = "https://files.pythonhosted.org/packages/c5/a7/0e0ab3e0b5bc1219bd80a6a0d4d72ca74d9250cb2382b7c699c147e06017/charset_normalizer-3.4.7-cp314-cp314t-win32.whl", hash = "sha256:c03a41a8784091e67a39648f70c5f97b5b6a37f216896d44d2cdcb82615339a0", size = 159827, upload-time = "2026-04-02T09:27:48.053Z" }, + { url = "https://files.pythonhosted.org/packages/7a/1d/29d32e0fb40864b1f878c7f5a0b343ae676c6e2b271a2d55cc3a152391da/charset_normalizer-3.4.7-cp314-cp314t-win_amd64.whl", hash = "sha256:03853ed82eeebbce3c2abfdbc98c96dc205f32a79627688ac9a27370ea61a49c", size = 174168, upload-time = "2026-04-02T09:27:49.795Z" }, + { url = "https://files.pythonhosted.org/packages/de/32/d92444ad05c7a6e41fb2036749777c163baf7a0301a040cb672d6b2b1ae9/charset_normalizer-3.4.7-cp314-cp314t-win_arm64.whl", hash = "sha256:c35abb8bfff0185efac5878da64c45dafd2b37fb0383add1be155a763c1f083d", size = 153018, upload-time = "2026-04-02T09:27:51.116Z" }, + { url = "https://files.pythonhosted.org/packages/db/8f/61959034484a4a7c527811f4721e75d02d653a35afb0b6054474d8185d4c/charset_normalizer-3.4.7-py3-none-any.whl", hash = "sha256:3dce51d0f5e7951f8bb4900c257dad282f49190fdbebecd4ba99bcc41fef404d", size = 61958, upload-time = "2026-04-02T09:28:37.794Z" }, +] + +[[package]] +name = "click" +version = "8.3.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/bb/63/f9e1ea081ce35720d8b92acde70daaedace594dc93b693c869e0d5910718/click-8.3.3.tar.gz", hash = "sha256:398329ad4837b2ff7cbe1dd166a4c0f8900c3ca3a218de04466f38f6497f18a2", size = 328061, upload-time = "2026-04-22T15:11:27.506Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ae/44/c1221527f6a71a01ec6fbad7fa78f1d50dfa02217385cf0fa3eec7087d59/click-8.3.3-py3-none-any.whl", hash = "sha256:a2bf429bb3033c89fa4936ffb35d5cb471e3719e1f3c8a7c3fff0b8314305613", size = 110502, upload-time = "2026-04-22T15:11:25.044Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "datasets" +version = "4.8.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "dill" }, + { name = "filelock" }, + { name = "fsspec", extra = ["http"] }, + { name = "httpx" }, + { name = "huggingface-hub" }, + { name = "multiprocess" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "pandas" }, + { name = "pyarrow" }, + { name = "pyyaml" }, + { name = "requests" }, + { name = "tqdm" }, + { name = "xxhash" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/22/22/73e46ac7a8c25e7ef0b3bd6f10da3465021d90219a32eb0b4d2afea4c56e/datasets-4.8.4.tar.gz", hash = "sha256:a1429ed853275ce7943a01c6d2e25475b4501eb758934362106a280470df3a52", size = 604382, upload-time = "2026-03-23T14:21:17.987Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b0/e5/247d094108e42ac26363ab8dc57f168840cf7c05774b40ffeb0d78868fcc/datasets-4.8.4-py3-none-any.whl", hash = "sha256:cdc8bee4698e549d78bf1fed6aea2eebc760b22b084f07e6fc020c6577a6ce6d", size = 526991, upload-time = "2026-03-23T14:21:15.89Z" }, +] + +[[package]] +name = "dill" +version = "0.4.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/81/e1/56027a71e31b02ddc53c7d65b01e68edf64dea2932122fe7746a516f75d5/dill-0.4.1.tar.gz", hash = "sha256:423092df4182177d4d8ba8290c8a5b640c66ab35ec7da59ccfa00f6fa3eea5fa", size = 187315, upload-time = "2026-01-19T02:36:56.85Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/77/dc8c558f7593132cf8fefec57c4f60c83b16941c574ac5f619abb3ae7933/dill-0.4.1-py3-none-any.whl", hash = "sha256:1e1ce33e978ae97fcfcff5638477032b801c46c7c65cf717f95fbc2248f79a9d", size = 120019, upload-time = "2026-01-19T02:36:55.663Z" }, +] + +[[package]] +name = "filelock" +version = "3.29.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b5/fe/997687a931ab51049acce6fa1f23e8f01216374ea81374ddee763c493db5/filelock-3.29.0.tar.gz", hash = "sha256:69974355e960702e789734cb4871f884ea6fe50bd8404051a3530bc07809cf90", size = 57571, upload-time = "2026-04-19T15:39:10.068Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/47/dd9a212ef6e343a6857485ffe25bba537304f1913bdbed446a23f7f592e1/filelock-3.29.0-py3-none-any.whl", hash = "sha256:96f5f6344709aa1572bbf631c640e4ebeeb519e08da902c39a001882f30ac258", size = 39812, upload-time = "2026-04-19T15:39:08.752Z" }, +] + +[[package]] +name = "frozenlist" +version = "1.8.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/2d/f5/c831fac6cc817d26fd54c7eaccd04ef7e0288806943f7cc5bbf69f3ac1f0/frozenlist-1.8.0.tar.gz", hash = "sha256:3ede829ed8d842f6cd48fc7081d7a41001a56f1f38603f9d49bf3020d59a31ad", size = 45875, upload-time = "2025-10-06T05:38:17.865Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/69/29/948b9aa87e75820a38650af445d2ef2b6b8a6fab1a23b6bb9e4ef0be2d59/frozenlist-1.8.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:78f7b9e5d6f2fdb88cdde9440dc147259b62b9d3b019924def9f6478be254ac1", size = 87782, upload-time = "2025-10-06T05:36:06.649Z" }, + { url = "https://files.pythonhosted.org/packages/64/80/4f6e318ee2a7c0750ed724fa33a4bdf1eacdc5a39a7a24e818a773cd91af/frozenlist-1.8.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:229bf37d2e4acdaf808fd3f06e854a4a7a3661e871b10dc1f8f1896a3b05f18b", size = 50594, upload-time = "2025-10-06T05:36:07.69Z" }, + { url = "https://files.pythonhosted.org/packages/2b/94/5c8a2b50a496b11dd519f4a24cb5496cf125681dd99e94c604ccdea9419a/frozenlist-1.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f833670942247a14eafbb675458b4e61c82e002a148f49e68257b79296e865c4", size = 50448, upload-time = "2025-10-06T05:36:08.78Z" }, + { url = "https://files.pythonhosted.org/packages/6a/bd/d91c5e39f490a49df14320f4e8c80161cfcce09f1e2cde1edd16a551abb3/frozenlist-1.8.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:494a5952b1c597ba44e0e78113a7266e656b9794eec897b19ead706bd7074383", size = 242411, upload-time = "2025-10-06T05:36:09.801Z" }, + { url = "https://files.pythonhosted.org/packages/8f/83/f61505a05109ef3293dfb1ff594d13d64a2324ac3482be2cedc2be818256/frozenlist-1.8.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:96f423a119f4777a4a056b66ce11527366a8bb92f54e541ade21f2374433f6d4", size = 243014, upload-time = "2025-10-06T05:36:11.394Z" }, + { url = "https://files.pythonhosted.org/packages/d8/cb/cb6c7b0f7d4023ddda30cf56b8b17494eb3a79e3fda666bf735f63118b35/frozenlist-1.8.0-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3462dd9475af2025c31cc61be6652dfa25cbfb56cbbf52f4ccfe029f38decaf8", size = 234909, upload-time = "2025-10-06T05:36:12.598Z" }, + { url = "https://files.pythonhosted.org/packages/31/c5/cd7a1f3b8b34af009fb17d4123c5a778b44ae2804e3ad6b86204255f9ec5/frozenlist-1.8.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c4c800524c9cd9bac5166cd6f55285957fcfc907db323e193f2afcd4d9abd69b", size = 250049, upload-time = "2025-10-06T05:36:14.065Z" }, + { url = "https://files.pythonhosted.org/packages/c0/01/2f95d3b416c584a1e7f0e1d6d31998c4a795f7544069ee2e0962a4b60740/frozenlist-1.8.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d6a5df73acd3399d893dafc71663ad22534b5aa4f94e8a2fabfe856c3c1b6a52", size = 256485, upload-time = "2025-10-06T05:36:15.39Z" }, + { url = "https://files.pythonhosted.org/packages/ce/03/024bf7720b3abaebcff6d0793d73c154237b85bdf67b7ed55e5e9596dc9a/frozenlist-1.8.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:405e8fe955c2280ce66428b3ca55e12b3c4e9c336fb2103a4937e891c69a4a29", size = 237619, upload-time = "2025-10-06T05:36:16.558Z" }, + { url = "https://files.pythonhosted.org/packages/69/fa/f8abdfe7d76b731f5d8bd217827cf6764d4f1d9763407e42717b4bed50a0/frozenlist-1.8.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:908bd3f6439f2fef9e85031b59fd4f1297af54415fb60e4254a95f75b3cab3f3", size = 250320, upload-time = "2025-10-06T05:36:17.821Z" }, + { url = "https://files.pythonhosted.org/packages/f5/3c/b051329f718b463b22613e269ad72138cc256c540f78a6de89452803a47d/frozenlist-1.8.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:294e487f9ec720bd8ffcebc99d575f7eff3568a08a253d1ee1a0378754b74143", size = 246820, upload-time = "2025-10-06T05:36:19.046Z" }, + { url = "https://files.pythonhosted.org/packages/0f/ae/58282e8f98e444b3f4dd42448ff36fa38bef29e40d40f330b22e7108f565/frozenlist-1.8.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:74c51543498289c0c43656701be6b077f4b265868fa7f8a8859c197006efb608", size = 250518, upload-time = "2025-10-06T05:36:20.763Z" }, + { url = "https://files.pythonhosted.org/packages/8f/96/007e5944694d66123183845a106547a15944fbbb7154788cbf7272789536/frozenlist-1.8.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:776f352e8329135506a1d6bf16ac3f87bc25b28e765949282dcc627af36123aa", size = 239096, upload-time = "2025-10-06T05:36:22.129Z" }, + { url = "https://files.pythonhosted.org/packages/66/bb/852b9d6db2fa40be96f29c0d1205c306288f0684df8fd26ca1951d461a56/frozenlist-1.8.0-cp312-cp312-win32.whl", hash = "sha256:433403ae80709741ce34038da08511d4a77062aa924baf411ef73d1146e74faf", size = 39985, upload-time = "2025-10-06T05:36:23.661Z" }, + { url = "https://files.pythonhosted.org/packages/b8/af/38e51a553dd66eb064cdf193841f16f077585d4d28394c2fa6235cb41765/frozenlist-1.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:34187385b08f866104f0c0617404c8eb08165ab1272e884abc89c112e9c00746", size = 44591, upload-time = "2025-10-06T05:36:24.958Z" }, + { url = "https://files.pythonhosted.org/packages/a7/06/1dc65480ab147339fecc70797e9c2f69d9cea9cf38934ce08df070fdb9cb/frozenlist-1.8.0-cp312-cp312-win_arm64.whl", hash = "sha256:fe3c58d2f5db5fbd18c2987cba06d51b0529f52bc3a6cdc33d3f4eab725104bd", size = 40102, upload-time = "2025-10-06T05:36:26.333Z" }, + { url = "https://files.pythonhosted.org/packages/2d/40/0832c31a37d60f60ed79e9dfb5a92e1e2af4f40a16a29abcc7992af9edff/frozenlist-1.8.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:8d92f1a84bb12d9e56f818b3a746f3efba93c1b63c8387a73dde655e1e42282a", size = 85717, upload-time = "2025-10-06T05:36:27.341Z" }, + { url = "https://files.pythonhosted.org/packages/30/ba/b0b3de23f40bc55a7057bd38434e25c34fa48e17f20ee273bbde5e0650f3/frozenlist-1.8.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:96153e77a591c8adc2ee805756c61f59fef4cf4073a9275ee86fe8cba41241f7", size = 49651, upload-time = "2025-10-06T05:36:28.855Z" }, + { url = "https://files.pythonhosted.org/packages/0c/ab/6e5080ee374f875296c4243c381bbdef97a9ac39c6e3ce1d5f7d42cb78d6/frozenlist-1.8.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:f21f00a91358803399890ab167098c131ec2ddd5f8f5fd5fe9c9f2c6fcd91e40", size = 49417, upload-time = "2025-10-06T05:36:29.877Z" }, + { url = "https://files.pythonhosted.org/packages/d5/4e/e4691508f9477ce67da2015d8c00acd751e6287739123113a9fca6f1604e/frozenlist-1.8.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:fb30f9626572a76dfe4293c7194a09fb1fe93ba94c7d4f720dfae3b646b45027", size = 234391, upload-time = "2025-10-06T05:36:31.301Z" }, + { url = "https://files.pythonhosted.org/packages/40/76/c202df58e3acdf12969a7895fd6f3bc016c642e6726aa63bd3025e0fc71c/frozenlist-1.8.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eaa352d7047a31d87dafcacbabe89df0aa506abb5b1b85a2fb91bc3faa02d822", size = 233048, upload-time = "2025-10-06T05:36:32.531Z" }, + { url = "https://files.pythonhosted.org/packages/f9/c0/8746afb90f17b73ca5979c7a3958116e105ff796e718575175319b5bb4ce/frozenlist-1.8.0-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:03ae967b4e297f58f8c774c7eabcce57fe3c2434817d4385c50661845a058121", size = 226549, upload-time = "2025-10-06T05:36:33.706Z" }, + { url = "https://files.pythonhosted.org/packages/7e/eb/4c7eefc718ff72f9b6c4893291abaae5fbc0c82226a32dcd8ef4f7a5dbef/frozenlist-1.8.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f6292f1de555ffcc675941d65fffffb0a5bcd992905015f85d0592201793e0e5", size = 239833, upload-time = "2025-10-06T05:36:34.947Z" }, + { url = "https://files.pythonhosted.org/packages/c2/4e/e5c02187cf704224f8b21bee886f3d713ca379535f16893233b9d672ea71/frozenlist-1.8.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:29548f9b5b5e3460ce7378144c3010363d8035cea44bc0bf02d57f5a685e084e", size = 245363, upload-time = "2025-10-06T05:36:36.534Z" }, + { url = "https://files.pythonhosted.org/packages/1f/96/cb85ec608464472e82ad37a17f844889c36100eed57bea094518bf270692/frozenlist-1.8.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:ec3cc8c5d4084591b4237c0a272cc4f50a5b03396a47d9caaf76f5d7b38a4f11", size = 229314, upload-time = "2025-10-06T05:36:38.582Z" }, + { url = "https://files.pythonhosted.org/packages/5d/6f/4ae69c550e4cee66b57887daeebe006fe985917c01d0fff9caab9883f6d0/frozenlist-1.8.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:517279f58009d0b1f2e7c1b130b377a349405da3f7621ed6bfae50b10adf20c1", size = 243365, upload-time = "2025-10-06T05:36:40.152Z" }, + { url = "https://files.pythonhosted.org/packages/7a/58/afd56de246cf11780a40a2c28dc7cbabbf06337cc8ddb1c780a2d97e88d8/frozenlist-1.8.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:db1e72ede2d0d7ccb213f218df6a078a9c09a7de257c2fe8fcef16d5925230b1", size = 237763, upload-time = "2025-10-06T05:36:41.355Z" }, + { url = "https://files.pythonhosted.org/packages/cb/36/cdfaf6ed42e2644740d4a10452d8e97fa1c062e2a8006e4b09f1b5fd7d63/frozenlist-1.8.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:b4dec9482a65c54a5044486847b8a66bf10c9cb4926d42927ec4e8fd5db7fed8", size = 240110, upload-time = "2025-10-06T05:36:42.716Z" }, + { url = "https://files.pythonhosted.org/packages/03/a8/9ea226fbefad669f11b52e864c55f0bd57d3c8d7eb07e9f2e9a0b39502e1/frozenlist-1.8.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:21900c48ae04d13d416f0e1e0c4d81f7931f73a9dfa0b7a8746fb2fe7dd970ed", size = 233717, upload-time = "2025-10-06T05:36:44.251Z" }, + { url = "https://files.pythonhosted.org/packages/1e/0b/1b5531611e83ba7d13ccc9988967ea1b51186af64c42b7a7af465dcc9568/frozenlist-1.8.0-cp313-cp313-win32.whl", hash = "sha256:8b7b94a067d1c504ee0b16def57ad5738701e4ba10cec90529f13fa03c833496", size = 39628, upload-time = "2025-10-06T05:36:45.423Z" }, + { url = "https://files.pythonhosted.org/packages/d8/cf/174c91dbc9cc49bc7b7aab74d8b734e974d1faa8f191c74af9b7e80848e6/frozenlist-1.8.0-cp313-cp313-win_amd64.whl", hash = "sha256:878be833caa6a3821caf85eb39c5ba92d28e85df26d57afb06b35b2efd937231", size = 43882, upload-time = "2025-10-06T05:36:46.796Z" }, + { url = "https://files.pythonhosted.org/packages/c1/17/502cd212cbfa96eb1388614fe39a3fc9ab87dbbe042b66f97acb57474834/frozenlist-1.8.0-cp313-cp313-win_arm64.whl", hash = "sha256:44389d135b3ff43ba8cc89ff7f51f5a0bb6b63d829c8300f79a2fe4fe61bcc62", size = 39676, upload-time = "2025-10-06T05:36:47.8Z" }, + { url = "https://files.pythonhosted.org/packages/d2/5c/3bbfaa920dfab09e76946a5d2833a7cbdf7b9b4a91c714666ac4855b88b4/frozenlist-1.8.0-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:e25ac20a2ef37e91c1b39938b591457666a0fa835c7783c3a8f33ea42870db94", size = 89235, upload-time = "2025-10-06T05:36:48.78Z" }, + { url = "https://files.pythonhosted.org/packages/d2/d6/f03961ef72166cec1687e84e8925838442b615bd0b8854b54923ce5b7b8a/frozenlist-1.8.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:07cdca25a91a4386d2e76ad992916a85038a9b97561bf7a3fd12d5d9ce31870c", size = 50742, upload-time = "2025-10-06T05:36:49.837Z" }, + { url = "https://files.pythonhosted.org/packages/1e/bb/a6d12b7ba4c3337667d0e421f7181c82dda448ce4e7ad7ecd249a16fa806/frozenlist-1.8.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:4e0c11f2cc6717e0a741f84a527c52616140741cd812a50422f83dc31749fb52", size = 51725, upload-time = "2025-10-06T05:36:50.851Z" }, + { url = "https://files.pythonhosted.org/packages/bc/71/d1fed0ffe2c2ccd70b43714c6cab0f4188f09f8a67a7914a6b46ee30f274/frozenlist-1.8.0-cp313-cp313t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:b3210649ee28062ea6099cfda39e147fa1bc039583c8ee4481cb7811e2448c51", size = 284533, upload-time = "2025-10-06T05:36:51.898Z" }, + { url = "https://files.pythonhosted.org/packages/c9/1f/fb1685a7b009d89f9bf78a42d94461bc06581f6e718c39344754a5d9bada/frozenlist-1.8.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:581ef5194c48035a7de2aefc72ac6539823bb71508189e5de01d60c9dcd5fa65", size = 292506, upload-time = "2025-10-06T05:36:53.101Z" }, + { url = "https://files.pythonhosted.org/packages/e6/3b/b991fe1612703f7e0d05c0cf734c1b77aaf7c7d321df4572e8d36e7048c8/frozenlist-1.8.0-cp313-cp313t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3ef2d026f16a2b1866e1d86fc4e1291e1ed8a387b2c333809419a2f8b3a77b82", size = 274161, upload-time = "2025-10-06T05:36:54.309Z" }, + { url = "https://files.pythonhosted.org/packages/ca/ec/c5c618767bcdf66e88945ec0157d7f6c4a1322f1473392319b7a2501ded7/frozenlist-1.8.0-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:5500ef82073f599ac84d888e3a8c1f77ac831183244bfd7f11eaa0289fb30714", size = 294676, upload-time = "2025-10-06T05:36:55.566Z" }, + { url = "https://files.pythonhosted.org/packages/7c/ce/3934758637d8f8a88d11f0585d6495ef54b2044ed6ec84492a91fa3b27aa/frozenlist-1.8.0-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:50066c3997d0091c411a66e710f4e11752251e6d2d73d70d8d5d4c76442a199d", size = 300638, upload-time = "2025-10-06T05:36:56.758Z" }, + { url = "https://files.pythonhosted.org/packages/fc/4f/a7e4d0d467298f42de4b41cbc7ddaf19d3cfeabaf9ff97c20c6c7ee409f9/frozenlist-1.8.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:5c1c8e78426e59b3f8005e9b19f6ff46e5845895adbde20ece9218319eca6506", size = 283067, upload-time = "2025-10-06T05:36:57.965Z" }, + { url = "https://files.pythonhosted.org/packages/dc/48/c7b163063d55a83772b268e6d1affb960771b0e203b632cfe09522d67ea5/frozenlist-1.8.0-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:eefdba20de0d938cec6a89bd4d70f346a03108a19b9df4248d3cf0d88f1b0f51", size = 292101, upload-time = "2025-10-06T05:36:59.237Z" }, + { url = "https://files.pythonhosted.org/packages/9f/d0/2366d3c4ecdc2fd391e0afa6e11500bfba0ea772764d631bbf82f0136c9d/frozenlist-1.8.0-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:cf253e0e1c3ceb4aaff6df637ce033ff6535fb8c70a764a8f46aafd3d6ab798e", size = 289901, upload-time = "2025-10-06T05:37:00.811Z" }, + { url = "https://files.pythonhosted.org/packages/b8/94/daff920e82c1b70e3618a2ac39fbc01ae3e2ff6124e80739ce5d71c9b920/frozenlist-1.8.0-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:032efa2674356903cd0261c4317a561a6850f3ac864a63fc1583147fb05a79b0", size = 289395, upload-time = "2025-10-06T05:37:02.115Z" }, + { url = "https://files.pythonhosted.org/packages/e3/20/bba307ab4235a09fdcd3cc5508dbabd17c4634a1af4b96e0f69bfe551ebd/frozenlist-1.8.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:6da155091429aeba16851ecb10a9104a108bcd32f6c1642867eadaee401c1c41", size = 283659, upload-time = "2025-10-06T05:37:03.711Z" }, + { url = "https://files.pythonhosted.org/packages/fd/00/04ca1c3a7a124b6de4f8a9a17cc2fcad138b4608e7a3fc5877804b8715d7/frozenlist-1.8.0-cp313-cp313t-win32.whl", hash = "sha256:0f96534f8bfebc1a394209427d0f8a63d343c9779cda6fc25e8e121b5fd8555b", size = 43492, upload-time = "2025-10-06T05:37:04.915Z" }, + { url = "https://files.pythonhosted.org/packages/59/5e/c69f733a86a94ab10f68e496dc6b7e8bc078ebb415281d5698313e3af3a1/frozenlist-1.8.0-cp313-cp313t-win_amd64.whl", hash = "sha256:5d63a068f978fc69421fb0e6eb91a9603187527c86b7cd3f534a5b77a592b888", size = 48034, upload-time = "2025-10-06T05:37:06.343Z" }, + { url = "https://files.pythonhosted.org/packages/16/6c/be9d79775d8abe79b05fa6d23da99ad6e7763a1d080fbae7290b286093fd/frozenlist-1.8.0-cp313-cp313t-win_arm64.whl", hash = "sha256:bf0a7e10b077bf5fb9380ad3ae8ce20ef919a6ad93b4552896419ac7e1d8e042", size = 41749, upload-time = "2025-10-06T05:37:07.431Z" }, + { url = "https://files.pythonhosted.org/packages/f1/c8/85da824b7e7b9b6e7f7705b2ecaf9591ba6f79c1177f324c2735e41d36a2/frozenlist-1.8.0-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:cee686f1f4cadeb2136007ddedd0aaf928ab95216e7691c63e50a8ec066336d0", size = 86127, upload-time = "2025-10-06T05:37:08.438Z" }, + { url = "https://files.pythonhosted.org/packages/8e/e8/a1185e236ec66c20afd72399522f142c3724c785789255202d27ae992818/frozenlist-1.8.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:119fb2a1bd47307e899c2fac7f28e85b9a543864df47aa7ec9d3c1b4545f096f", size = 49698, upload-time = "2025-10-06T05:37:09.48Z" }, + { url = "https://files.pythonhosted.org/packages/a1/93/72b1736d68f03fda5fdf0f2180fb6caaae3894f1b854d006ac61ecc727ee/frozenlist-1.8.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4970ece02dbc8c3a92fcc5228e36a3e933a01a999f7094ff7c23fbd2beeaa67c", size = 49749, upload-time = "2025-10-06T05:37:10.569Z" }, + { url = "https://files.pythonhosted.org/packages/a7/b2/fabede9fafd976b991e9f1b9c8c873ed86f202889b864756f240ce6dd855/frozenlist-1.8.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:cba69cb73723c3f329622e34bdbf5ce1f80c21c290ff04256cff1cd3c2036ed2", size = 231298, upload-time = "2025-10-06T05:37:11.993Z" }, + { url = "https://files.pythonhosted.org/packages/3a/3b/d9b1e0b0eed36e70477ffb8360c49c85c8ca8ef9700a4e6711f39a6e8b45/frozenlist-1.8.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:778a11b15673f6f1df23d9586f83c4846c471a8af693a22e066508b77d201ec8", size = 232015, upload-time = "2025-10-06T05:37:13.194Z" }, + { url = "https://files.pythonhosted.org/packages/dc/94/be719d2766c1138148564a3960fc2c06eb688da592bdc25adcf856101be7/frozenlist-1.8.0-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:0325024fe97f94c41c08872db482cf8ac4800d80e79222c6b0b7b162d5b13686", size = 225038, upload-time = "2025-10-06T05:37:14.577Z" }, + { url = "https://files.pythonhosted.org/packages/e4/09/6712b6c5465f083f52f50cf74167b92d4ea2f50e46a9eea0523d658454ae/frozenlist-1.8.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:97260ff46b207a82a7567b581ab4190bd4dfa09f4db8a8b49d1a958f6aa4940e", size = 240130, upload-time = "2025-10-06T05:37:15.781Z" }, + { url = "https://files.pythonhosted.org/packages/f8/d4/cd065cdcf21550b54f3ce6a22e143ac9e4836ca42a0de1022da8498eac89/frozenlist-1.8.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:54b2077180eb7f83dd52c40b2750d0a9f175e06a42e3213ce047219de902717a", size = 242845, upload-time = "2025-10-06T05:37:17.037Z" }, + { url = "https://files.pythonhosted.org/packages/62/c3/f57a5c8c70cd1ead3d5d5f776f89d33110b1addae0ab010ad774d9a44fb9/frozenlist-1.8.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:2f05983daecab868a31e1da44462873306d3cbfd76d1f0b5b69c473d21dbb128", size = 229131, upload-time = "2025-10-06T05:37:18.221Z" }, + { url = "https://files.pythonhosted.org/packages/6c/52/232476fe9cb64f0742f3fde2b7d26c1dac18b6d62071c74d4ded55e0ef94/frozenlist-1.8.0-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:33f48f51a446114bc5d251fb2954ab0164d5be02ad3382abcbfe07e2531d650f", size = 240542, upload-time = "2025-10-06T05:37:19.771Z" }, + { url = "https://files.pythonhosted.org/packages/5f/85/07bf3f5d0fb5414aee5f47d33c6f5c77bfe49aac680bfece33d4fdf6a246/frozenlist-1.8.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:154e55ec0655291b5dd1b8731c637ecdb50975a2ae70c606d100750a540082f7", size = 237308, upload-time = "2025-10-06T05:37:20.969Z" }, + { url = "https://files.pythonhosted.org/packages/11/99/ae3a33d5befd41ac0ca2cc7fd3aa707c9c324de2e89db0e0f45db9a64c26/frozenlist-1.8.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:4314debad13beb564b708b4a496020e5306c7333fa9a3ab90374169a20ffab30", size = 238210, upload-time = "2025-10-06T05:37:22.252Z" }, + { url = "https://files.pythonhosted.org/packages/b2/60/b1d2da22f4970e7a155f0adde9b1435712ece01b3cd45ba63702aea33938/frozenlist-1.8.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:073f8bf8becba60aa931eb3bc420b217bb7d5b8f4750e6f8b3be7f3da85d38b7", size = 231972, upload-time = "2025-10-06T05:37:23.5Z" }, + { url = "https://files.pythonhosted.org/packages/3f/ab/945b2f32de889993b9c9133216c068b7fcf257d8595a0ac420ac8677cab0/frozenlist-1.8.0-cp314-cp314-win32.whl", hash = "sha256:bac9c42ba2ac65ddc115d930c78d24ab8d4f465fd3fc473cdedfccadb9429806", size = 40536, upload-time = "2025-10-06T05:37:25.581Z" }, + { url = "https://files.pythonhosted.org/packages/59/ad/9caa9b9c836d9ad6f067157a531ac48b7d36499f5036d4141ce78c230b1b/frozenlist-1.8.0-cp314-cp314-win_amd64.whl", hash = "sha256:3e0761f4d1a44f1d1a47996511752cf3dcec5bbdd9cc2b4fe595caf97754b7a0", size = 44330, upload-time = "2025-10-06T05:37:26.928Z" }, + { url = "https://files.pythonhosted.org/packages/82/13/e6950121764f2676f43534c555249f57030150260aee9dcf7d64efda11dd/frozenlist-1.8.0-cp314-cp314-win_arm64.whl", hash = "sha256:d1eaff1d00c7751b7c6662e9c5ba6eb2c17a2306ba5e2a37f24ddf3cc953402b", size = 40627, upload-time = "2025-10-06T05:37:28.075Z" }, + { url = "https://files.pythonhosted.org/packages/c0/c7/43200656ecc4e02d3f8bc248df68256cd9572b3f0017f0a0c4e93440ae23/frozenlist-1.8.0-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:d3bb933317c52d7ea5004a1c442eef86f426886fba134ef8cf4226ea6ee1821d", size = 89238, upload-time = "2025-10-06T05:37:29.373Z" }, + { url = "https://files.pythonhosted.org/packages/d1/29/55c5f0689b9c0fb765055629f472c0de484dcaf0acee2f7707266ae3583c/frozenlist-1.8.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:8009897cdef112072f93a0efdce29cd819e717fd2f649ee3016efd3cd885a7ed", size = 50738, upload-time = "2025-10-06T05:37:30.792Z" }, + { url = "https://files.pythonhosted.org/packages/ba/7d/b7282a445956506fa11da8c2db7d276adcbf2b17d8bb8407a47685263f90/frozenlist-1.8.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2c5dcbbc55383e5883246d11fd179782a9d07a986c40f49abe89ddf865913930", size = 51739, upload-time = "2025-10-06T05:37:32.127Z" }, + { url = "https://files.pythonhosted.org/packages/62/1c/3d8622e60d0b767a5510d1d3cf21065b9db874696a51ea6d7a43180a259c/frozenlist-1.8.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:39ecbc32f1390387d2aa4f5a995e465e9e2f79ba3adcac92d68e3e0afae6657c", size = 284186, upload-time = "2025-10-06T05:37:33.21Z" }, + { url = "https://files.pythonhosted.org/packages/2d/14/aa36d5f85a89679a85a1d44cd7a6657e0b1c75f61e7cad987b203d2daca8/frozenlist-1.8.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:92db2bf818d5cc8d9c1f1fc56b897662e24ea5adb36ad1f1d82875bd64e03c24", size = 292196, upload-time = "2025-10-06T05:37:36.107Z" }, + { url = "https://files.pythonhosted.org/packages/05/23/6bde59eb55abd407d34f77d39a5126fb7b4f109a3f611d3929f14b700c66/frozenlist-1.8.0-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2dc43a022e555de94c3b68a4ef0b11c4f747d12c024a520c7101709a2144fb37", size = 273830, upload-time = "2025-10-06T05:37:37.663Z" }, + { url = "https://files.pythonhosted.org/packages/d2/3f/22cff331bfad7a8afa616289000ba793347fcd7bc275f3b28ecea2a27909/frozenlist-1.8.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:cb89a7f2de3602cfed448095bab3f178399646ab7c61454315089787df07733a", size = 294289, upload-time = "2025-10-06T05:37:39.261Z" }, + { url = "https://files.pythonhosted.org/packages/a4/89/5b057c799de4838b6c69aa82b79705f2027615e01be996d2486a69ca99c4/frozenlist-1.8.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:33139dc858c580ea50e7e60a1b0ea003efa1fd42e6ec7fdbad78fff65fad2fd2", size = 300318, upload-time = "2025-10-06T05:37:43.213Z" }, + { url = "https://files.pythonhosted.org/packages/30/de/2c22ab3eb2a8af6d69dc799e48455813bab3690c760de58e1bf43b36da3e/frozenlist-1.8.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:168c0969a329b416119507ba30b9ea13688fafffac1b7822802537569a1cb0ef", size = 282814, upload-time = "2025-10-06T05:37:45.337Z" }, + { url = "https://files.pythonhosted.org/packages/59/f7/970141a6a8dbd7f556d94977858cfb36fa9b66e0892c6dd780d2219d8cd8/frozenlist-1.8.0-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:28bd570e8e189d7f7b001966435f9dac6718324b5be2990ac496cf1ea9ddb7fe", size = 291762, upload-time = "2025-10-06T05:37:46.657Z" }, + { url = "https://files.pythonhosted.org/packages/c1/15/ca1adae83a719f82df9116d66f5bb28bb95557b3951903d39135620ef157/frozenlist-1.8.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:b2a095d45c5d46e5e79ba1e5b9cb787f541a8dee0433836cea4b96a2c439dcd8", size = 289470, upload-time = "2025-10-06T05:37:47.946Z" }, + { url = "https://files.pythonhosted.org/packages/ac/83/dca6dc53bf657d371fbc88ddeb21b79891e747189c5de990b9dfff2ccba1/frozenlist-1.8.0-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:eab8145831a0d56ec9c4139b6c3e594c7a83c2c8be25d5bcf2d86136a532287a", size = 289042, upload-time = "2025-10-06T05:37:49.499Z" }, + { url = "https://files.pythonhosted.org/packages/96/52/abddd34ca99be142f354398700536c5bd315880ed0a213812bc491cff5e4/frozenlist-1.8.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:974b28cf63cc99dfb2188d8d222bc6843656188164848c4f679e63dae4b0708e", size = 283148, upload-time = "2025-10-06T05:37:50.745Z" }, + { url = "https://files.pythonhosted.org/packages/af/d3/76bd4ed4317e7119c2b7f57c3f6934aba26d277acc6309f873341640e21f/frozenlist-1.8.0-cp314-cp314t-win32.whl", hash = "sha256:342c97bf697ac5480c0a7ec73cd700ecfa5a8a40ac923bd035484616efecc2df", size = 44676, upload-time = "2025-10-06T05:37:52.222Z" }, + { url = "https://files.pythonhosted.org/packages/89/76/c615883b7b521ead2944bb3480398cbb07e12b7b4e4d073d3752eb721558/frozenlist-1.8.0-cp314-cp314t-win_amd64.whl", hash = "sha256:06be8f67f39c8b1dc671f5d83aaefd3358ae5cdcf8314552c57e7ed3e6475bdd", size = 49451, upload-time = "2025-10-06T05:37:53.425Z" }, + { url = "https://files.pythonhosted.org/packages/e0/a3/5982da14e113d07b325230f95060e2169f5311b1017ea8af2a29b374c289/frozenlist-1.8.0-cp314-cp314t-win_arm64.whl", hash = "sha256:102e6314ca4da683dca92e3b1355490fed5f313b768500084fbe6371fddfdb79", size = 42507, upload-time = "2025-10-06T05:37:54.513Z" }, + { url = "https://files.pythonhosted.org/packages/9a/9a/e35b4a917281c0b8419d4207f4334c8e8c5dbf4f3f5f9ada73958d937dcc/frozenlist-1.8.0-py3-none-any.whl", hash = "sha256:0c18a16eab41e82c295618a77502e17b195883241c563b00f0aa5106fc4eaa0d", size = 13409, upload-time = "2025-10-06T05:38:16.721Z" }, +] + +[[package]] +name = "fsspec" +version = "2026.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/51/7c/f60c259dcbf4f0c47cc4ddb8f7720d2dcdc8888c8e5ad84c73ea4531cc5b/fsspec-2026.2.0.tar.gz", hash = "sha256:6544e34b16869f5aacd5b90bdf1a71acb37792ea3ddf6125ee69a22a53fb8bff", size = 313441, upload-time = "2026-02-05T21:50:53.743Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/ab/fb21f4c939bb440104cc2b396d3be1d9b7a9fd3c6c2a53d98c45b3d7c954/fsspec-2026.2.0-py3-none-any.whl", hash = "sha256:98de475b5cb3bd66bedd5c4679e87b4fdfe1a3bf4d707b151b3c07e58c9a2437", size = 202505, upload-time = "2026-02-05T21:50:51.819Z" }, +] + +[package.optional-dependencies] +http = [ + { name = "aiohttp" }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "hf-transfer" +version = "0.1.9" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1a/eb/8fc64f40388c29ce8ce3b2b180a089d4d6b25b1d0d232d016704cb852104/hf_transfer-0.1.9.tar.gz", hash = "sha256:035572865dab29d17e783fbf1e84cf1cb24f3fcf8f1b17db1cfc7fdf139f02bf", size = 25201, upload-time = "2025-01-07T10:05:12.947Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a4/78/0dce00208f585fae675f40033ef9a30dedfa83665d5ac79f16beb4a0a6c2/hf_transfer-0.1.9-cp313-cp313t-macosx_10_12_x86_64.whl", hash = "sha256:6e94e8822da79573c9b6ae4d6b2f847c59a7a06c5327d7db20751b68538dc4f6", size = 1386084, upload-time = "2025-01-07T10:04:47.874Z" }, + { url = "https://files.pythonhosted.org/packages/ea/2e/3d60b1a9e9f29a2152aa66c823bf5e399ae7be3fef310ff0de86779c5d2d/hf_transfer-0.1.9-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:3ebc4ab9023414880c8b1d3c38174d1c9989eb5022d37e814fa91a3060123eb0", size = 1343558, upload-time = "2025-01-07T10:04:42.313Z" }, + { url = "https://files.pythonhosted.org/packages/fb/38/130a5ac3747f104033591bcac1c961cb1faadfdc91704f59b09c0b465ff2/hf_transfer-0.1.9-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8674026f21ed369aa2a0a4b46000aca850fc44cd2b54af33a172ce5325b4fc82", size = 3726676, upload-time = "2025-01-07T10:04:11.539Z" }, + { url = "https://files.pythonhosted.org/packages/15/a1/f4e27c5ad17aac616ae0849e2aede5aae31db8267a948c6b3eeb9fd96446/hf_transfer-0.1.9-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:3a736dfbb2c84f5a2c975478ad200c0c8bfcb58a25a35db402678fb87ce17fa4", size = 3062920, upload-time = "2025-01-07T10:04:16.297Z" }, + { url = "https://files.pythonhosted.org/packages/8d/0d/727abdfba39bc3f1132cfa4c970588c2c0bb0d82fe2d645cc10f4e2f8e0b/hf_transfer-0.1.9-cp313-cp313t-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:504b8427fd785dd8546d53b9fafe6e436bd7a3adf76b9dce556507650a7b4567", size = 3578681, upload-time = "2025-01-07T10:04:29.702Z" }, + { url = "https://files.pythonhosted.org/packages/50/d0/2b213eb1ea8b1252ccaf1a6c804d0aba03fea38aae4124df6a3acb70511a/hf_transfer-0.1.9-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2c7fc1b85f4d0f76e452765d7648c9f4bfd0aedb9ced2ae1ebfece2d8cfaf8e2", size = 3398837, upload-time = "2025-01-07T10:04:22.778Z" }, + { url = "https://files.pythonhosted.org/packages/8c/8a/79dbce9006e0bd6b74516f97451a7b7c64dbbb426df15d901dd438cfeee3/hf_transfer-0.1.9-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0d991376f0eac70a60f0cbc95602aa708a6f7c8617f28b4945c1431d67b8e3c8", size = 3546986, upload-time = "2025-01-07T10:04:36.415Z" }, + { url = "https://files.pythonhosted.org/packages/a9/f7/9ac239b6ee6fe0bad130325d987a93ea58c4118e50479f0786f1733b37e8/hf_transfer-0.1.9-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:e6ac4eddcd99575ed3735ed911ddf9d1697e2bd13aa3f0ad7e3904dd4863842e", size = 4071715, upload-time = "2025-01-07T10:04:53.224Z" }, + { url = "https://files.pythonhosted.org/packages/d8/a3/0ed697279f5eeb7a40f279bd783cf50e6d0b91f24120dcf66ef2cf8822b4/hf_transfer-0.1.9-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:57fd9880da1ee0f47250f735f791fab788f0aa1ee36afc49f761349869c8b4d9", size = 3388081, upload-time = "2025-01-07T10:04:57.818Z" }, + { url = "https://files.pythonhosted.org/packages/dc/eb/47e477bdf1d784f31c7540db6cc8c354b777e51a186897a7abda34517f36/hf_transfer-0.1.9-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:5d561f0520f493c66b016d99ceabe69c23289aa90be38dd802d2aef279f15751", size = 3658654, upload-time = "2025-01-07T10:05:03.168Z" }, + { url = "https://files.pythonhosted.org/packages/45/07/6661e43fbee09594a8a5e9bb778107d95fe38dac4c653982afe03d32bd4d/hf_transfer-0.1.9-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:a5b366d34cd449fe9b20ef25941e6eef0460a2f74e7389f02e673e1f88ebd538", size = 3690551, upload-time = "2025-01-07T10:05:09.238Z" }, + { url = "https://files.pythonhosted.org/packages/81/f5/461d2e5f307e5048289b1168d5c642ae3bb2504e88dff1a38b92ed990a21/hf_transfer-0.1.9-cp38-abi3-macosx_10_12_x86_64.whl", hash = "sha256:e66acf91df4a8b72f60223059df3003062a5ae111757187ed1a06750a30e911b", size = 1393046, upload-time = "2025-01-07T10:04:51.003Z" }, + { url = "https://files.pythonhosted.org/packages/41/ba/8d9fd9f1083525edfcb389c93738c802f3559cb749324090d7109c8bf4c2/hf_transfer-0.1.9-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:8669dbcc7a3e2e8d61d42cd24da9c50d57770bd74b445c65123291ca842a7e7a", size = 1348126, upload-time = "2025-01-07T10:04:45.712Z" }, + { url = "https://files.pythonhosted.org/packages/8e/a2/cd7885bc9959421065a6fae0fe67b6c55becdeda4e69b873e52976f9a9f0/hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8fd0167c4407a3bc4cdd0307e65ada2294ec04f1813d8a69a5243e379b22e9d8", size = 3728604, upload-time = "2025-01-07T10:04:14.173Z" }, + { url = "https://files.pythonhosted.org/packages/f6/2e/a072cf196edfeda3310c9a5ade0a0fdd785e6154b3ce24fc738c818da2a7/hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ee8b10afedcb75f71091bcc197c526a6ebf5c58bbbadb34fdeee6160f55f619f", size = 3064995, upload-time = "2025-01-07T10:04:18.663Z" }, + { url = "https://files.pythonhosted.org/packages/c2/84/aec9ef4c0fab93c1ea2b1badff38c78b4b2f86f0555b26d2051dbc920cde/hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5828057e313de59300dd1abb489444bc452efe3f479d3c55b31a8f680936ba42", size = 3580908, upload-time = "2025-01-07T10:04:32.834Z" }, + { url = "https://files.pythonhosted.org/packages/29/63/b560d39651a56603d64f1a0212d0472a44cbd965db2fa62b99d99cb981bf/hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fc6bd19e1cc177c66bdef15ef8636ad3bde79d5a4f608c158021153b4573509d", size = 3400839, upload-time = "2025-01-07T10:04:26.122Z" }, + { url = "https://files.pythonhosted.org/packages/d6/d8/f87ea6f42456254b48915970ed98e993110521e9263472840174d32c880d/hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cdca9bfb89e6f8f281890cc61a8aff2d3cecaff7e1a4d275574d96ca70098557", size = 3552664, upload-time = "2025-01-07T10:04:40.123Z" }, + { url = "https://files.pythonhosted.org/packages/d6/56/1267c39b65fc8f4e2113b36297320f102718bf5799b544a6cbe22013aa1d/hf_transfer-0.1.9-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:89a23f58b7b7effbc047b8ca286f131b17728c99a9f972723323003ffd1bb916", size = 4073732, upload-time = "2025-01-07T10:04:55.624Z" }, + { url = "https://files.pythonhosted.org/packages/82/1a/9c748befbe3decf7cb415e34f8a0c3789a0a9c55910dea73d581e48c0ce5/hf_transfer-0.1.9-cp38-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:dc7fff1345980d6c0ebb92c811d24afa4b98b3e07ed070c8e38cc91fd80478c5", size = 3390096, upload-time = "2025-01-07T10:04:59.98Z" }, + { url = "https://files.pythonhosted.org/packages/72/85/4c03da147b6b4b7cb12e074d3d44eee28604a387ed0eaf7eaaead5069c57/hf_transfer-0.1.9-cp38-abi3-musllinux_1_2_i686.whl", hash = "sha256:1a6bd16c667ebe89a069ca163060127a794fa3a3525292c900b8c8cc47985b0d", size = 3664743, upload-time = "2025-01-07T10:05:05.416Z" }, + { url = "https://files.pythonhosted.org/packages/e7/6e/e597b04f753f1b09e6893075d53a82a30c13855cbaa791402695b01e369f/hf_transfer-0.1.9-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:d2fde99d502093ade3ab1b53f80da18480e9902aa960dab7f74fb1b9e5bc5746", size = 3695243, upload-time = "2025-01-07T10:05:11.411Z" }, + { url = "https://files.pythonhosted.org/packages/09/89/d4e234727a26b2546c8fb70a276cd924260d60135f2165bf8b9ed67bb9a4/hf_transfer-0.1.9-cp38-abi3-win32.whl", hash = "sha256:435cc3cdc8524ce57b074032b8fd76eed70a4224d2091232fa6a8cef8fd6803e", size = 1086605, upload-time = "2025-01-07T10:05:18.873Z" }, + { url = "https://files.pythonhosted.org/packages/a1/14/f1e15b851d1c2af5b0b1a82bf8eb10bda2da62d98180220ba6fd8879bb5b/hf_transfer-0.1.9-cp38-abi3-win_amd64.whl", hash = "sha256:16f208fc678911c37e11aa7b586bc66a37d02e636208f18b6bc53d29b5df40ad", size = 1160240, upload-time = "2025-01-07T10:05:14.324Z" }, +] + +[[package]] +name = "hf-xet" +version = "1.4.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/53/92/ec9ad04d0b5728dca387a45af7bc98fbb0d73b2118759f5f6038b61a57e8/hf_xet-1.4.3.tar.gz", hash = "sha256:8ddedb73c8c08928c793df2f3401ec26f95be7f7e516a7bee2fbb546f6676113", size = 670477, upload-time = "2026-03-31T22:40:07.874Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/72/43/724d307b34e353da0abd476e02f72f735cdd2bc86082dee1b32ea0bfee1d/hf_xet-1.4.3-cp313-cp313t-macosx_10_12_x86_64.whl", hash = "sha256:7551659ba4f1e1074e9623996f28c3873682530aee0a846b7f2f066239228144", size = 3800935, upload-time = "2026-03-31T22:39:49.618Z" }, + { url = "https://files.pythonhosted.org/packages/2b/d2/8bee5996b699262edb87dbb54118d287c0e1b2fc78af7cdc41857ba5e3c4/hf_xet-1.4.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:bee693ada985e7045997f05f081d0e12c4c08bd7626dc397f8a7c487e6c04f7f", size = 3558942, upload-time = "2026-03-31T22:39:47.938Z" }, + { url = "https://files.pythonhosted.org/packages/c3/a1/e993d09cbe251196fb60812b09a58901c468127b7259d2bf0f68bf6088eb/hf_xet-1.4.3-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:21644b404bb0100fe3857892f752c4d09642586fd988e61501c95bbf44b393a3", size = 4207657, upload-time = "2026-03-31T22:39:39.69Z" }, + { url = "https://files.pythonhosted.org/packages/64/44/9eb6d21e5c34c63e5e399803a6932fa983cabdf47c0ecbcfe7ea97684b8c/hf_xet-1.4.3-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:987f09cfe418237812896a6736b81b1af02a3a6dcb4b4944425c4c4fca7a7cf8", size = 3986765, upload-time = "2026-03-31T22:39:37.936Z" }, + { url = "https://files.pythonhosted.org/packages/ea/7b/8ad6f16fdb82f5f7284a34b5ec48645bd575bdcd2f6f0d1644775909c486/hf_xet-1.4.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:60cf7fc43a99da0a853345cf86d23738c03983ee5249613a6305d3e57a5dca74", size = 4188162, upload-time = "2026-03-31T22:39:58.382Z" }, + { url = "https://files.pythonhosted.org/packages/1b/c4/39d6e136cbeea9ca5a23aad4b33024319222adbdc059ebcda5fc7d9d5ff4/hf_xet-1.4.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:2815a49a7a59f3e2edf0cf113ae88e8cb2ca2a221bf353fb60c609584f4884d4", size = 4424525, upload-time = "2026-03-31T22:40:00.225Z" }, + { url = "https://files.pythonhosted.org/packages/46/f2/adc32dae6bdbc367853118b9878139ac869419a4ae7ba07185dc31251b76/hf_xet-1.4.3-cp313-cp313t-win_amd64.whl", hash = "sha256:42ee323265f1e6a81b0e11094564fb7f7e0ec75b5105ffd91ae63f403a11931b", size = 3671610, upload-time = "2026-03-31T22:40:10.42Z" }, + { url = "https://files.pythonhosted.org/packages/e2/19/25d897dcc3f81953e0c2cde9ec186c7a0fee413eb0c9a7a9130d87d94d3a/hf_xet-1.4.3-cp313-cp313t-win_arm64.whl", hash = "sha256:27c976ba60079fb8217f485b9c5c7fcd21c90b0367753805f87cb9f3cdc4418a", size = 3528529, upload-time = "2026-03-31T22:40:09.106Z" }, + { url = "https://files.pythonhosted.org/packages/ec/36/3e8f85ca9fe09b8de2b2e10c63b3b3353d7dda88a0b3d426dffbe7b8313b/hf_xet-1.4.3-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:5251d5ece3a81815bae9abab41cf7ddb7bcb8f56411bce0827f4a3071c92fdc6", size = 3801019, upload-time = "2026-03-31T22:39:56.651Z" }, + { url = "https://files.pythonhosted.org/packages/b5/9c/defb6cb1de28bccb7bd8d95f6e60f72a3d3fa4cb3d0329c26fb9a488bfe7/hf_xet-1.4.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1feb0f3abeacee143367c326a128a2e2b60868ec12a36c225afb1d6c5a05e6d2", size = 3558746, upload-time = "2026-03-31T22:39:54.766Z" }, + { url = "https://files.pythonhosted.org/packages/c1/bd/8d001191893178ff8e826e46ad5299446e62b93cd164e17b0ffea08832ec/hf_xet-1.4.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8b301fc150290ca90b4fccd079829b84bb4786747584ae08b94b4577d82fb791", size = 4207692, upload-time = "2026-03-31T22:39:46.246Z" }, + { url = "https://files.pythonhosted.org/packages/ce/48/6790b402803250e9936435613d3a78b9aaeee7973439f0918848dde58309/hf_xet-1.4.3-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:d972fbe95ddc0d3c0fc49b31a8a69f47db35c1e3699bf316421705741aab6653", size = 3986281, upload-time = "2026-03-31T22:39:44.648Z" }, + { url = "https://files.pythonhosted.org/packages/51/56/ea62552fe53db652a9099eda600b032d75554d0e86c12a73824bfedef88b/hf_xet-1.4.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c5b48db1ee344a805a1b9bd2cda9b6b65fe77ed3787bd6e87ad5521141d317cd", size = 4187414, upload-time = "2026-03-31T22:40:04.951Z" }, + { url = "https://files.pythonhosted.org/packages/7d/f5/bc1456d4638061bea997e6d2db60a1a613d7b200e0755965ec312dc1ef79/hf_xet-1.4.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:22bdc1f5fb8b15bf2831440b91d1c9bbceeb7e10c81a12e8d75889996a5c9da8", size = 4424368, upload-time = "2026-03-31T22:40:06.347Z" }, + { url = "https://files.pythonhosted.org/packages/e4/76/ab597bae87e1f06d18d3ecb8ed7f0d3c9a37037fc32ce76233d369273c64/hf_xet-1.4.3-cp314-cp314t-win_amd64.whl", hash = "sha256:0392c79b7cf48418cd61478c1a925246cf10639f4cd9d94368d8ca1e8df9ea07", size = 3672280, upload-time = "2026-03-31T22:40:16.401Z" }, + { url = "https://files.pythonhosted.org/packages/62/05/2e462d34e23a09a74d73785dbed71cc5dbad82a72eee2ad60a72a554155d/hf_xet-1.4.3-cp314-cp314t-win_arm64.whl", hash = "sha256:681c92a07796325778a79d76c67011764ecc9042a8c3579332b61b63ae512075", size = 3528945, upload-time = "2026-03-31T22:40:14.995Z" }, + { url = "https://files.pythonhosted.org/packages/ac/9f/9c23e4a447b8f83120798f9279d0297a4d1360bdbf59ef49ebec78fe2545/hf_xet-1.4.3-cp37-abi3-macosx_10_12_x86_64.whl", hash = "sha256:d0da85329eaf196e03e90b84c2d0aca53bd4573d097a75f99609e80775f98025", size = 3805048, upload-time = "2026-03-31T22:39:53.105Z" }, + { url = "https://files.pythonhosted.org/packages/0b/f8/7aacb8e5f4a7899d39c787b5984e912e6c18b11be136ef13947d7a66d265/hf_xet-1.4.3-cp37-abi3-macosx_11_0_arm64.whl", hash = "sha256:e23717ce4186b265f69afa66e6f0069fe7efbf331546f5c313d00e123dc84583", size = 3562178, upload-time = "2026-03-31T22:39:51.295Z" }, + { url = "https://files.pythonhosted.org/packages/df/9a/a24b26dc8a65f0ecc0fe5be981a19e61e7ca963b85e062c083f3a9100529/hf_xet-1.4.3-cp37-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fc360b70c815bf340ed56c7b8c63aacf11762a4b099b2fe2c9bd6d6068668c08", size = 4212320, upload-time = "2026-03-31T22:39:42.922Z" }, + { url = "https://files.pythonhosted.org/packages/53/60/46d493db155d2ee2801b71fb1b0fd67696359047fdd8caee2c914cc50c79/hf_xet-1.4.3-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:39f2d2e9654cd9b4319885733993807aab6de9dfbd34c42f0b78338d6617421f", size = 3991546, upload-time = "2026-03-31T22:39:41.335Z" }, + { url = "https://files.pythonhosted.org/packages/bc/f5/067363e1c96c6b17256910830d1b54099d06287e10f4ec6ec4e7e08371fc/hf_xet-1.4.3-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:49ad8a8cead2b56051aa84d7fce3e1335efe68df3cf6c058f22a65513885baac", size = 4193200, upload-time = "2026-03-31T22:40:01.936Z" }, + { url = "https://files.pythonhosted.org/packages/42/4b/53951592882d9c23080c7644542fda34a3813104e9e11fa1a7d82d419cb8/hf_xet-1.4.3-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:7716d62015477a70ea272d2d68cd7cad140f61c52ee452e133e139abfe2c17ba", size = 4429392, upload-time = "2026-03-31T22:40:03.492Z" }, + { url = "https://files.pythonhosted.org/packages/8a/21/75a6c175b4e79662ad8e62f46a40ce341d8d6b206b06b4320d07d55b188c/hf_xet-1.4.3-cp37-abi3-win_amd64.whl", hash = "sha256:6b591fcad34e272a5b02607485e4f2a1334aebf1bc6d16ce8eb1eb8978ac2021", size = 3677359, upload-time = "2026-03-31T22:40:13.619Z" }, + { url = "https://files.pythonhosted.org/packages/8a/7c/44314ecd0e89f8b2b51c9d9e5e7a60a9c1c82024ac471d415860557d3cd8/hf_xet-1.4.3-cp37-abi3-win_arm64.whl", hash = "sha256:7c2c7e20bcfcc946dc67187c203463f5e932e395845d098cc2a93f5b67ca0b47", size = 3533664, upload-time = "2026-03-31T22:40:12.152Z" }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, +] + +[[package]] +name = "huggingface-hub" +version = "1.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "filelock" }, + { name = "fsspec" }, + { name = "hf-xet", marker = "platform_machine == 'AMD64' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'" }, + { name = "httpx" }, + { name = "packaging" }, + { name = "pyyaml" }, + { name = "tqdm" }, + { name = "typer" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/56/52/1b54cb569509c725a32c1315261ac9fd0e6b91bbbf74d86fca10d3376164/huggingface_hub-1.12.0.tar.gz", hash = "sha256:7c3fe85e24b652334e5d456d7a812cd9a071e75630fac4365d9165ab5e4a34b6", size = 763091, upload-time = "2026-04-24T13:32:08.674Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/2b/ef03ddb96bd1123503c2bd6932001020292deea649e9bf4caa2cb65a85bf/huggingface_hub-1.12.0-py3-none-any.whl", hash = "sha256:d74939969585ee35748bd66de09baf84099d461bda7287cd9043bfb99b0e424d", size = 646806, upload-time = "2026-04-24T13:32:06.717Z" }, +] + +[[package]] +name = "idna" +version = "3.13" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ce/cc/762dfb036166873f0059f3b7de4565e1b5bc3d6f28a414c13da27e442f99/idna-3.13.tar.gz", hash = "sha256:585ea8fe5d69b9181ec1afba340451fba6ba764af97026f92a91d4eef164a242", size = 194210, upload-time = "2026-04-22T16:42:42.314Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5d/13/ad7d7ca3808a898b4612b6fe93cde56b53f3034dcde235acb1f0e1df24c6/idna-3.13-py3-none-any.whl", hash = "sha256:892ea0cde124a99ce773decba204c5552b69c3c67ffd5f232eb7696135bc8bb3", size = 68629, upload-time = "2026-04-22T16:42:40.909Z" }, +] + +[[package]] +name = "markdown-it-py" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mdurl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz", hash = "sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3", size = 73070, upload-time = "2025-08-11T12:57:52.854Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl", hash = "sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147", size = 87321, upload-time = "2025-08-11T12:57:51.923Z" }, +] + +[[package]] +name = "mdurl" +version = "0.1.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, +] + +[[package]] +name = "multidict" +version = "6.7.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1a/c2/c2d94cbe6ac1753f3fc980da97b3d930efe1da3af3c9f5125354436c073d/multidict-6.7.1.tar.gz", hash = "sha256:ec6652a1bee61c53a3e5776b6049172c53b6aaba34f18c9ad04f82712bac623d", size = 102010, upload-time = "2026-01-26T02:46:45.979Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8d/9c/f20e0e2cf80e4b2e4b1c365bf5fe104ee633c751a724246262db8f1a0b13/multidict-6.7.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:a90f75c956e32891a4eda3639ce6dd86e87105271f43d43442a3aedf3cddf172", size = 76893, upload-time = "2026-01-26T02:43:52.754Z" }, + { url = "https://files.pythonhosted.org/packages/fe/cf/18ef143a81610136d3da8193da9d80bfe1cb548a1e2d1c775f26b23d024a/multidict-6.7.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3fccb473e87eaa1382689053e4a4618e7ba7b9b9b8d6adf2027ee474597128cd", size = 45456, upload-time = "2026-01-26T02:43:53.893Z" }, + { url = "https://files.pythonhosted.org/packages/a9/65/1caac9d4cd32e8433908683446eebc953e82d22b03d10d41a5f0fefe991b/multidict-6.7.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b0fa96985700739c4c7853a43c0b3e169360d6855780021bfc6d0f1ce7c123e7", size = 43872, upload-time = "2026-01-26T02:43:55.041Z" }, + { url = "https://files.pythonhosted.org/packages/cf/3b/d6bd75dc4f3ff7c73766e04e705b00ed6dbbaccf670d9e05a12b006f5a21/multidict-6.7.1-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:cb2a55f408c3043e42b40cc8eecd575afa27b7e0b956dfb190de0f8499a57a53", size = 251018, upload-time = "2026-01-26T02:43:56.198Z" }, + { url = "https://files.pythonhosted.org/packages/fd/80/c959c5933adedb9ac15152e4067c702a808ea183a8b64cf8f31af8ad3155/multidict-6.7.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eb0ce7b2a32d09892b3dd6cc44877a0d02a33241fafca5f25c8b6b62374f8b75", size = 258883, upload-time = "2026-01-26T02:43:57.499Z" }, + { url = "https://files.pythonhosted.org/packages/86/85/7ed40adafea3d4f1c8b916e3b5cc3a8e07dfcdcb9cd72800f4ed3ca1b387/multidict-6.7.1-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c3a32d23520ee37bf327d1e1a656fec76a2edd5c038bf43eddfa0572ec49c60b", size = 242413, upload-time = "2026-01-26T02:43:58.755Z" }, + { url = "https://files.pythonhosted.org/packages/d2/57/b8565ff533e48595503c785f8361ff9a4fde4d67de25c207cd0ba3befd03/multidict-6.7.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9c90fed18bffc0189ba814749fdcc102b536e83a9f738a9003e569acd540a733", size = 268404, upload-time = "2026-01-26T02:44:00.216Z" }, + { url = "https://files.pythonhosted.org/packages/e0/50/9810c5c29350f7258180dfdcb2e52783a0632862eb334c4896ac717cebcb/multidict-6.7.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:da62917e6076f512daccfbbde27f46fed1c98fee202f0559adec8ee0de67f71a", size = 269456, upload-time = "2026-01-26T02:44:02.202Z" }, + { url = "https://files.pythonhosted.org/packages/f3/8d/5e5be3ced1d12966fefb5c4ea3b2a5b480afcea36406559442c6e31d4a48/multidict-6.7.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bfde23ef6ed9db7eaee6c37dcec08524cb43903c60b285b172b6c094711b3961", size = 256322, upload-time = "2026-01-26T02:44:03.56Z" }, + { url = "https://files.pythonhosted.org/packages/31/6e/d8a26d81ac166a5592782d208dd90dfdc0a7a218adaa52b45a672b46c122/multidict-6.7.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3758692429e4e32f1ba0df23219cd0b4fc0a52f476726fff9337d1a57676a582", size = 253955, upload-time = "2026-01-26T02:44:04.845Z" }, + { url = "https://files.pythonhosted.org/packages/59/4c/7c672c8aad41534ba619bcd4ade7a0dc87ed6b8b5c06149b85d3dd03f0cd/multidict-6.7.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:398c1478926eca669f2fd6a5856b6de9c0acf23a2cb59a14c0ba5844fa38077e", size = 251254, upload-time = "2026-01-26T02:44:06.133Z" }, + { url = "https://files.pythonhosted.org/packages/7b/bd/84c24de512cbafbdbc39439f74e967f19570ce7924e3007174a29c348916/multidict-6.7.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:c102791b1c4f3ab36ce4101154549105a53dc828f016356b3e3bcae2e3a039d3", size = 252059, upload-time = "2026-01-26T02:44:07.518Z" }, + { url = "https://files.pythonhosted.org/packages/fa/ba/f5449385510825b73d01c2d4087bf6d2fccc20a2d42ac34df93191d3dd03/multidict-6.7.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:a088b62bd733e2ad12c50dad01b7d0166c30287c166e137433d3b410add807a6", size = 263588, upload-time = "2026-01-26T02:44:09.382Z" }, + { url = "https://files.pythonhosted.org/packages/d7/11/afc7c677f68f75c84a69fe37184f0f82fce13ce4b92f49f3db280b7e92b3/multidict-6.7.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:3d51ff4785d58d3f6c91bdbffcb5e1f7ddfda557727043aa20d20ec4f65e324a", size = 259642, upload-time = "2026-01-26T02:44:10.73Z" }, + { url = "https://files.pythonhosted.org/packages/2b/17/ebb9644da78c4ab36403739e0e6e0e30ebb135b9caf3440825001a0bddcb/multidict-6.7.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fc5907494fccf3e7d3f94f95c91d6336b092b5fc83811720fae5e2765890dfba", size = 251377, upload-time = "2026-01-26T02:44:12.042Z" }, + { url = "https://files.pythonhosted.org/packages/ca/a4/840f5b97339e27846c46307f2530a2805d9d537d8b8bd416af031cad7fa0/multidict-6.7.1-cp312-cp312-win32.whl", hash = "sha256:28ca5ce2fd9716631133d0e9a9b9a745ad7f60bac2bccafb56aa380fc0b6c511", size = 41887, upload-time = "2026-01-26T02:44:14.245Z" }, + { url = "https://files.pythonhosted.org/packages/80/31/0b2517913687895f5904325c2069d6a3b78f66cc641a86a2baf75a05dcbb/multidict-6.7.1-cp312-cp312-win_amd64.whl", hash = "sha256:fcee94dfbd638784645b066074b338bc9cc155d4b4bffa4adce1615c5a426c19", size = 46053, upload-time = "2026-01-26T02:44:15.371Z" }, + { url = "https://files.pythonhosted.org/packages/0c/5b/aba28e4ee4006ae4c7df8d327d31025d760ffa992ea23812a601d226e682/multidict-6.7.1-cp312-cp312-win_arm64.whl", hash = "sha256:ba0a9fb644d0c1a2194cf7ffb043bd852cea63a57f66fbd33959f7dae18517bf", size = 43307, upload-time = "2026-01-26T02:44:16.852Z" }, + { url = "https://files.pythonhosted.org/packages/f2/22/929c141d6c0dba87d3e1d38fbdf1ba8baba86b7776469f2bc2d3227a1e67/multidict-6.7.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:2b41f5fed0ed563624f1c17630cb9941cf2309d4df00e494b551b5f3e3d67a23", size = 76174, upload-time = "2026-01-26T02:44:18.509Z" }, + { url = "https://files.pythonhosted.org/packages/c7/75/bc704ae15fee974f8fccd871305e254754167dce5f9e42d88a2def741a1d/multidict-6.7.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:84e61e3af5463c19b67ced91f6c634effb89ef8bfc5ca0267f954451ed4bb6a2", size = 45116, upload-time = "2026-01-26T02:44:19.745Z" }, + { url = "https://files.pythonhosted.org/packages/79/76/55cd7186f498ed080a18440c9013011eb548f77ae1b297206d030eb1180a/multidict-6.7.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:935434b9853c7c112eee7ac891bc4cb86455aa631269ae35442cb316790c1445", size = 43524, upload-time = "2026-01-26T02:44:21.571Z" }, + { url = "https://files.pythonhosted.org/packages/e9/3c/414842ef8d5a1628d68edee29ba0e5bcf235dbfb3ccd3ea303a7fe8c72ff/multidict-6.7.1-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:432feb25a1cb67fe82a9680b4d65fb542e4635cb3166cd9c01560651ad60f177", size = 249368, upload-time = "2026-01-26T02:44:22.803Z" }, + { url = "https://files.pythonhosted.org/packages/f6/32/befed7f74c458b4a525e60519fe8d87eef72bb1e99924fa2b0f9d97a221e/multidict-6.7.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e82d14e3c948952a1a85503817e038cba5905a3352de76b9a465075d072fba23", size = 256952, upload-time = "2026-01-26T02:44:24.306Z" }, + { url = "https://files.pythonhosted.org/packages/03/d6/c878a44ba877f366630c860fdf74bfb203c33778f12b6ac274936853c451/multidict-6.7.1-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:4cfb48c6ea66c83bcaaf7e4dfa7ec1b6bbcf751b7db85a328902796dfde4c060", size = 240317, upload-time = "2026-01-26T02:44:25.772Z" }, + { url = "https://files.pythonhosted.org/packages/68/49/57421b4d7ad2e9e60e25922b08ceb37e077b90444bde6ead629095327a6f/multidict-6.7.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:1d540e51b7e8e170174555edecddbd5538105443754539193e3e1061864d444d", size = 267132, upload-time = "2026-01-26T02:44:27.648Z" }, + { url = "https://files.pythonhosted.org/packages/b7/fe/ec0edd52ddbcea2a2e89e174f0206444a61440b40f39704e64dc807a70bd/multidict-6.7.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:273d23f4b40f3dce4d6c8a821c741a86dec62cded82e1175ba3d99be128147ed", size = 268140, upload-time = "2026-01-26T02:44:29.588Z" }, + { url = "https://files.pythonhosted.org/packages/b0/73/6e1b01cbeb458807aa0831742232dbdd1fa92bfa33f52a3f176b4ff3dc11/multidict-6.7.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9d624335fd4fa1c08a53f8b4be7676ebde19cd092b3895c421045ca87895b429", size = 254277, upload-time = "2026-01-26T02:44:30.902Z" }, + { url = "https://files.pythonhosted.org/packages/6a/b2/5fb8c124d7561a4974c342bc8c778b471ebbeb3cc17df696f034a7e9afe7/multidict-6.7.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:12fad252f8b267cc75b66e8fc51b3079604e8d43a75428ffe193cd9e2195dfd6", size = 252291, upload-time = "2026-01-26T02:44:32.31Z" }, + { url = "https://files.pythonhosted.org/packages/5a/96/51d4e4e06bcce92577fcd488e22600bd38e4fd59c20cb49434d054903bd2/multidict-6.7.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:03ede2a6ffbe8ef936b92cb4529f27f42be7f56afcdab5ab739cd5f27fb1cbf9", size = 250156, upload-time = "2026-01-26T02:44:33.734Z" }, + { url = "https://files.pythonhosted.org/packages/db/6b/420e173eec5fba721a50e2a9f89eda89d9c98fded1124f8d5c675f7a0c0f/multidict-6.7.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:90efbcf47dbe33dcf643a1e400d67d59abeac5db07dc3f27d6bdeae497a2198c", size = 249742, upload-time = "2026-01-26T02:44:35.222Z" }, + { url = "https://files.pythonhosted.org/packages/44/a3/ec5b5bd98f306bc2aa297b8c6f11a46714a56b1e6ef5ebda50a4f5d7c5fb/multidict-6.7.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:5c4b9bfc148f5a91be9244d6264c53035c8a0dcd2f51f1c3c6e30e30ebaa1c84", size = 262221, upload-time = "2026-01-26T02:44:36.604Z" }, + { url = "https://files.pythonhosted.org/packages/cd/f7/e8c0d0da0cd1e28d10e624604e1a36bcc3353aaebdfdc3a43c72bc683a12/multidict-6.7.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:401c5a650f3add2472d1d288c26deebc540f99e2fb83e9525007a74cd2116f1d", size = 258664, upload-time = "2026-01-26T02:44:38.008Z" }, + { url = "https://files.pythonhosted.org/packages/52/da/151a44e8016dd33feed44f730bd856a66257c1ee7aed4f44b649fb7edeb3/multidict-6.7.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:97891f3b1b3ffbded884e2916cacf3c6fc87b66bb0dde46f7357404750559f33", size = 249490, upload-time = "2026-01-26T02:44:39.386Z" }, + { url = "https://files.pythonhosted.org/packages/87/af/a3b86bf9630b732897f6fc3f4c4714b90aa4361983ccbdcd6c0339b21b0c/multidict-6.7.1-cp313-cp313-win32.whl", hash = "sha256:e1c5988359516095535c4301af38d8a8838534158f649c05dd1050222321bcb3", size = 41695, upload-time = "2026-01-26T02:44:41.318Z" }, + { url = "https://files.pythonhosted.org/packages/b2/35/e994121b0e90e46134673422dd564623f93304614f5d11886b1b3e06f503/multidict-6.7.1-cp313-cp313-win_amd64.whl", hash = "sha256:960c83bf01a95b12b08fd54324a4eb1d5b52c88932b5cba5d6e712bb3ed12eb5", size = 45884, upload-time = "2026-01-26T02:44:42.488Z" }, + { url = "https://files.pythonhosted.org/packages/ca/61/42d3e5dbf661242a69c97ea363f2d7b46c567da8eadef8890022be6e2ab0/multidict-6.7.1-cp313-cp313-win_arm64.whl", hash = "sha256:563fe25c678aaba333d5399408f5ec3c383ca5b663e7f774dd179a520b8144df", size = 43122, upload-time = "2026-01-26T02:44:43.664Z" }, + { url = "https://files.pythonhosted.org/packages/6d/b3/e6b21c6c4f314bb956016b0b3ef2162590a529b84cb831c257519e7fde44/multidict-6.7.1-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:c76c4bec1538375dad9d452d246ca5368ad6e1c9039dadcf007ae59c70619ea1", size = 83175, upload-time = "2026-01-26T02:44:44.894Z" }, + { url = "https://files.pythonhosted.org/packages/fb/76/23ecd2abfe0957b234f6c960f4ade497f55f2c16aeb684d4ecdbf1c95791/multidict-6.7.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:57b46b24b5d5ebcc978da4ec23a819a9402b4228b8a90d9c656422b4bdd8a963", size = 48460, upload-time = "2026-01-26T02:44:46.106Z" }, + { url = "https://files.pythonhosted.org/packages/c4/57/a0ed92b23f3a042c36bc4227b72b97eca803f5f1801c1ab77c8a212d455e/multidict-6.7.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:e954b24433c768ce78ab7929e84ccf3422e46deb45a4dc9f93438f8217fa2d34", size = 46930, upload-time = "2026-01-26T02:44:47.278Z" }, + { url = "https://files.pythonhosted.org/packages/b5/66/02ec7ace29162e447f6382c495dc95826bf931d3818799bbef11e8f7df1a/multidict-6.7.1-cp313-cp313t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:3bd231490fa7217cc832528e1cd8752a96f0125ddd2b5749390f7c3ec8721b65", size = 242582, upload-time = "2026-01-26T02:44:48.604Z" }, + { url = "https://files.pythonhosted.org/packages/58/18/64f5a795e7677670e872673aca234162514696274597b3708b2c0d276cce/multidict-6.7.1-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:253282d70d67885a15c8a7716f3a73edf2d635793ceda8173b9ecc21f2fb8292", size = 250031, upload-time = "2026-01-26T02:44:50.544Z" }, + { url = "https://files.pythonhosted.org/packages/c8/ed/e192291dbbe51a8290c5686f482084d31bcd9d09af24f63358c3d42fd284/multidict-6.7.1-cp313-cp313t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:0b4c48648d7649c9335cf1927a8b87fa692de3dcb15faa676c6a6f1f1aabda43", size = 228596, upload-time = "2026-01-26T02:44:51.951Z" }, + { url = "https://files.pythonhosted.org/packages/1e/7e/3562a15a60cf747397e7f2180b0a11dc0c38d9175a650e75fa1b4d325e15/multidict-6.7.1-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:98bc624954ec4d2c7cb074b8eefc2b5d0ce7d482e410df446414355d158fe4ca", size = 257492, upload-time = "2026-01-26T02:44:53.902Z" }, + { url = "https://files.pythonhosted.org/packages/24/02/7d0f9eae92b5249bb50ac1595b295f10e263dd0078ebb55115c31e0eaccd/multidict-6.7.1-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:1b99af4d9eec0b49927b4402bcbb58dea89d3e0db8806a4086117019939ad3dd", size = 255899, upload-time = "2026-01-26T02:44:55.316Z" }, + { url = "https://files.pythonhosted.org/packages/00/e3/9b60ed9e23e64c73a5cde95269ef1330678e9c6e34dd4eb6b431b85b5a10/multidict-6.7.1-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6aac4f16b472d5b7dc6f66a0d49dd57b0e0902090be16594dc9ebfd3d17c47e7", size = 247970, upload-time = "2026-01-26T02:44:56.783Z" }, + { url = "https://files.pythonhosted.org/packages/3e/06/538e58a63ed5cfb0bd4517e346b91da32fde409d839720f664e9a4ae4f9d/multidict-6.7.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:21f830fe223215dffd51f538e78c172ed7c7f60c9b96a2bf05c4848ad49921c3", size = 245060, upload-time = "2026-01-26T02:44:58.195Z" }, + { url = "https://files.pythonhosted.org/packages/b2/2f/d743a3045a97c895d401e9bd29aaa09b94f5cbdf1bd561609e5a6c431c70/multidict-6.7.1-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:f5dd81c45b05518b9aa4da4aa74e1c93d715efa234fd3e8a179df611cc85e5f4", size = 235888, upload-time = "2026-01-26T02:44:59.57Z" }, + { url = "https://files.pythonhosted.org/packages/38/83/5a325cac191ab28b63c52f14f1131f3b0a55ba3b9aa65a6d0bf2a9b921a0/multidict-6.7.1-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:eb304767bca2bb92fb9c5bd33cedc95baee5bb5f6c88e63706533a1c06ad08c8", size = 243554, upload-time = "2026-01-26T02:45:01.054Z" }, + { url = "https://files.pythonhosted.org/packages/20/1f/9d2327086bd15da2725ef6aae624208e2ef828ed99892b17f60c344e57ed/multidict-6.7.1-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:c9035dde0f916702850ef66460bc4239d89d08df4d02023a5926e7446724212c", size = 252341, upload-time = "2026-01-26T02:45:02.484Z" }, + { url = "https://files.pythonhosted.org/packages/e8/2c/2a1aa0280cf579d0f6eed8ee5211c4f1730bd7e06c636ba2ee6aafda302e/multidict-6.7.1-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:af959b9beeb66c822380f222f0e0a1889331597e81f1ded7f374f3ecb0fd6c52", size = 246391, upload-time = "2026-01-26T02:45:03.862Z" }, + { url = "https://files.pythonhosted.org/packages/e5/03/7ca022ffc36c5a3f6e03b179a5ceb829be9da5783e6fe395f347c0794680/multidict-6.7.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:41f2952231456154ee479651491e94118229844dd7226541788be783be2b5108", size = 243422, upload-time = "2026-01-26T02:45:05.296Z" }, + { url = "https://files.pythonhosted.org/packages/dc/1d/b31650eab6c5778aceed46ba735bd97f7c7d2f54b319fa916c0f96e7805b/multidict-6.7.1-cp313-cp313t-win32.whl", hash = "sha256:df9f19c28adcb40b6aae30bbaa1478c389efd50c28d541d76760199fc1037c32", size = 47770, upload-time = "2026-01-26T02:45:06.754Z" }, + { url = "https://files.pythonhosted.org/packages/ac/5b/2d2d1d522e51285bd61b1e20df8f47ae1a9d80839db0b24ea783b3832832/multidict-6.7.1-cp313-cp313t-win_amd64.whl", hash = "sha256:d54ecf9f301853f2c5e802da559604b3e95bb7a3b01a9c295c6ee591b9882de8", size = 53109, upload-time = "2026-01-26T02:45:08.044Z" }, + { url = "https://files.pythonhosted.org/packages/3d/a3/cc409ba012c83ca024a308516703cf339bdc4b696195644a7215a5164a24/multidict-6.7.1-cp313-cp313t-win_arm64.whl", hash = "sha256:5a37ca18e360377cfda1d62f5f382ff41f2b8c4ccb329ed974cc2e1643440118", size = 45573, upload-time = "2026-01-26T02:45:09.349Z" }, + { url = "https://files.pythonhosted.org/packages/91/cc/db74228a8be41884a567e88a62fd589a913708fcf180d029898c17a9a371/multidict-6.7.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:8f333ec9c5eb1b7105e3b84b53141e66ca05a19a605368c55450b6ba208cb9ee", size = 75190, upload-time = "2026-01-26T02:45:10.651Z" }, + { url = "https://files.pythonhosted.org/packages/d5/22/492f2246bb5b534abd44804292e81eeaf835388901f0c574bac4eeec73c5/multidict-6.7.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:a407f13c188f804c759fc6a9f88286a565c242a76b27626594c133b82883b5c2", size = 44486, upload-time = "2026-01-26T02:45:11.938Z" }, + { url = "https://files.pythonhosted.org/packages/f1/4f/733c48f270565d78b4544f2baddc2fb2a245e5a8640254b12c36ac7ac68e/multidict-6.7.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:0e161ddf326db5577c3a4cc2d8648f81456e8a20d40415541587a71620d7a7d1", size = 43219, upload-time = "2026-01-26T02:45:14.346Z" }, + { url = "https://files.pythonhosted.org/packages/24/bb/2c0c2287963f4259c85e8bcbba9182ced8d7fca65c780c38e99e61629d11/multidict-6.7.1-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:1e3a8bb24342a8201d178c3b4984c26ba81a577c80d4d525727427460a50c22d", size = 245132, upload-time = "2026-01-26T02:45:15.712Z" }, + { url = "https://files.pythonhosted.org/packages/a7/f9/44d4b3064c65079d2467888794dea218d1601898ac50222ab8a9a8094460/multidict-6.7.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:97231140a50f5d447d3164f994b86a0bed7cd016e2682f8650d6a9158e14fd31", size = 252420, upload-time = "2026-01-26T02:45:17.293Z" }, + { url = "https://files.pythonhosted.org/packages/8b/13/78f7275e73fa17b24c9a51b0bd9d73ba64bb32d0ed51b02a746eb876abe7/multidict-6.7.1-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:6b10359683bd8806a200fd2909e7c8ca3a7b24ec1d8132e483d58e791d881048", size = 233510, upload-time = "2026-01-26T02:45:19.356Z" }, + { url = "https://files.pythonhosted.org/packages/4b/25/8167187f62ae3cbd52da7893f58cb036b47ea3fb67138787c76800158982/multidict-6.7.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:283ddac99f7ac25a4acadbf004cb5ae34480bbeb063520f70ce397b281859362", size = 264094, upload-time = "2026-01-26T02:45:20.834Z" }, + { url = "https://files.pythonhosted.org/packages/a1/e7/69a3a83b7b030cf283fb06ce074a05a02322359783424d7edf0f15fe5022/multidict-6.7.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:538cec1e18c067d0e6103aa9a74f9e832904c957adc260e61cd9d8cf0c3b3d37", size = 260786, upload-time = "2026-01-26T02:45:22.818Z" }, + { url = "https://files.pythonhosted.org/packages/fe/3b/8ec5074bcfc450fe84273713b4b0a0dd47c0249358f5d82eb8104ffe2520/multidict-6.7.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7eee46ccb30ff48a1e35bb818cc90846c6be2b68240e42a78599166722cea709", size = 248483, upload-time = "2026-01-26T02:45:24.368Z" }, + { url = "https://files.pythonhosted.org/packages/48/5a/d5a99e3acbca0e29c5d9cba8f92ceb15dce78bab963b308ae692981e3a5d/multidict-6.7.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:fa263a02f4f2dd2d11a7b1bb4362aa7cb1049f84a9235d31adf63f30143469a0", size = 248403, upload-time = "2026-01-26T02:45:25.982Z" }, + { url = "https://files.pythonhosted.org/packages/35/48/e58cd31f6c7d5102f2a4bf89f96b9cf7e00b6c6f3d04ecc44417c00a5a3c/multidict-6.7.1-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:2e1425e2f99ec5bd36c15a01b690a1a2456209c5deed58f95469ffb46039ccbb", size = 240315, upload-time = "2026-01-26T02:45:27.487Z" }, + { url = "https://files.pythonhosted.org/packages/94/33/1cd210229559cb90b6786c30676bb0c58249ff42f942765f88793b41fdce/multidict-6.7.1-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:497394b3239fc6f0e13a78a3e1b61296e72bf1c5f94b4c4eb80b265c37a131cd", size = 245528, upload-time = "2026-01-26T02:45:28.991Z" }, + { url = "https://files.pythonhosted.org/packages/64/f2/6e1107d226278c876c783056b7db43d800bb64c6131cec9c8dfb6903698e/multidict-6.7.1-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:233b398c29d3f1b9676b4b6f75c518a06fcb2ea0b925119fb2c1bc35c05e1601", size = 258784, upload-time = "2026-01-26T02:45:30.503Z" }, + { url = "https://files.pythonhosted.org/packages/4d/c1/11f664f14d525e4a1b5327a82d4de61a1db604ab34c6603bb3c2cc63ad34/multidict-6.7.1-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:93b1818e4a6e0930454f0f2af7dfce69307ca03cdcfb3739bf4d91241967b6c1", size = 251980, upload-time = "2026-01-26T02:45:32.603Z" }, + { url = "https://files.pythonhosted.org/packages/e1/9f/75a9ac888121d0c5bbd4ecf4eead45668b1766f6baabfb3b7f66a410e231/multidict-6.7.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:f33dc2a3abe9249ea5d8360f969ec7f4142e7ac45ee7014d8f8d5acddf178b7b", size = 243602, upload-time = "2026-01-26T02:45:34.043Z" }, + { url = "https://files.pythonhosted.org/packages/9a/e7/50bf7b004cc8525d80dbbbedfdc7aed3e4c323810890be4413e589074032/multidict-6.7.1-cp314-cp314-win32.whl", hash = "sha256:3ab8b9d8b75aef9df299595d5388b14530839f6422333357af1339443cff777d", size = 40930, upload-time = "2026-01-26T02:45:36.278Z" }, + { url = "https://files.pythonhosted.org/packages/e0/bf/52f25716bbe93745595800f36fb17b73711f14da59ed0bb2eba141bc9f0f/multidict-6.7.1-cp314-cp314-win_amd64.whl", hash = "sha256:5e01429a929600e7dab7b166062d9bb54a5eed752384c7384c968c2afab8f50f", size = 45074, upload-time = "2026-01-26T02:45:37.546Z" }, + { url = "https://files.pythonhosted.org/packages/97/ab/22803b03285fa3a525f48217963da3a65ae40f6a1b6f6cf2768879e208f9/multidict-6.7.1-cp314-cp314-win_arm64.whl", hash = "sha256:4885cb0e817aef5d00a2e8451d4665c1808378dc27c2705f1bf4ef8505c0d2e5", size = 42471, upload-time = "2026-01-26T02:45:38.889Z" }, + { url = "https://files.pythonhosted.org/packages/e0/6d/f9293baa6146ba9507e360ea0292b6422b016907c393e2f63fc40ab7b7b5/multidict-6.7.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:0458c978acd8e6ea53c81eefaddbbee9c6c5e591f41b3f5e8e194780fe026581", size = 82401, upload-time = "2026-01-26T02:45:40.254Z" }, + { url = "https://files.pythonhosted.org/packages/7a/68/53b5494738d83558d87c3c71a486504d8373421c3e0dbb6d0db48ad42ee0/multidict-6.7.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:c0abd12629b0af3cf590982c0b413b1e7395cd4ec026f30986818ab95bfaa94a", size = 48143, upload-time = "2026-01-26T02:45:41.635Z" }, + { url = "https://files.pythonhosted.org/packages/37/e8/5284c53310dcdc99ce5d66563f6e5773531a9b9fe9ec7a615e9bc306b05f/multidict-6.7.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:14525a5f61d7d0c94b368a42cff4c9a4e7ba2d52e2672a7b23d84dc86fb02b0c", size = 46507, upload-time = "2026-01-26T02:45:42.99Z" }, + { url = "https://files.pythonhosted.org/packages/e4/fc/6800d0e5b3875568b4083ecf5f310dcf91d86d52573160834fb4bfcf5e4f/multidict-6.7.1-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:17307b22c217b4cf05033dabefe68255a534d637c6c9b0cc8382718f87be4262", size = 239358, upload-time = "2026-01-26T02:45:44.376Z" }, + { url = "https://files.pythonhosted.org/packages/41/75/4ad0973179361cdf3a113905e6e088173198349131be2b390f9fa4da5fc6/multidict-6.7.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7a7e590ff876a3eaf1c02a4dfe0724b6e69a9e9de6d8f556816f29c496046e59", size = 246884, upload-time = "2026-01-26T02:45:47.167Z" }, + { url = "https://files.pythonhosted.org/packages/c3/9c/095bb28b5da139bd41fb9a5d5caff412584f377914bd8787c2aa98717130/multidict-6.7.1-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:5fa6a95dfee63893d80a34758cd0e0c118a30b8dcb46372bf75106c591b77889", size = 225878, upload-time = "2026-01-26T02:45:48.698Z" }, + { url = "https://files.pythonhosted.org/packages/07/d0/c0a72000243756e8f5a277b6b514fa005f2c73d481b7d9e47cd4568aa2e4/multidict-6.7.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a0543217a6a017692aa6ae5cc39adb75e587af0f3a82288b1492eb73dd6cc2a4", size = 253542, upload-time = "2026-01-26T02:45:50.164Z" }, + { url = "https://files.pythonhosted.org/packages/c0/6b/f69da15289e384ecf2a68837ec8b5ad8c33e973aa18b266f50fe55f24b8c/multidict-6.7.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f99fe611c312b3c1c0ace793f92464d8cd263cc3b26b5721950d977b006b6c4d", size = 252403, upload-time = "2026-01-26T02:45:51.779Z" }, + { url = "https://files.pythonhosted.org/packages/a2/76/b9669547afa5a1a25cd93eaca91c0da1c095b06b6d2d8ec25b713588d3a1/multidict-6.7.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9004d8386d133b7e6135679424c91b0b854d2d164af6ea3f289f8f2761064609", size = 244889, upload-time = "2026-01-26T02:45:53.27Z" }, + { url = "https://files.pythonhosted.org/packages/7e/a9/a50d2669e506dad33cfc45b5d574a205587b7b8a5f426f2fbb2e90882588/multidict-6.7.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e628ef0e6859ffd8273c69412a2465c4be4a9517d07261b33334b5ec6f3c7489", size = 241982, upload-time = "2026-01-26T02:45:54.919Z" }, + { url = "https://files.pythonhosted.org/packages/c5/bb/1609558ad8b456b4827d3c5a5b775c93b87878fd3117ed3db3423dfbce1b/multidict-6.7.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:841189848ba629c3552035a6a7f5bf3b02eb304e9fea7492ca220a8eda6b0e5c", size = 232415, upload-time = "2026-01-26T02:45:56.981Z" }, + { url = "https://files.pythonhosted.org/packages/d8/59/6f61039d2aa9261871e03ab9dc058a550d240f25859b05b67fd70f80d4b3/multidict-6.7.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:ce1bbd7d780bb5a0da032e095c951f7014d6b0a205f8318308140f1a6aba159e", size = 240337, upload-time = "2026-01-26T02:45:58.698Z" }, + { url = "https://files.pythonhosted.org/packages/a1/29/fdc6a43c203890dc2ae9249971ecd0c41deaedfe00d25cb6564b2edd99eb/multidict-6.7.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:b26684587228afed0d50cf804cc71062cc9c1cdf55051c4c6345d372947b268c", size = 248788, upload-time = "2026-01-26T02:46:00.862Z" }, + { url = "https://files.pythonhosted.org/packages/a9/14/a153a06101323e4cf086ecee3faadba52ff71633d471f9685c42e3736163/multidict-6.7.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:9f9af11306994335398293f9958071019e3ab95e9a707dc1383a35613f6abcb9", size = 242842, upload-time = "2026-01-26T02:46:02.824Z" }, + { url = "https://files.pythonhosted.org/packages/41/5f/604ae839e64a4a6efc80db94465348d3b328ee955e37acb24badbcd24d83/multidict-6.7.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:b4938326284c4f1224178a560987b6cf8b4d38458b113d9b8c1db1a836e640a2", size = 240237, upload-time = "2026-01-26T02:46:05.898Z" }, + { url = "https://files.pythonhosted.org/packages/5f/60/c3a5187bf66f6fb546ff4ab8fb5a077cbdd832d7b1908d4365c7f74a1917/multidict-6.7.1-cp314-cp314t-win32.whl", hash = "sha256:98655c737850c064a65e006a3df7c997cd3b220be4ec8fe26215760b9697d4d7", size = 48008, upload-time = "2026-01-26T02:46:07.468Z" }, + { url = "https://files.pythonhosted.org/packages/0c/f7/addf1087b860ac60e6f382240f64fb99f8bfb532bb06f7c542b83c29ca61/multidict-6.7.1-cp314-cp314t-win_amd64.whl", hash = "sha256:497bde6223c212ba11d462853cfa4f0ae6ef97465033e7dc9940cdb3ab5b48e5", size = 53542, upload-time = "2026-01-26T02:46:08.809Z" }, + { url = "https://files.pythonhosted.org/packages/4c/81/4629d0aa32302ef7b2ec65c75a728cc5ff4fa410c50096174c1632e70b3e/multidict-6.7.1-cp314-cp314t-win_arm64.whl", hash = "sha256:2bbd113e0d4af5db41d5ebfe9ccaff89de2120578164f86a5d17d5a576d1e5b2", size = 44719, upload-time = "2026-01-26T02:46:11.146Z" }, + { url = "https://files.pythonhosted.org/packages/81/08/7036c080d7117f28a4af526d794aab6a84463126db031b007717c1a6676e/multidict-6.7.1-py3-none-any.whl", hash = "sha256:55d97cc6dae627efa6a6e548885712d4864b81110ac76fa4e534c03819fa4a56", size = 12319, upload-time = "2026-01-26T02:46:44.004Z" }, +] + +[[package]] +name = "multiprocess" +version = "0.70.19" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "dill" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a2/f2/e783ac7f2aeeed14e9e12801f22529cc7e6b7ab80928d6dcce4e9f00922d/multiprocess-0.70.19.tar.gz", hash = "sha256:952021e0e6c55a4a9fe4cd787895b86e239a40e76802a789d6305398d3975897", size = 2079989, upload-time = "2026-01-19T06:47:39.744Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e3/45/8004d1e6b9185c1a444d6b55ac5682acf9d98035e54386d967366035a03a/multiprocess-0.70.19-py310-none-any.whl", hash = "sha256:97404393419dcb2a8385910864eedf47a3cadf82c66345b44f036420eb0b5d87", size = 134948, upload-time = "2026-01-19T06:47:32.325Z" }, + { url = "https://files.pythonhosted.org/packages/86/c2/dec9722dc3474c164a0b6bcd9a7ed7da542c98af8cabce05374abab35edd/multiprocess-0.70.19-py311-none-any.whl", hash = "sha256:928851ae7973aea4ce0eaf330bbdafb2e01398a91518d5c8818802845564f45c", size = 144457, upload-time = "2026-01-19T06:47:33.711Z" }, + { url = "https://files.pythonhosted.org/packages/71/70/38998b950a97ea279e6bd657575d22d1a2047256caf707d9a10fbce4f065/multiprocess-0.70.19-py312-none-any.whl", hash = "sha256:3a56c0e85dd5025161bac5ce138dcac1e49174c7d8e74596537e729fd5c53c28", size = 150281, upload-time = "2026-01-19T06:47:35.037Z" }, + { url = "https://files.pythonhosted.org/packages/7f/74/d2c27e03cb84251dfe7249b8e82923643c6d48fa4883b9476b025e7dc7eb/multiprocess-0.70.19-py313-none-any.whl", hash = "sha256:8d5eb4ec5017ba2fab4e34a747c6d2c2b6fecfe9e7236e77988db91580ada952", size = 156414, upload-time = "2026-01-19T06:47:35.915Z" }, + { url = "https://files.pythonhosted.org/packages/a0/61/af9115673a5870fd885247e2f1b68c4f1197737da315b520a91c757a861a/multiprocess-0.70.19-py314-none-any.whl", hash = "sha256:e8cc7fbdff15c0613f0a1f1f8744bef961b0a164c0ca29bdff53e9d2d93c5e5f", size = 160318, upload-time = "2026-01-19T06:47:37.497Z" }, + { url = "https://files.pythonhosted.org/packages/7e/82/69e539c4c2027f1e1697e09aaa2449243085a0edf81ae2c6341e84d769b6/multiprocess-0.70.19-py39-none-any.whl", hash = "sha256:0d4b4397ed669d371c81dcd1ef33fd384a44d6c3de1bd0ca7ac06d837720d3c5", size = 133477, upload-time = "2026-01-19T06:47:38.619Z" }, +] + +[[package]] +name = "numpy" +version = "2.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/9f/b8cef5bffa569759033adda9481211426f12f53299629b410340795c2514/numpy-2.4.4.tar.gz", hash = "sha256:2d390634c5182175533585cc89f3608a4682ccb173cc9bb940b2881c8d6f8fa0", size = 20731587, upload-time = "2026-03-29T13:22:01.298Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/28/05/32396bec30fb2263770ee910142f49c1476d08e8ad41abf8403806b520ce/numpy-2.4.4-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:15716cfef24d3a9762e3acdf87e27f58dc823d1348f765bbea6bef8c639bfa1b", size = 16689272, upload-time = "2026-03-29T13:18:49.223Z" }, + { url = "https://files.pythonhosted.org/packages/c5/f3/a983d28637bfcd763a9c7aafdb6d5c0ebf3d487d1e1459ffdb57e2f01117/numpy-2.4.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:23cbfd4c17357c81021f21540da84ee282b9c8fba38a03b7b9d09ba6b951421e", size = 14699573, upload-time = "2026-03-29T13:18:52.629Z" }, + { url = "https://files.pythonhosted.org/packages/9b/fd/e5ecca1e78c05106d98028114f5c00d3eddb41207686b2b7de3e477b0e22/numpy-2.4.4-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:8b3b60bb7cba2c8c81837661c488637eee696f59a877788a396d33150c35d842", size = 5204782, upload-time = "2026-03-29T13:18:55.579Z" }, + { url = "https://files.pythonhosted.org/packages/de/2f/702a4594413c1a8632092beae8aba00f1d67947389369b3777aed783fdca/numpy-2.4.4-cp312-cp312-macosx_14_0_x86_64.whl", hash = "sha256:e4a010c27ff6f210ff4c6ef34394cd61470d01014439b192ec22552ee867f2a8", size = 6552038, upload-time = "2026-03-29T13:18:57.769Z" }, + { url = "https://files.pythonhosted.org/packages/7f/37/eed308a8f56cba4d1fdf467a4fc67ef4ff4bf1c888f5fc980481890104b1/numpy-2.4.4-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f9e75681b59ddaa5e659898085ae0eaea229d054f2ac0c7e563a62205a700121", size = 15670666, upload-time = "2026-03-29T13:19:00.341Z" }, + { url = "https://files.pythonhosted.org/packages/0a/0d/0e3ecece05b7a7e87ab9fb587855548da437a061326fff64a223b6dcb78a/numpy-2.4.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:81f4a14bee47aec54f883e0cad2d73986640c1590eb9bfaaba7ad17394481e6e", size = 16645480, upload-time = "2026-03-29T13:19:03.63Z" }, + { url = "https://files.pythonhosted.org/packages/34/49/f2312c154b82a286758ee2f1743336d50651f8b5195db18cdb63675ff649/numpy-2.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:62d6b0f03b694173f9fcb1fb317f7222fd0b0b103e784c6549f5e53a27718c44", size = 17020036, upload-time = "2026-03-29T13:19:07.428Z" }, + { url = "https://files.pythonhosted.org/packages/7b/e9/736d17bd77f1b0ec4f9901aaec129c00d59f5d84d5e79bba540ef12c2330/numpy-2.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fbc356aae7adf9e6336d336b9c8111d390a05df88f1805573ebb0807bd06fd1d", size = 18368643, upload-time = "2026-03-29T13:19:10.775Z" }, + { url = "https://files.pythonhosted.org/packages/63/f6/d417977c5f519b17c8a5c3bc9e8304b0908b0e21136fe43bf628a1343914/numpy-2.4.4-cp312-cp312-win32.whl", hash = "sha256:0d35aea54ad1d420c812bfa0385c71cd7cc5bcf7c65fed95fc2cd02fe8c79827", size = 5961117, upload-time = "2026-03-29T13:19:13.464Z" }, + { url = "https://files.pythonhosted.org/packages/2d/5b/e1deebf88ff431b01b7406ca3583ab2bbb90972bbe1c568732e49c844f7e/numpy-2.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:b5f0362dc928a6ecd9db58868fca5e48485205e3855957bdedea308f8672ea4a", size = 12320584, upload-time = "2026-03-29T13:19:16.155Z" }, + { url = "https://files.pythonhosted.org/packages/58/89/e4e856ac82a68c3ed64486a544977d0e7bdd18b8da75b78a577ca31c4395/numpy-2.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:846300f379b5b12cc769334464656bc882e0735d27d9726568bc932fdc49d5ec", size = 10221450, upload-time = "2026-03-29T13:19:18.994Z" }, + { url = "https://files.pythonhosted.org/packages/14/1d/d0a583ce4fefcc3308806a749a536c201ed6b5ad6e1322e227ee4848979d/numpy-2.4.4-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:08f2e31ed5e6f04b118e49821397f12767934cfdd12a1ce86a058f91e004ee50", size = 16684933, upload-time = "2026-03-29T13:19:22.47Z" }, + { url = "https://files.pythonhosted.org/packages/c1/62/2b7a48fbb745d344742c0277f01286dead15f3f68e4f359fbfcf7b48f70f/numpy-2.4.4-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e823b8b6edc81e747526f70f71a9c0a07ac4e7ad13020aa736bb7c9d67196115", size = 14694532, upload-time = "2026-03-29T13:19:25.581Z" }, + { url = "https://files.pythonhosted.org/packages/e5/87/499737bfba066b4a3bebff24a8f1c5b2dee410b209bc6668c9be692580f0/numpy-2.4.4-cp313-cp313-macosx_14_0_arm64.whl", hash = "sha256:4a19d9dba1a76618dd86b164d608566f393f8ec6ac7c44f0cc879011c45e65af", size = 5199661, upload-time = "2026-03-29T13:19:28.31Z" }, + { url = "https://files.pythonhosted.org/packages/cd/da/464d551604320d1491bc345efed99b4b7034143a85787aab78d5691d5a0e/numpy-2.4.4-cp313-cp313-macosx_14_0_x86_64.whl", hash = "sha256:d2a8490669bfe99a233298348acc2d824d496dee0e66e31b66a6022c2ad74a5c", size = 6547539, upload-time = "2026-03-29T13:19:30.97Z" }, + { url = "https://files.pythonhosted.org/packages/7d/90/8d23e3b0dafd024bf31bdec225b3bb5c2dbfa6912f8a53b8659f21216cbf/numpy-2.4.4-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:45dbed2ab436a9e826e302fcdcbe9133f9b0006e5af7168afb8963a6520da103", size = 15668806, upload-time = "2026-03-29T13:19:33.887Z" }, + { url = "https://files.pythonhosted.org/packages/d1/73/a9d864e42a01896bb5974475438f16086be9ba1f0d19d0bb7a07427c4a8b/numpy-2.4.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c901b15172510173f5cb310eae652908340f8dede90fff9e3bf6c0d8dfd92f83", size = 16632682, upload-time = "2026-03-29T13:19:37.336Z" }, + { url = "https://files.pythonhosted.org/packages/34/fb/14570d65c3bde4e202a031210475ae9cde9b7686a2e7dc97ee67d2833b35/numpy-2.4.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:99d838547ace2c4aace6c4f76e879ddfe02bb58a80c1549928477862b7a6d6ed", size = 17019810, upload-time = "2026-03-29T13:19:40.963Z" }, + { url = "https://files.pythonhosted.org/packages/8a/77/2ba9d87081fd41f6d640c83f26fb7351e536b7ce6dd9061b6af5904e8e46/numpy-2.4.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:0aec54fd785890ecca25a6003fd9a5aed47ad607bbac5cd64f836ad8666f4959", size = 18357394, upload-time = "2026-03-29T13:19:44.859Z" }, + { url = "https://files.pythonhosted.org/packages/a2/23/52666c9a41708b0853fa3b1a12c90da38c507a3074883823126d4e9d5b30/numpy-2.4.4-cp313-cp313-win32.whl", hash = "sha256:07077278157d02f65c43b1b26a3886bce886f95d20aabd11f87932750dfb14ed", size = 5959556, upload-time = "2026-03-29T13:19:47.661Z" }, + { url = "https://files.pythonhosted.org/packages/57/fb/48649b4971cde70d817cf97a2a2fdc0b4d8308569f1dd2f2611959d2e0cf/numpy-2.4.4-cp313-cp313-win_amd64.whl", hash = "sha256:5c70f1cc1c4efbe316a572e2d8b9b9cc44e89b95f79ca3331553fbb63716e2bf", size = 12317311, upload-time = "2026-03-29T13:19:50.67Z" }, + { url = "https://files.pythonhosted.org/packages/ba/d8/11490cddd564eb4de97b4579ef6bfe6a736cc07e94c1598590ae25415e01/numpy-2.4.4-cp313-cp313-win_arm64.whl", hash = "sha256:ef4059d6e5152fa1a39f888e344c73fdc926e1b2dd58c771d67b0acfbf2aa67d", size = 10222060, upload-time = "2026-03-29T13:19:54.229Z" }, + { url = "https://files.pythonhosted.org/packages/99/5d/dab4339177a905aad3e2221c915b35202f1ec30d750dd2e5e9d9a72b804b/numpy-2.4.4-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:4bbc7f303d125971f60ec0aaad5e12c62d0d2c925f0ab1273debd0e4ba37aba5", size = 14822302, upload-time = "2026-03-29T13:19:57.585Z" }, + { url = "https://files.pythonhosted.org/packages/eb/e4/0564a65e7d3d97562ed6f9b0fd0fb0a6f559ee444092f105938b50043876/numpy-2.4.4-cp313-cp313t-macosx_14_0_arm64.whl", hash = "sha256:4d6d57903571f86180eb98f8f0c839fa9ebbfb031356d87f1361be91e433f5b7", size = 5327407, upload-time = "2026-03-29T13:20:00.601Z" }, + { url = "https://files.pythonhosted.org/packages/29/8d/35a3a6ce5ad371afa58b4700f1c820f8f279948cca32524e0a695b0ded83/numpy-2.4.4-cp313-cp313t-macosx_14_0_x86_64.whl", hash = "sha256:4636de7fd195197b7535f231b5de9e4b36d2c440b6e566d2e4e4746e6af0ca93", size = 6647631, upload-time = "2026-03-29T13:20:02.855Z" }, + { url = "https://files.pythonhosted.org/packages/f4/da/477731acbd5a58a946c736edfdabb2ac5b34c3d08d1ba1a7b437fa0884df/numpy-2.4.4-cp313-cp313t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ad2e2ef14e0b04e544ea2fa0a36463f847f113d314aa02e5b402fdf910ef309e", size = 15727691, upload-time = "2026-03-29T13:20:06.004Z" }, + { url = "https://files.pythonhosted.org/packages/e6/db/338535d9b152beabeb511579598418ba0212ce77cf9718edd70262cc4370/numpy-2.4.4-cp313-cp313t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5a285b3b96f951841799528cd1f4f01cd70e7e0204b4abebac9463eecfcf2a40", size = 16681241, upload-time = "2026-03-29T13:20:09.417Z" }, + { url = "https://files.pythonhosted.org/packages/e2/a9/ad248e8f58beb7a0219b413c9c7d8151c5d285f7f946c3e26695bdbbe2df/numpy-2.4.4-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:f8474c4241bc18b750be2abea9d7a9ec84f46ef861dbacf86a4f6e043401f79e", size = 17085767, upload-time = "2026-03-29T13:20:13.126Z" }, + { url = "https://files.pythonhosted.org/packages/b5/1a/3b88ccd3694681356f70da841630e4725a7264d6a885c8d442a697e1146b/numpy-2.4.4-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:4e874c976154687c1f71715b034739b45c7711bec81db01914770373d125e392", size = 18403169, upload-time = "2026-03-29T13:20:17.096Z" }, + { url = "https://files.pythonhosted.org/packages/c2/c9/fcfd5d0639222c6eac7f304829b04892ef51c96a75d479214d77e3ce6e33/numpy-2.4.4-cp313-cp313t-win32.whl", hash = "sha256:9c585a1790d5436a5374bac930dad6ed244c046ed91b2b2a3634eb2971d21008", size = 6083477, upload-time = "2026-03-29T13:20:20.195Z" }, + { url = "https://files.pythonhosted.org/packages/d5/e3/3938a61d1c538aaec8ed6fd6323f57b0c2d2d2219512434c5c878db76553/numpy-2.4.4-cp313-cp313t-win_amd64.whl", hash = "sha256:93e15038125dc1e5345d9b5b68aa7f996ec33b98118d18c6ca0d0b7d6198b7e8", size = 12457487, upload-time = "2026-03-29T13:20:22.946Z" }, + { url = "https://files.pythonhosted.org/packages/97/6a/7e345032cc60501721ef94e0e30b60f6b0bd601f9174ebd36389a2b86d40/numpy-2.4.4-cp313-cp313t-win_arm64.whl", hash = "sha256:0dfd3f9d3adbe2920b68b5cd3d51444e13a10792ec7154cd0a2f6e74d4ab3233", size = 10292002, upload-time = "2026-03-29T13:20:25.909Z" }, + { url = "https://files.pythonhosted.org/packages/6e/06/c54062f85f673dd5c04cbe2f14c3acb8c8b95e3384869bb8cc9bff8cb9df/numpy-2.4.4-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:f169b9a863d34f5d11b8698ead99febeaa17a13ca044961aa8e2662a6c7766a0", size = 16684353, upload-time = "2026-03-29T13:20:29.504Z" }, + { url = "https://files.pythonhosted.org/packages/4c/39/8a320264a84404c74cc7e79715de85d6130fa07a0898f67fb5cd5bd79908/numpy-2.4.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:2483e4584a1cb3092da4470b38866634bafb223cbcd551ee047633fd2584599a", size = 14704914, upload-time = "2026-03-29T13:20:33.547Z" }, + { url = "https://files.pythonhosted.org/packages/91/fb/287076b2614e1d1044235f50f03748f31fa287e3dbe6abeb35cdfa351eca/numpy-2.4.4-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:2d19e6e2095506d1736b7d80595e0f252d76b89f5e715c35e06e937679ea7d7a", size = 5210005, upload-time = "2026-03-29T13:20:36.45Z" }, + { url = "https://files.pythonhosted.org/packages/63/eb/fcc338595309910de6ecabfcef2419a9ce24399680bfb149421fa2df1280/numpy-2.4.4-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:6a246d5914aa1c820c9443ddcee9c02bec3e203b0c080349533fae17727dfd1b", size = 6544974, upload-time = "2026-03-29T13:20:39.014Z" }, + { url = "https://files.pythonhosted.org/packages/44/5d/e7e9044032a716cdfaa3fba27a8e874bf1c5f1912a1ddd4ed071bf8a14a6/numpy-2.4.4-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:989824e9faf85f96ec9c7761cd8d29c531ad857bfa1daa930cba85baaecf1a9a", size = 15684591, upload-time = "2026-03-29T13:20:42.146Z" }, + { url = "https://files.pythonhosted.org/packages/98/7c/21252050676612625449b4807d6b695b9ce8a7c9e1c197ee6216c8a65c7c/numpy-2.4.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:27a8d92cd10f1382a67d7cf4db7ce18341b66438bdd9f691d7b0e48d104c2a9d", size = 16637700, upload-time = "2026-03-29T13:20:46.204Z" }, + { url = "https://files.pythonhosted.org/packages/b1/29/56d2bbef9465db24ef25393383d761a1af4f446a1df9b8cded4fe3a5a5d7/numpy-2.4.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e44319a2953c738205bf3354537979eaa3998ed673395b964c1176083dd46252", size = 17035781, upload-time = "2026-03-29T13:20:50.242Z" }, + { url = "https://files.pythonhosted.org/packages/e3/2b/a35a6d7589d21f44cea7d0a98de5ddcbb3d421b2622a5c96b1edf18707c3/numpy-2.4.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e892aff75639bbef0d2a2cfd55535510df26ff92f63c92cd84ef8d4ba5a5557f", size = 18362959, upload-time = "2026-03-29T13:20:54.019Z" }, + { url = "https://files.pythonhosted.org/packages/64/c9/d52ec581f2390e0f5f85cbfd80fb83d965fc15e9f0e1aec2195faa142cde/numpy-2.4.4-cp314-cp314-win32.whl", hash = "sha256:1378871da56ca8943c2ba674530924bb8ca40cd228358a3b5f302ad60cf875fc", size = 6008768, upload-time = "2026-03-29T13:20:56.912Z" }, + { url = "https://files.pythonhosted.org/packages/fa/22/4cc31a62a6c7b74a8730e31a4274c5dc80e005751e277a2ce38e675e4923/numpy-2.4.4-cp314-cp314-win_amd64.whl", hash = "sha256:715d1c092715954784bc79e1174fc2a90093dc4dc84ea15eb14dad8abdcdeb74", size = 12449181, upload-time = "2026-03-29T13:20:59.548Z" }, + { url = "https://files.pythonhosted.org/packages/70/2e/14cda6f4d8e396c612d1bf97f22958e92148801d7e4f110cabebdc0eef4b/numpy-2.4.4-cp314-cp314-win_arm64.whl", hash = "sha256:2c194dd721e54ecad9ad387c1d35e63dce5c4450c6dc7dd5611283dda239aabb", size = 10496035, upload-time = "2026-03-29T13:21:02.524Z" }, + { url = "https://files.pythonhosted.org/packages/b1/e8/8fed8c8d848d7ecea092dc3469643f9d10bc3a134a815a3b033da1d2039b/numpy-2.4.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2aa0613a5177c264ff5921051a5719d20095ea586ca88cc802c5c218d1c67d3e", size = 14824958, upload-time = "2026-03-29T13:21:05.671Z" }, + { url = "https://files.pythonhosted.org/packages/05/1a/d8007a5138c179c2bf33ef44503e83d70434d2642877ee8fbb230e7c0548/numpy-2.4.4-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:42c16925aa5a02362f986765f9ebabf20de75cdefdca827d14315c568dcab113", size = 5330020, upload-time = "2026-03-29T13:21:08.635Z" }, + { url = "https://files.pythonhosted.org/packages/99/64/ffb99ac6ae93faf117bcbd5c7ba48a7f45364a33e8e458545d3633615dda/numpy-2.4.4-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:874f200b2a981c647340f841730fc3a2b54c9d940566a3c4149099591e2c4c3d", size = 6650758, upload-time = "2026-03-29T13:21:10.949Z" }, + { url = "https://files.pythonhosted.org/packages/6e/6e/795cc078b78a384052e73b2f6281ff7a700e9bf53bcce2ee579d4f6dd879/numpy-2.4.4-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c9b39d38a9bd2ae1becd7eac1303d031c5c110ad31f2b319c6e7d98b135c934d", size = 15729948, upload-time = "2026-03-29T13:21:14.047Z" }, + { url = "https://files.pythonhosted.org/packages/5f/86/2acbda8cc2af5f3d7bfc791192863b9e3e19674da7b5e533fded124d1299/numpy-2.4.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b268594bccac7d7cf5844c7732e3f20c50921d94e36d7ec9b79e9857694b1b2f", size = 16679325, upload-time = "2026-03-29T13:21:17.561Z" }, + { url = "https://files.pythonhosted.org/packages/bc/59/cafd83018f4aa55e0ac6fa92aa066c0a1877b77a615ceff1711c260ffae8/numpy-2.4.4-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:ac6b31e35612a26483e20750126d30d0941f949426974cace8e6b5c58a3657b0", size = 17084883, upload-time = "2026-03-29T13:21:21.106Z" }, + { url = "https://files.pythonhosted.org/packages/f0/85/a42548db84e65ece46ab2caea3d3f78b416a47af387fcbb47ec28e660dc2/numpy-2.4.4-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:8e3ed142f2728df44263aaf5fb1f5b0b99f4070c553a0d7f033be65338329150", size = 18403474, upload-time = "2026-03-29T13:21:24.828Z" }, + { url = "https://files.pythonhosted.org/packages/ed/ad/483d9e262f4b831000062e5d8a45e342166ec8aaa1195264982bca267e62/numpy-2.4.4-cp314-cp314t-win32.whl", hash = "sha256:dddbbd259598d7240b18c9d87c56a9d2fb3b02fe266f49a7c101532e78c1d871", size = 6155500, upload-time = "2026-03-29T13:21:28.205Z" }, + { url = "https://files.pythonhosted.org/packages/c7/03/2fc4e14c7bd4ff2964b74ba90ecb8552540b6315f201df70f137faa5c589/numpy-2.4.4-cp314-cp314t-win_amd64.whl", hash = "sha256:a7164afb23be6e37ad90b2f10426149fd75aee07ca55653d2aa41e66c4ef697e", size = 12637755, upload-time = "2026-03-29T13:21:31.107Z" }, + { url = "https://files.pythonhosted.org/packages/58/78/548fb8e07b1a341746bfbecb32f2c268470f45fa028aacdbd10d9bc73aab/numpy-2.4.4-cp314-cp314t-win_arm64.whl", hash = "sha256:ba203255017337d39f89bdd58417f03c4426f12beed0440cfd933cb15f8669c7", size = 10566643, upload-time = "2026-03-29T13:21:34.339Z" }, +] + +[[package]] +name = "osu-everything" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "datasets" }, + { name = "hf-transfer" }, + { name = "huggingface-hub" }, + { name = "pyarrow" }, + { name = "tqdm" }, + { name = "zstandard" }, +] + +[package.metadata] +requires-dist = [ + { name = "datasets", specifier = ">=2.18" }, + { name = "hf-transfer", specifier = ">=0.1.9" }, + { name = "huggingface-hub", specifier = ">=0.20" }, + { name = "pyarrow", specifier = ">=15" }, + { name = "tqdm", specifier = ">=4.66" }, + { name = "zstandard", specifier = ">=0.22" }, +] +provides-extras = ["probe"] + +[[package]] +name = "packaging" +version = "26.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/f1/e7a6dd94a8d4a5626c03e4e99c87f241ba9e350cd9e6d75123f992427270/packaging-26.2.tar.gz", hash = "sha256:ff452ff5a3e828ce110190feff1178bb1f2ea2281fa2075aadb987c2fb221661", size = 228134, upload-time = "2026-04-24T20:15:23.917Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/df/b2/87e62e8c3e2f4b32e5fe99e0b86d576da1312593b39f47d8ceef365e95ed/packaging-26.2-py3-none-any.whl", hash = "sha256:5fc45236b9446107ff2415ce77c807cee2862cb6fac22b8a73826d0693b0980e", size = 100195, upload-time = "2026-04-24T20:15:22.081Z" }, +] + +[[package]] +name = "pandas" +version = "3.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, + { name = "python-dateutil" }, + { name = "tzdata", marker = "sys_platform == 'emscripten' or sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/da/99/b342345300f13440fe9fe385c3c481e2d9a595ee3bab4d3219247ac94e9a/pandas-3.0.2.tar.gz", hash = "sha256:f4753e73e34c8d83221ba58f232433fca2748be8b18dbca02d242ed153945043", size = 4645855, upload-time = "2026-03-31T06:48:30.816Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f3/b0/c20bd4d6d3f736e6bd6b55794e9cd0a617b858eaad27c8f410ea05d953b7/pandas-3.0.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:232a70ebb568c0c4d2db4584f338c1577d81e3af63292208d615907b698a0f18", size = 10347921, upload-time = "2026-03-31T06:46:33.36Z" }, + { url = "https://files.pythonhosted.org/packages/35/d0/4831af68ce30cc2d03c697bea8450e3225a835ef497d0d70f31b8cdde965/pandas-3.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:970762605cff1ca0d3f71ed4f3a769ea8f85fc8e6348f6e110b8fea7e6eb5a14", size = 9888127, upload-time = "2026-03-31T06:46:36.253Z" }, + { url = "https://files.pythonhosted.org/packages/61/a9/16ea9346e1fc4a96e2896242d9bc674764fb9049b0044c0132502f7a771e/pandas-3.0.2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:aff4e6f4d722e0652707d7bcb190c445fe58428500c6d16005b02401764b1b3d", size = 10399577, upload-time = "2026-03-31T06:46:39.224Z" }, + { url = "https://files.pythonhosted.org/packages/c4/a8/3a61a721472959ab0ce865ef05d10b0d6bfe27ce8801c99f33d4fa996e65/pandas-3.0.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ef8b27695c3d3dc78403c9a7d5e59a62d5464a7e1123b4e0042763f7104dc74f", size = 10880030, upload-time = "2026-03-31T06:46:42.412Z" }, + { url = "https://files.pythonhosted.org/packages/da/65/7225c0ea4d6ce9cb2160a7fb7f39804871049f016e74782e5dade4d14109/pandas-3.0.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f8d68083e49e16b84734eb1a4dcae4259a75c90fb6e2251ab9a00b61120c06ab", size = 11409468, upload-time = "2026-03-31T06:46:45.2Z" }, + { url = "https://files.pythonhosted.org/packages/fa/5b/46e7c76032639f2132359b5cf4c785dd8cf9aea5ea64699eac752f02b9db/pandas-3.0.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:32cc41f310ebd4a296d93515fcac312216adfedb1894e879303987b8f1e2b97d", size = 11936381, upload-time = "2026-03-31T06:46:48.293Z" }, + { url = "https://files.pythonhosted.org/packages/7b/8b/721a9cff6fa6a91b162eb51019c6243b82b3226c71bb6c8ef4a9bd65cbc6/pandas-3.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:a4785e1d6547d8427c5208b748ae2efb64659a21bd82bf440d4262d02bfa02a4", size = 9744993, upload-time = "2026-03-31T06:46:51.488Z" }, + { url = "https://files.pythonhosted.org/packages/d5/18/7f0bd34ae27b28159aa80f2a6799f47fda34f7fb938a76e20c7b7fe3b200/pandas-3.0.2-cp312-cp312-win_arm64.whl", hash = "sha256:08504503f7101300107ecdc8df73658e4347586db5cfdadabc1592e9d7e7a0fd", size = 9056118, upload-time = "2026-03-31T06:46:54.548Z" }, + { url = "https://files.pythonhosted.org/packages/bf/ca/3e639a1ea6fcd0617ca4e8ca45f62a74de33a56ae6cd552735470b22c8d3/pandas-3.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:b5918ba197c951dec132b0c5929a00c0bf05d5942f590d3c10a807f6e15a57d3", size = 10321105, upload-time = "2026-03-31T06:46:57.327Z" }, + { url = "https://files.pythonhosted.org/packages/0b/77/dbc82ff2fb0e63c6564356682bf201edff0ba16c98630d21a1fb312a8182/pandas-3.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:d606a041c89c0a474a4702d532ab7e73a14fe35c8d427b972a625c8e46373668", size = 9864088, upload-time = "2026-03-31T06:46:59.935Z" }, + { url = "https://files.pythonhosted.org/packages/5c/2b/341f1b04bbca2e17e13cd3f08c215b70ef2c60c5356ef1e8c6857449edc7/pandas-3.0.2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:710246ba0616e86891b58ab95f2495143bb2bc83ab6b06747c74216f583a6ac9", size = 10369066, upload-time = "2026-03-31T06:47:02.792Z" }, + { url = "https://files.pythonhosted.org/packages/12/c5/cbb1ffefb20a93d3f0e1fdcda699fb84976210d411b008f97f48bf6ce27e/pandas-3.0.2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5d3cfe227c725b1f3dff4278b43d8c784656a42a9325b63af6b1492a8232209e", size = 10876780, upload-time = "2026-03-31T06:47:06.205Z" }, + { url = "https://files.pythonhosted.org/packages/98/fe/2249ae5e0a69bd0ddf17353d0a5d26611d70970111f5b3600cdc8be883e7/pandas-3.0.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:c3b723df9087a9a9a840e263ebd9f88b64a12075d1bf2ea401a5a42f254f084d", size = 11375181, upload-time = "2026-03-31T06:47:09.383Z" }, + { url = "https://files.pythonhosted.org/packages/de/64/77a38b09e70b6464883b8d7584ab543e748e42c1b5d337a2ee088e0df741/pandas-3.0.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:a3096110bf9eac0070b7208465f2740e2d8a670d5cb6530b5bb884eca495fd39", size = 11928899, upload-time = "2026-03-31T06:47:12.686Z" }, + { url = "https://files.pythonhosted.org/packages/5e/52/42855bf626868413f761addd574acc6195880ae247a5346477a4361c3acb/pandas-3.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:07a10f5c36512eead51bc578eb3354ad17578b22c013d89a796ab5eee90cd991", size = 9746574, upload-time = "2026-03-31T06:47:15.64Z" }, + { url = "https://files.pythonhosted.org/packages/88/39/21304ae06a25e8bf9fc820d69b29b2c495b2ae580d1e143146c309941760/pandas-3.0.2-cp313-cp313-win_arm64.whl", hash = "sha256:5fdbfa05931071aba28b408e59226186b01eb5e92bea2ab78b65863ca3228d84", size = 9047156, upload-time = "2026-03-31T06:47:18.595Z" }, + { url = "https://files.pythonhosted.org/packages/72/20/7defa8b27d4f330a903bb68eea33be07d839c5ea6bdda54174efcec0e1d2/pandas-3.0.2-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:dbc20dea3b9e27d0e66d74c42b2d0c1bed9c2ffe92adea33633e3bedeb5ac235", size = 10756238, upload-time = "2026-03-31T06:47:22.012Z" }, + { url = "https://files.pythonhosted.org/packages/e9/95/49433c14862c636afc0e9b2db83ff16b3ad92959364e52b2955e44c8e94c/pandas-3.0.2-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:b75c347eff42497452116ce05ef461822d97ce5b9ff8df6edacb8076092c855d", size = 10408520, upload-time = "2026-03-31T06:47:25.197Z" }, + { url = "https://files.pythonhosted.org/packages/3b/f8/462ad2b5881d6b8ec8e5f7ed2ea1893faa02290d13870a1600fe72ad8efc/pandas-3.0.2-cp313-cp313t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d1478075142e83a5571782ad007fb201ed074bdeac7ebcc8890c71442e96adf7", size = 10324154, upload-time = "2026-03-31T06:47:28.097Z" }, + { url = "https://files.pythonhosted.org/packages/0a/65/d1e69b649cbcddda23ad6e4c40ef935340f6f652a006e5cbc3555ac8adb3/pandas-3.0.2-cp313-cp313t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5880314e69e763d4c8b27937090de570f1fb8d027059a7ada3f7f8e98bdcb677", size = 10714449, upload-time = "2026-03-31T06:47:30.85Z" }, + { url = "https://files.pythonhosted.org/packages/47/a4/85b59bc65b8190ea3689882db6cdf32a5003c0ccd5a586c30fdcc3ffc4fc/pandas-3.0.2-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:b5329e26898896f06035241a626d7c335daa479b9bbc82be7c2742d048e41172", size = 11338475, upload-time = "2026-03-31T06:47:34.026Z" }, + { url = "https://files.pythonhosted.org/packages/1e/c4/bc6966c6e38e5d9478b935272d124d80a589511ed1612a5d21d36f664c68/pandas-3.0.2-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:81526c4afd31971f8b62671442a4b2b51e0aa9acc3819c9f0f12a28b6fcf85f1", size = 11786568, upload-time = "2026-03-31T06:47:36.941Z" }, + { url = "https://files.pythonhosted.org/packages/e8/74/09298ca9740beed1d3504e073d67e128aa07e5ca5ca2824b0c674c0b8676/pandas-3.0.2-cp313-cp313t-win_amd64.whl", hash = "sha256:7cadd7e9a44ec13b621aec60f9150e744cfc7a3dd32924a7e2f45edff31823b0", size = 10488652, upload-time = "2026-03-31T06:47:40.612Z" }, + { url = "https://files.pythonhosted.org/packages/bb/40/c6ea527147c73b24fc15c891c3fcffe9c019793119c5742b8784a062c7db/pandas-3.0.2-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:db0dbfd2a6cdf3770aa60464d50333d8f3d9165b2f2671bcc299b72de5a6677b", size = 10326084, upload-time = "2026-03-31T06:47:43.834Z" }, + { url = "https://files.pythonhosted.org/packages/95/25/bdb9326c3b5455f8d4d3549fce7abcf967259de146fe2cf7a82368141948/pandas-3.0.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:0555c5882688a39317179ab4a0ed41d3ebc8812ab14c69364bbee8fb7a3f6288", size = 9914146, upload-time = "2026-03-31T06:47:46.67Z" }, + { url = "https://files.pythonhosted.org/packages/8d/77/3a227ff3337aa376c60d288e1d61c5d097131d0ac71f954d90a8f369e422/pandas-3.0.2-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:01f31a546acd5574ef77fe199bc90b55527c225c20ccda6601cf6b0fd5ed597c", size = 10444081, upload-time = "2026-03-31T06:47:49.681Z" }, + { url = "https://files.pythonhosted.org/packages/15/88/3cdd54fa279341afa10acf8d2b503556b1375245dccc9315659f795dd2e9/pandas-3.0.2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:deeca1b5a931fdf0c2212c8a659ade6d3b1edc21f0914ce71ef24456ca7a6535", size = 10897535, upload-time = "2026-03-31T06:47:53.033Z" }, + { url = "https://files.pythonhosted.org/packages/06/9d/98cc7a7624f7932e40f434299260e2917b090a579d75937cb8a57b9d2de3/pandas-3.0.2-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:0f48afd9bb13300ffb5a3316973324c787054ba6665cda0da3fbd67f451995db", size = 11446992, upload-time = "2026-03-31T06:47:56.193Z" }, + { url = "https://files.pythonhosted.org/packages/9a/cd/19ff605cc3760e80602e6826ddef2824d8e7050ed80f2e11c4b079741dc3/pandas-3.0.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:6c4d8458b97a35717b62469a4ea0e85abd5ed8687277f5ccfc67f8a5126f8c53", size = 11968257, upload-time = "2026-03-31T06:47:59.137Z" }, + { url = "https://files.pythonhosted.org/packages/db/60/aba6a38de456e7341285102bede27514795c1eaa353bc0e7638b6b785356/pandas-3.0.2-cp314-cp314-win_amd64.whl", hash = "sha256:b35d14bb5d8285d9494fe93815a9e9307c0876e10f1e8e89ac5b88f728ec8dcf", size = 9865893, upload-time = "2026-03-31T06:48:02.038Z" }, + { url = "https://files.pythonhosted.org/packages/08/71/e5ec979dd2e8a093dacb8864598c0ff59a0cee0bbcdc0bfec16a51684d4f/pandas-3.0.2-cp314-cp314-win_arm64.whl", hash = "sha256:63d141b56ef686f7f0d714cfb8de4e320475b86bf4b620aa0b7da89af8cbdbbb", size = 9188644, upload-time = "2026-03-31T06:48:05.045Z" }, + { url = "https://files.pythonhosted.org/packages/f1/6c/7b45d85db19cae1eb524f2418ceaa9d85965dcf7b764ed151386b7c540f0/pandas-3.0.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:140f0cffb1fa2524e874dde5b477d9defe10780d8e9e220d259b2c0874c89d9d", size = 10776246, upload-time = "2026-03-31T06:48:07.789Z" }, + { url = "https://files.pythonhosted.org/packages/a8/3e/7b00648b086c106e81766f25322b48aa8dfa95b55e621dbdf2fdd413a117/pandas-3.0.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ae37e833ff4fed0ba352f6bdd8b73ba3ab3256a85e54edfd1ab51ae40cca0af8", size = 10424801, upload-time = "2026-03-31T06:48:10.897Z" }, + { url = "https://files.pythonhosted.org/packages/da/6e/558dd09a71b53b4008e7fc8a98ec6d447e9bfb63cdaeea10e5eb9b2dabe8/pandas-3.0.2-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4d888a5c678a419a5bb41a2a93818e8ed9fd3172246555c0b37b7cc27027effd", size = 10345643, upload-time = "2026-03-31T06:48:13.7Z" }, + { url = "https://files.pythonhosted.org/packages/be/e3/921c93b4d9a280409451dc8d07b062b503bbec0531d2627e73a756e99a82/pandas-3.0.2-cp314-cp314t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b444dc64c079e84df91baa8bf613d58405645461cabca929d9178f2cd392398d", size = 10743641, upload-time = "2026-03-31T06:48:16.659Z" }, + { url = "https://files.pythonhosted.org/packages/56/ca/fd17286f24fa3b4d067965d8d5d7e14fe557dd4f979a0b068ac0deaf8228/pandas-3.0.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:4544c7a54920de8eeacaa1466a6b7268ecfbc9bc64ab4dbb89c6bbe94d5e0660", size = 11361993, upload-time = "2026-03-31T06:48:19.475Z" }, + { url = "https://files.pythonhosted.org/packages/e4/a5/2f6ed612056819de445a433ca1f2821ac3dab7f150d569a59e9cc105de1d/pandas-3.0.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:734be7551687c00fbd760dc0522ed974f82ad230d4a10f54bf51b80d44a08702", size = 11815274, upload-time = "2026-03-31T06:48:22.695Z" }, + { url = "https://files.pythonhosted.org/packages/00/2f/b622683e99ec3ce00b0854bac9e80868592c5b051733f2cf3a868e5fea26/pandas-3.0.2-cp314-cp314t-win_amd64.whl", hash = "sha256:57a07209bebcbcf768d2d13c9b78b852f9a15978dac41b9e6421a81ad4cdd276", size = 10888530, upload-time = "2026-03-31T06:48:25.806Z" }, + { url = "https://files.pythonhosted.org/packages/cb/2b/f8434233fab2bd66a02ec014febe4e5adced20e2693e0e90a07d118ed30e/pandas-3.0.2-cp314-cp314t-win_arm64.whl", hash = "sha256:5371b72c2d4d415d08765f32d689217a43227484e81b2305b52076e328f6f482", size = 9455341, upload-time = "2026-03-31T06:48:28.418Z" }, +] + +[[package]] +name = "propcache" +version = "0.4.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9e/da/e9fc233cf63743258bff22b3dfa7ea5baef7b5bc324af47a0ad89b8ffc6f/propcache-0.4.1.tar.gz", hash = "sha256:f48107a8c637e80362555f37ecf49abe20370e557cc4ab374f04ec4423c97c3d", size = 46442, upload-time = "2025-10-08T19:49:02.291Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a2/0f/f17b1b2b221d5ca28b4b876e8bb046ac40466513960646bda8e1853cdfa2/propcache-0.4.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:e153e9cd40cc8945138822807139367f256f89c6810c2634a4f6902b52d3b4e2", size = 80061, upload-time = "2025-10-08T19:46:46.075Z" }, + { url = "https://files.pythonhosted.org/packages/76/47/8ccf75935f51448ba9a16a71b783eb7ef6b9ee60f5d14c7f8a8a79fbeed7/propcache-0.4.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cd547953428f7abb73c5ad82cbb32109566204260d98e41e5dfdc682eb7f8403", size = 46037, upload-time = "2025-10-08T19:46:47.23Z" }, + { url = "https://files.pythonhosted.org/packages/0a/b6/5c9a0e42df4d00bfb4a3cbbe5cf9f54260300c88a0e9af1f47ca5ce17ac0/propcache-0.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f048da1b4f243fc44f205dfd320933a951b8d89e0afd4c7cacc762a8b9165207", size = 47324, upload-time = "2025-10-08T19:46:48.384Z" }, + { url = "https://files.pythonhosted.org/packages/9e/d3/6c7ee328b39a81ee877c962469f1e795f9db87f925251efeb0545e0020d0/propcache-0.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ec17c65562a827bba85e3872ead335f95405ea1674860d96483a02f5c698fa72", size = 225505, upload-time = "2025-10-08T19:46:50.055Z" }, + { url = "https://files.pythonhosted.org/packages/01/5d/1c53f4563490b1d06a684742cc6076ef944bc6457df6051b7d1a877c057b/propcache-0.4.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:405aac25c6394ef275dee4c709be43745d36674b223ba4eb7144bf4d691b7367", size = 230242, upload-time = "2025-10-08T19:46:51.815Z" }, + { url = "https://files.pythonhosted.org/packages/20/e1/ce4620633b0e2422207c3cb774a0ee61cac13abc6217763a7b9e2e3f4a12/propcache-0.4.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:0013cb6f8dde4b2a2f66903b8ba740bdfe378c943c4377a200551ceb27f379e4", size = 238474, upload-time = "2025-10-08T19:46:53.208Z" }, + { url = "https://files.pythonhosted.org/packages/46/4b/3aae6835b8e5f44ea6a68348ad90f78134047b503765087be2f9912140ea/propcache-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:15932ab57837c3368b024473a525e25d316d8353016e7cc0e5ba9eb343fbb1cf", size = 221575, upload-time = "2025-10-08T19:46:54.511Z" }, + { url = "https://files.pythonhosted.org/packages/6e/a5/8a5e8678bcc9d3a1a15b9a29165640d64762d424a16af543f00629c87338/propcache-0.4.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:031dce78b9dc099f4c29785d9cf5577a3faf9ebf74ecbd3c856a7b92768c3df3", size = 216736, upload-time = "2025-10-08T19:46:56.212Z" }, + { url = "https://files.pythonhosted.org/packages/f1/63/b7b215eddeac83ca1c6b934f89d09a625aa9ee4ba158338854c87210cc36/propcache-0.4.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:ab08df6c9a035bee56e31af99be621526bd237bea9f32def431c656b29e41778", size = 213019, upload-time = "2025-10-08T19:46:57.595Z" }, + { url = "https://files.pythonhosted.org/packages/57/74/f580099a58c8af587cac7ba19ee7cb418506342fbbe2d4a4401661cca886/propcache-0.4.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:4d7af63f9f93fe593afbf104c21b3b15868efb2c21d07d8732c0c4287e66b6a6", size = 220376, upload-time = "2025-10-08T19:46:59.067Z" }, + { url = "https://files.pythonhosted.org/packages/c4/ee/542f1313aff7eaf19c2bb758c5d0560d2683dac001a1c96d0774af799843/propcache-0.4.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:cfc27c945f422e8b5071b6e93169679e4eb5bf73bbcbf1ba3ae3a83d2f78ebd9", size = 226988, upload-time = "2025-10-08T19:47:00.544Z" }, + { url = "https://files.pythonhosted.org/packages/8f/18/9c6b015dd9c6930f6ce2229e1f02fb35298b847f2087ea2b436a5bfa7287/propcache-0.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:35c3277624a080cc6ec6f847cbbbb5b49affa3598c4535a0a4682a697aaa5c75", size = 215615, upload-time = "2025-10-08T19:47:01.968Z" }, + { url = "https://files.pythonhosted.org/packages/80/9e/e7b85720b98c45a45e1fca6a177024934dc9bc5f4d5dd04207f216fc33ed/propcache-0.4.1-cp312-cp312-win32.whl", hash = "sha256:671538c2262dadb5ba6395e26c1731e1d52534bfe9ae56d0b5573ce539266aa8", size = 38066, upload-time = "2025-10-08T19:47:03.503Z" }, + { url = "https://files.pythonhosted.org/packages/54/09/d19cff2a5aaac632ec8fc03737b223597b1e347416934c1b3a7df079784c/propcache-0.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:cb2d222e72399fcf5890d1d5cc1060857b9b236adff2792ff48ca2dfd46c81db", size = 41655, upload-time = "2025-10-08T19:47:04.973Z" }, + { url = "https://files.pythonhosted.org/packages/68/ab/6b5c191bb5de08036a8c697b265d4ca76148efb10fa162f14af14fb5f076/propcache-0.4.1-cp312-cp312-win_arm64.whl", hash = "sha256:204483131fb222bdaaeeea9f9e6c6ed0cac32731f75dfc1d4a567fc1926477c1", size = 37789, upload-time = "2025-10-08T19:47:06.077Z" }, + { url = "https://files.pythonhosted.org/packages/bf/df/6d9c1b6ac12b003837dde8a10231a7344512186e87b36e855bef32241942/propcache-0.4.1-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:43eedf29202c08550aac1d14e0ee619b0430aaef78f85864c1a892294fbc28cf", size = 77750, upload-time = "2025-10-08T19:47:07.648Z" }, + { url = "https://files.pythonhosted.org/packages/8b/e8/677a0025e8a2acf07d3418a2e7ba529c9c33caf09d3c1f25513023c1db56/propcache-0.4.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:d62cdfcfd89ccb8de04e0eda998535c406bf5e060ffd56be6c586cbcc05b3311", size = 44780, upload-time = "2025-10-08T19:47:08.851Z" }, + { url = "https://files.pythonhosted.org/packages/89/a4/92380f7ca60f99ebae761936bc48a72a639e8a47b29050615eef757cb2a7/propcache-0.4.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cae65ad55793da34db5f54e4029b89d3b9b9490d8abe1b4c7ab5d4b8ec7ebf74", size = 46308, upload-time = "2025-10-08T19:47:09.982Z" }, + { url = "https://files.pythonhosted.org/packages/2d/48/c5ac64dee5262044348d1d78a5f85dd1a57464a60d30daee946699963eb3/propcache-0.4.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:333ddb9031d2704a301ee3e506dc46b1fe5f294ec198ed6435ad5b6a085facfe", size = 208182, upload-time = "2025-10-08T19:47:11.319Z" }, + { url = "https://files.pythonhosted.org/packages/c6/0c/cd762dd011a9287389a6a3eb43aa30207bde253610cca06824aeabfe9653/propcache-0.4.1-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:fd0858c20f078a32cf55f7e81473d96dcf3b93fd2ccdb3d40fdf54b8573df3af", size = 211215, upload-time = "2025-10-08T19:47:13.146Z" }, + { url = "https://files.pythonhosted.org/packages/30/3e/49861e90233ba36890ae0ca4c660e95df565b2cd15d4a68556ab5865974e/propcache-0.4.1-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:678ae89ebc632c5c204c794f8dab2837c5f159aeb59e6ed0539500400577298c", size = 218112, upload-time = "2025-10-08T19:47:14.913Z" }, + { url = "https://files.pythonhosted.org/packages/f1/8b/544bc867e24e1bd48f3118cecd3b05c694e160a168478fa28770f22fd094/propcache-0.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d472aeb4fbf9865e0c6d622d7f4d54a4e101a89715d8904282bb5f9a2f476c3f", size = 204442, upload-time = "2025-10-08T19:47:16.277Z" }, + { url = "https://files.pythonhosted.org/packages/50/a6/4282772fd016a76d3e5c0df58380a5ea64900afd836cec2c2f662d1b9bb3/propcache-0.4.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:4d3df5fa7e36b3225954fba85589da77a0fe6a53e3976de39caf04a0db4c36f1", size = 199398, upload-time = "2025-10-08T19:47:17.962Z" }, + { url = "https://files.pythonhosted.org/packages/3e/ec/d8a7cd406ee1ddb705db2139f8a10a8a427100347bd698e7014351c7af09/propcache-0.4.1-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:ee17f18d2498f2673e432faaa71698032b0127ebf23ae5974eeaf806c279df24", size = 196920, upload-time = "2025-10-08T19:47:19.355Z" }, + { url = "https://files.pythonhosted.org/packages/f6/6c/f38ab64af3764f431e359f8baf9e0a21013e24329e8b85d2da32e8ed07ca/propcache-0.4.1-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:580e97762b950f993ae618e167e7be9256b8353c2dcd8b99ec100eb50f5286aa", size = 203748, upload-time = "2025-10-08T19:47:21.338Z" }, + { url = "https://files.pythonhosted.org/packages/d6/e3/fa846bd70f6534d647886621388f0a265254d30e3ce47e5c8e6e27dbf153/propcache-0.4.1-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:501d20b891688eb8e7aa903021f0b72d5a55db40ffaab27edefd1027caaafa61", size = 205877, upload-time = "2025-10-08T19:47:23.059Z" }, + { url = "https://files.pythonhosted.org/packages/e2/39/8163fc6f3133fea7b5f2827e8eba2029a0277ab2c5beee6c1db7b10fc23d/propcache-0.4.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:9a0bd56e5b100aef69bd8562b74b46254e7c8812918d3baa700c8a8009b0af66", size = 199437, upload-time = "2025-10-08T19:47:24.445Z" }, + { url = "https://files.pythonhosted.org/packages/93/89/caa9089970ca49c7c01662bd0eeedfe85494e863e8043565aeb6472ce8fe/propcache-0.4.1-cp313-cp313-win32.whl", hash = "sha256:bcc9aaa5d80322bc2fb24bb7accb4a30f81e90ab8d6ba187aec0744bc302ad81", size = 37586, upload-time = "2025-10-08T19:47:25.736Z" }, + { url = "https://files.pythonhosted.org/packages/f5/ab/f76ec3c3627c883215b5c8080debb4394ef5a7a29be811f786415fc1e6fd/propcache-0.4.1-cp313-cp313-win_amd64.whl", hash = "sha256:381914df18634f5494334d201e98245c0596067504b9372d8cf93f4bb23e025e", size = 40790, upload-time = "2025-10-08T19:47:26.847Z" }, + { url = "https://files.pythonhosted.org/packages/59/1b/e71ae98235f8e2ba5004d8cb19765a74877abf189bc53fc0c80d799e56c3/propcache-0.4.1-cp313-cp313-win_arm64.whl", hash = "sha256:8873eb4460fd55333ea49b7d189749ecf6e55bf85080f11b1c4530ed3034cba1", size = 37158, upload-time = "2025-10-08T19:47:27.961Z" }, + { url = "https://files.pythonhosted.org/packages/83/ce/a31bbdfc24ee0dcbba458c8175ed26089cf109a55bbe7b7640ed2470cfe9/propcache-0.4.1-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:92d1935ee1f8d7442da9c0c4fa7ac20d07e94064184811b685f5c4fada64553b", size = 81451, upload-time = "2025-10-08T19:47:29.445Z" }, + { url = "https://files.pythonhosted.org/packages/25/9c/442a45a470a68456e710d96cacd3573ef26a1d0a60067e6a7d5e655621ed/propcache-0.4.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:473c61b39e1460d386479b9b2f337da492042447c9b685f28be4f74d3529e566", size = 46374, upload-time = "2025-10-08T19:47:30.579Z" }, + { url = "https://files.pythonhosted.org/packages/f4/bf/b1d5e21dbc3b2e889ea4327044fb16312a736d97640fb8b6aa3f9c7b3b65/propcache-0.4.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:c0ef0aaafc66fbd87842a3fe3902fd889825646bc21149eafe47be6072725835", size = 48396, upload-time = "2025-10-08T19:47:31.79Z" }, + { url = "https://files.pythonhosted.org/packages/f4/04/5b4c54a103d480e978d3c8a76073502b18db0c4bc17ab91b3cb5092ad949/propcache-0.4.1-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f95393b4d66bfae908c3ca8d169d5f79cd65636ae15b5e7a4f6e67af675adb0e", size = 275950, upload-time = "2025-10-08T19:47:33.481Z" }, + { url = "https://files.pythonhosted.org/packages/b4/c1/86f846827fb969c4b78b0af79bba1d1ea2156492e1b83dea8b8a6ae27395/propcache-0.4.1-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:c07fda85708bc48578467e85099645167a955ba093be0a2dcba962195676e859", size = 273856, upload-time = "2025-10-08T19:47:34.906Z" }, + { url = "https://files.pythonhosted.org/packages/36/1d/fc272a63c8d3bbad6878c336c7a7dea15e8f2d23a544bda43205dfa83ada/propcache-0.4.1-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:af223b406d6d000830c6f65f1e6431783fc3f713ba3e6cc8c024d5ee96170a4b", size = 280420, upload-time = "2025-10-08T19:47:36.338Z" }, + { url = "https://files.pythonhosted.org/packages/07/0c/01f2219d39f7e53d52e5173bcb09c976609ba30209912a0680adfb8c593a/propcache-0.4.1-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a78372c932c90ee474559c5ddfffd718238e8673c340dc21fe45c5b8b54559a0", size = 263254, upload-time = "2025-10-08T19:47:37.692Z" }, + { url = "https://files.pythonhosted.org/packages/2d/18/cd28081658ce597898f0c4d174d4d0f3c5b6d4dc27ffafeef835c95eb359/propcache-0.4.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:564d9f0d4d9509e1a870c920a89b2fec951b44bf5ba7d537a9e7c1ccec2c18af", size = 261205, upload-time = "2025-10-08T19:47:39.659Z" }, + { url = "https://files.pythonhosted.org/packages/7a/71/1f9e22eb8b8316701c2a19fa1f388c8a3185082607da8e406a803c9b954e/propcache-0.4.1-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:17612831fda0138059cc5546f4d12a2aacfb9e47068c06af35c400ba58ba7393", size = 247873, upload-time = "2025-10-08T19:47:41.084Z" }, + { url = "https://files.pythonhosted.org/packages/4a/65/3d4b61f36af2b4eddba9def857959f1016a51066b4f1ce348e0cf7881f58/propcache-0.4.1-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:41a89040cb10bd345b3c1a873b2bf36413d48da1def52f268a055f7398514874", size = 262739, upload-time = "2025-10-08T19:47:42.51Z" }, + { url = "https://files.pythonhosted.org/packages/2a/42/26746ab087faa77c1c68079b228810436ccd9a5ce9ac85e2b7307195fd06/propcache-0.4.1-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:e35b88984e7fa64aacecea39236cee32dd9bd8c55f57ba8a75cf2399553f9bd7", size = 263514, upload-time = "2025-10-08T19:47:43.927Z" }, + { url = "https://files.pythonhosted.org/packages/94/13/630690fe201f5502d2403dd3cfd451ed8858fe3c738ee88d095ad2ff407b/propcache-0.4.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:6f8b465489f927b0df505cbe26ffbeed4d6d8a2bbc61ce90eb074ff129ef0ab1", size = 257781, upload-time = "2025-10-08T19:47:45.448Z" }, + { url = "https://files.pythonhosted.org/packages/92/f7/1d4ec5841505f423469efbfc381d64b7b467438cd5a4bbcbb063f3b73d27/propcache-0.4.1-cp313-cp313t-win32.whl", hash = "sha256:2ad890caa1d928c7c2965b48f3a3815c853180831d0e5503d35cf00c472f4717", size = 41396, upload-time = "2025-10-08T19:47:47.202Z" }, + { url = "https://files.pythonhosted.org/packages/48/f0/615c30622316496d2cbbc29f5985f7777d3ada70f23370608c1d3e081c1f/propcache-0.4.1-cp313-cp313t-win_amd64.whl", hash = "sha256:f7ee0e597f495cf415bcbd3da3caa3bd7e816b74d0d52b8145954c5e6fd3ff37", size = 44897, upload-time = "2025-10-08T19:47:48.336Z" }, + { url = "https://files.pythonhosted.org/packages/fd/ca/6002e46eccbe0e33dcd4069ef32f7f1c9e243736e07adca37ae8c4830ec3/propcache-0.4.1-cp313-cp313t-win_arm64.whl", hash = "sha256:929d7cbe1f01bb7baffb33dc14eb5691c95831450a26354cd210a8155170c93a", size = 39789, upload-time = "2025-10-08T19:47:49.876Z" }, + { url = "https://files.pythonhosted.org/packages/8e/5c/bca52d654a896f831b8256683457ceddd490ec18d9ec50e97dfd8fc726a8/propcache-0.4.1-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:3f7124c9d820ba5548d431afb4632301acf965db49e666aa21c305cbe8c6de12", size = 78152, upload-time = "2025-10-08T19:47:51.051Z" }, + { url = "https://files.pythonhosted.org/packages/65/9b/03b04e7d82a5f54fb16113d839f5ea1ede58a61e90edf515f6577c66fa8f/propcache-0.4.1-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:c0d4b719b7da33599dfe3b22d3db1ef789210a0597bc650b7cee9c77c2be8c5c", size = 44869, upload-time = "2025-10-08T19:47:52.594Z" }, + { url = "https://files.pythonhosted.org/packages/b2/fa/89a8ef0468d5833a23fff277b143d0573897cf75bd56670a6d28126c7d68/propcache-0.4.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:9f302f4783709a78240ebc311b793f123328716a60911d667e0c036bc5dcbded", size = 46596, upload-time = "2025-10-08T19:47:54.073Z" }, + { url = "https://files.pythonhosted.org/packages/86/bd/47816020d337f4a746edc42fe8d53669965138f39ee117414c7d7a340cfe/propcache-0.4.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c80ee5802e3fb9ea37938e7eecc307fb984837091d5fd262bb37238b1ae97641", size = 206981, upload-time = "2025-10-08T19:47:55.715Z" }, + { url = "https://files.pythonhosted.org/packages/df/f6/c5fa1357cc9748510ee55f37173eb31bfde6d94e98ccd9e6f033f2fc06e1/propcache-0.4.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ed5a841e8bb29a55fb8159ed526b26adc5bdd7e8bd7bf793ce647cb08656cdf4", size = 211490, upload-time = "2025-10-08T19:47:57.499Z" }, + { url = "https://files.pythonhosted.org/packages/80/1e/e5889652a7c4a3846683401a48f0f2e5083ce0ec1a8a5221d8058fbd1adf/propcache-0.4.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:55c72fd6ea2da4c318e74ffdf93c4fe4e926051133657459131a95c846d16d44", size = 215371, upload-time = "2025-10-08T19:47:59.317Z" }, + { url = "https://files.pythonhosted.org/packages/b2/f2/889ad4b2408f72fe1a4f6a19491177b30ea7bf1a0fd5f17050ca08cfc882/propcache-0.4.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8326e144341460402713f91df60ade3c999d601e7eb5ff8f6f7862d54de0610d", size = 201424, upload-time = "2025-10-08T19:48:00.67Z" }, + { url = "https://files.pythonhosted.org/packages/27/73/033d63069b57b0812c8bd19f311faebeceb6ba31b8f32b73432d12a0b826/propcache-0.4.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:060b16ae65bc098da7f6d25bf359f1f31f688384858204fe5d652979e0015e5b", size = 197566, upload-time = "2025-10-08T19:48:02.604Z" }, + { url = "https://files.pythonhosted.org/packages/dc/89/ce24f3dc182630b4e07aa6d15f0ff4b14ed4b9955fae95a0b54c58d66c05/propcache-0.4.1-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:89eb3fa9524f7bec9de6e83cf3faed9d79bffa560672c118a96a171a6f55831e", size = 193130, upload-time = "2025-10-08T19:48:04.499Z" }, + { url = "https://files.pythonhosted.org/packages/a9/24/ef0d5fd1a811fb5c609278d0209c9f10c35f20581fcc16f818da959fc5b4/propcache-0.4.1-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:dee69d7015dc235f526fe80a9c90d65eb0039103fe565776250881731f06349f", size = 202625, upload-time = "2025-10-08T19:48:06.213Z" }, + { url = "https://files.pythonhosted.org/packages/f5/02/98ec20ff5546f68d673df2f7a69e8c0d076b5abd05ca882dc7ee3a83653d/propcache-0.4.1-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:5558992a00dfd54ccbc64a32726a3357ec93825a418a401f5cc67df0ac5d9e49", size = 204209, upload-time = "2025-10-08T19:48:08.432Z" }, + { url = "https://files.pythonhosted.org/packages/a0/87/492694f76759b15f0467a2a93ab68d32859672b646aa8a04ce4864e7932d/propcache-0.4.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:c9b822a577f560fbd9554812526831712c1436d2c046cedee4c3796d3543b144", size = 197797, upload-time = "2025-10-08T19:48:09.968Z" }, + { url = "https://files.pythonhosted.org/packages/ee/36/66367de3575db1d2d3f3d177432bd14ee577a39d3f5d1b3d5df8afe3b6e2/propcache-0.4.1-cp314-cp314-win32.whl", hash = "sha256:ab4c29b49d560fe48b696cdcb127dd36e0bc2472548f3bf56cc5cb3da2b2984f", size = 38140, upload-time = "2025-10-08T19:48:11.232Z" }, + { url = "https://files.pythonhosted.org/packages/0c/2a/a758b47de253636e1b8aef181c0b4f4f204bf0dd964914fb2af90a95b49b/propcache-0.4.1-cp314-cp314-win_amd64.whl", hash = "sha256:5a103c3eb905fcea0ab98be99c3a9a5ab2de60228aa5aceedc614c0281cf6153", size = 41257, upload-time = "2025-10-08T19:48:12.707Z" }, + { url = "https://files.pythonhosted.org/packages/34/5e/63bd5896c3fec12edcbd6f12508d4890d23c265df28c74b175e1ef9f4f3b/propcache-0.4.1-cp314-cp314-win_arm64.whl", hash = "sha256:74c1fb26515153e482e00177a1ad654721bf9207da8a494a0c05e797ad27b992", size = 38097, upload-time = "2025-10-08T19:48:13.923Z" }, + { url = "https://files.pythonhosted.org/packages/99/85/9ff785d787ccf9bbb3f3106f79884a130951436f58392000231b4c737c80/propcache-0.4.1-cp314-cp314t-macosx_10_13_universal2.whl", hash = "sha256:824e908bce90fb2743bd6b59db36eb4f45cd350a39637c9f73b1c1ea66f5b75f", size = 81455, upload-time = "2025-10-08T19:48:15.16Z" }, + { url = "https://files.pythonhosted.org/packages/90/85/2431c10c8e7ddb1445c1f7c4b54d886e8ad20e3c6307e7218f05922cad67/propcache-0.4.1-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:c2b5e7db5328427c57c8e8831abda175421b709672f6cfc3d630c3b7e2146393", size = 46372, upload-time = "2025-10-08T19:48:16.424Z" }, + { url = "https://files.pythonhosted.org/packages/01/20/b0972d902472da9bcb683fa595099911f4d2e86e5683bcc45de60dd05dc3/propcache-0.4.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:6f6ff873ed40292cd4969ef5310179afd5db59fdf055897e282485043fc80ad0", size = 48411, upload-time = "2025-10-08T19:48:17.577Z" }, + { url = "https://files.pythonhosted.org/packages/e2/e3/7dc89f4f21e8f99bad3d5ddb3a3389afcf9da4ac69e3deb2dcdc96e74169/propcache-0.4.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:49a2dc67c154db2c1463013594c458881a069fcf98940e61a0569016a583020a", size = 275712, upload-time = "2025-10-08T19:48:18.901Z" }, + { url = "https://files.pythonhosted.org/packages/20/67/89800c8352489b21a8047c773067644e3897f02ecbbd610f4d46b7f08612/propcache-0.4.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:005f08e6a0529984491e37d8dbc3dd86f84bd78a8ceb5fa9a021f4c48d4984be", size = 273557, upload-time = "2025-10-08T19:48:20.762Z" }, + { url = "https://files.pythonhosted.org/packages/e2/a1/b52b055c766a54ce6d9c16d9aca0cad8059acd9637cdf8aa0222f4a026ef/propcache-0.4.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5c3310452e0d31390da9035c348633b43d7e7feb2e37be252be6da45abd1abcc", size = 280015, upload-time = "2025-10-08T19:48:22.592Z" }, + { url = "https://files.pythonhosted.org/packages/48/c8/33cee30bd890672c63743049f3c9e4be087e6780906bfc3ec58528be59c1/propcache-0.4.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4c3c70630930447f9ef1caac7728c8ad1c56bc5015338b20fed0d08ea2480b3a", size = 262880, upload-time = "2025-10-08T19:48:23.947Z" }, + { url = "https://files.pythonhosted.org/packages/0c/b1/8f08a143b204b418285c88b83d00edbd61afbc2c6415ffafc8905da7038b/propcache-0.4.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:8e57061305815dfc910a3634dcf584f08168a8836e6999983569f51a8544cd89", size = 260938, upload-time = "2025-10-08T19:48:25.656Z" }, + { url = "https://files.pythonhosted.org/packages/cf/12/96e4664c82ca2f31e1c8dff86afb867348979eb78d3cb8546a680287a1e9/propcache-0.4.1-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:521a463429ef54143092c11a77e04056dd00636f72e8c45b70aaa3140d639726", size = 247641, upload-time = "2025-10-08T19:48:27.207Z" }, + { url = "https://files.pythonhosted.org/packages/18/ed/e7a9cfca28133386ba52278136d42209d3125db08d0a6395f0cba0c0285c/propcache-0.4.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:120c964da3fdc75e3731aa392527136d4ad35868cc556fd09bb6d09172d9a367", size = 262510, upload-time = "2025-10-08T19:48:28.65Z" }, + { url = "https://files.pythonhosted.org/packages/f5/76/16d8bf65e8845dd62b4e2b57444ab81f07f40caa5652b8969b87ddcf2ef6/propcache-0.4.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:d8f353eb14ee3441ee844ade4277d560cdd68288838673273b978e3d6d2c8f36", size = 263161, upload-time = "2025-10-08T19:48:30.133Z" }, + { url = "https://files.pythonhosted.org/packages/e7/70/c99e9edb5d91d5ad8a49fa3c1e8285ba64f1476782fed10ab251ff413ba1/propcache-0.4.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:ab2943be7c652f09638800905ee1bab2c544e537edb57d527997a24c13dc1455", size = 257393, upload-time = "2025-10-08T19:48:31.567Z" }, + { url = "https://files.pythonhosted.org/packages/08/02/87b25304249a35c0915d236575bc3574a323f60b47939a2262b77632a3ee/propcache-0.4.1-cp314-cp314t-win32.whl", hash = "sha256:05674a162469f31358c30bcaa8883cb7829fa3110bf9c0991fe27d7896c42d85", size = 42546, upload-time = "2025-10-08T19:48:32.872Z" }, + { url = "https://files.pythonhosted.org/packages/cb/ef/3c6ecf8b317aa982f309835e8f96987466123c6e596646d4e6a1dfcd080f/propcache-0.4.1-cp314-cp314t-win_amd64.whl", hash = "sha256:990f6b3e2a27d683cb7602ed6c86f15ee6b43b1194736f9baaeb93d0016633b1", size = 46259, upload-time = "2025-10-08T19:48:34.226Z" }, + { url = "https://files.pythonhosted.org/packages/c4/2d/346e946d4951f37eca1e4f55be0f0174c52cd70720f84029b02f296f4a38/propcache-0.4.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ecef2343af4cc68e05131e45024ba34f6095821988a9d0a02aa7c73fcc448aa9", size = 40428, upload-time = "2025-10-08T19:48:35.441Z" }, + { url = "https://files.pythonhosted.org/packages/5b/5a/bc7b4a4ef808fa59a816c17b20c4bef6884daebbdf627ff2a161da67da19/propcache-0.4.1-py3-none-any.whl", hash = "sha256:af2a6052aeb6cf17d3e46ee169099044fd8224cbaf75c76a2ef596e8163e2237", size = 13305, upload-time = "2025-10-08T19:49:00.792Z" }, +] + +[[package]] +name = "pyarrow" +version = "24.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/91/13/13e1069b351bdc3881266e11147ffccf687505dbb0ea74036237f5d454a5/pyarrow-24.0.0.tar.gz", hash = "sha256:85fe721a14dd823aca09127acbb06c3ca723efbd436c004f16bca601b04dcc83", size = 1180261, upload-time = "2026-04-21T10:51:25.837Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b4/a9/9686d9f07837f91f775e8932659192e02c74f9d8920524b480b85212cc68/pyarrow-24.0.0-cp312-cp312-macosx_12_0_arm64.whl", hash = "sha256:6233c9ed9ab9d1db47de57d9753256d9dcffbf42db341576099f0fd9f6bf4810", size = 34981559, upload-time = "2026-04-21T10:47:22.17Z" }, + { url = "https://files.pythonhosted.org/packages/80/b6/0ddf0e9b6ead3474ab087ae598c76b031fc45532bf6a63f3a553440fb258/pyarrow-24.0.0-cp312-cp312-macosx_12_0_x86_64.whl", hash = "sha256:f7616236ec1bc2b15bfdec22a71ab38851c86f8f05ff64f379e1278cf20c634a", size = 36663654, upload-time = "2026-04-21T10:47:28.315Z" }, + { url = "https://files.pythonhosted.org/packages/7c/3b/926382efe8ce27ba729071d3566ade6dfb86bdf112f366000196b2f5780a/pyarrow-24.0.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:1617043b99bd33e5318ae18eb2919af09c71322ef1ca46566cdafc6e6712fb66", size = 45679394, upload-time = "2026-04-21T10:47:34.821Z" }, + { url = "https://files.pythonhosted.org/packages/b3/7a/829f7d9dfd37c207206081d6dad474d81dde29952401f07f2ba507814818/pyarrow-24.0.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:6165461f55ef6314f026de6638d661188e3455d3ec49834556a0ebbdbace18bb", size = 48863122, upload-time = "2026-04-21T10:47:42.056Z" }, + { url = "https://files.pythonhosted.org/packages/5f/e8/f88ce625fe8babaae64e8db2d417c7653adb3019b08aae85c5ed787dc816/pyarrow-24.0.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3b13dedfe76a0ad2d1d859b0811b53827a4e9d93a0bcb05cf59333ab4980cc7e", size = 49376032, upload-time = "2026-04-21T10:47:48.967Z" }, + { url = "https://files.pythonhosted.org/packages/36/7a/82c363caa145fff88fb475da50d3bf52bb024f61917be5424c3392eaf878/pyarrow-24.0.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:25ea65d868eb04015cd18e6df2fbe98f07e5bda2abefabcb88fce39a947716f6", size = 51929490, upload-time = "2026-04-21T10:47:55.981Z" }, + { url = "https://files.pythonhosted.org/packages/66/1c/e3e72c8014ad2743ca64a701652c733cc5cbcee15c0463a32a8c55518d9e/pyarrow-24.0.0-cp312-cp312-win_amd64.whl", hash = "sha256:295f0a7f2e242dabd513737cf076007dc5b2d59237e3eca37b05c0c6446f3826", size = 27355660, upload-time = "2026-04-21T10:48:01.718Z" }, + { url = "https://files.pythonhosted.org/packages/6f/d3/a1abf004482026ddc17f4503db227787fa3cfe41ec5091ff20e4fea55e57/pyarrow-24.0.0-cp313-cp313-macosx_12_0_arm64.whl", hash = "sha256:02b001b3ed4723caa44f6cd1af2d5c86aa2cf9971dacc2ffa55b21237713dfba", size = 34976759, upload-time = "2026-04-21T10:48:07.258Z" }, + { url = "https://files.pythonhosted.org/packages/4f/4a/34f0a36d28a2dd32225301b79daad44e243dc1a2bb77d43b60749be255c4/pyarrow-24.0.0-cp313-cp313-macosx_12_0_x86_64.whl", hash = "sha256:04920d6a71aabd08a0417709efce97d45ea8e6fb733d9ca9ecffb13c67839f68", size = 36658471, upload-time = "2026-04-21T10:48:13.347Z" }, + { url = "https://files.pythonhosted.org/packages/1f/78/543b94712ae8bb1a6023bcc1acf1a740fbff8286747c289cd9468fced2a5/pyarrow-24.0.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:a964266397740257f16f7bb2e4f08a0c81454004beab8ff59dd531b73610e9f2", size = 45675981, upload-time = "2026-04-21T10:48:20.201Z" }, + { url = "https://files.pythonhosted.org/packages/84/9f/8fb7c222b100d314137fa40ec050de56cd8c6d957d1cfff685ce72f15b17/pyarrow-24.0.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:6f066b179d68c413374294bc1735f68475457c933258df594443bb9d88ddc2a0", size = 48859172, upload-time = "2026-04-21T10:48:27.541Z" }, + { url = "https://files.pythonhosted.org/packages/a7/d3/1ea72538e6c8b3b475ed78d1049a2c518e655761ea50fe1171fc855fcab7/pyarrow-24.0.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:1183baeb14c5f587b1ec52831e665718ce632caab84b7cd6b85fd44f96114495", size = 49385733, upload-time = "2026-04-21T10:48:34.7Z" }, + { url = "https://files.pythonhosted.org/packages/c3/be/c3d8b06a1ba35f2260f8e1f771abbee7d5e345c0937aab90675706b1690a/pyarrow-24.0.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:806f24b4085453c197a5078218d1ee08783ebbba271badd153d1ae22a3ee804f", size = 51934335, upload-time = "2026-04-21T10:48:42.099Z" }, + { url = "https://files.pythonhosted.org/packages/9c/62/89e07a1e7329d2cde3e3c6994ba0839a24977a2beda8be6005ea3d860b99/pyarrow-24.0.0-cp313-cp313-win_amd64.whl", hash = "sha256:e4505fc6583f7b05ab854934896bcac8253b04ac1171a77dfb73efef92076d91", size = 27271748, upload-time = "2026-04-21T10:49:42.532Z" }, + { url = "https://files.pythonhosted.org/packages/17/1a/cff3a59f80b5b1658549d46611b67163f65e0664431c076ad728bf9d5af4/pyarrow-24.0.0-cp313-cp313t-macosx_12_0_arm64.whl", hash = "sha256:1a4e45017efbf115032e4475ee876d525e0e36c742214fbe405332480ecd6275", size = 35238554, upload-time = "2026-04-21T10:48:48.526Z" }, + { url = "https://files.pythonhosted.org/packages/a8/99/cce0f42a327bfef2c420fb6078a3eb834826e5d6697bf3009fe11d2ad051/pyarrow-24.0.0-cp313-cp313t-macosx_12_0_x86_64.whl", hash = "sha256:7986f1fa71cee060ad00758bcc79d3a93bab8559bf978fab9e53472a2e25a17b", size = 36782301, upload-time = "2026-04-21T10:48:55.181Z" }, + { url = "https://files.pythonhosted.org/packages/2a/66/8e560d5ff6793ca29aca213c53eec0dd482dd46cb93b2819e5aab52e4252/pyarrow-24.0.0-cp313-cp313t-manylinux_2_28_aarch64.whl", hash = "sha256:d3e0b61e8efb24ed38898e5cdc5fffa9124be480008d401a1f8071500494ae42", size = 45721929, upload-time = "2026-04-21T10:49:03.676Z" }, + { url = "https://files.pythonhosted.org/packages/27/0c/a26e25505d030716e078d9f16eb74973cbf0b33b672884e9f9da1c83b871/pyarrow-24.0.0-cp313-cp313t-manylinux_2_28_x86_64.whl", hash = "sha256:55a3bc1e3df3b5567b7d27ef551b2283f0c68a5e86f1cd56abc569da4f31335b", size = 48825365, upload-time = "2026-04-21T10:49:11.714Z" }, + { url = "https://files.pythonhosted.org/packages/5f/eb/771f9ecb0c65e73fe9dccdd1717901b9594f08c4515d000c7c62df573811/pyarrow-24.0.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:641f795b361874ac9da5294f8f443dfdbee355cf2bd9e3b8d97aaac2306b9b37", size = 49451819, upload-time = "2026-04-21T10:49:21.474Z" }, + { url = "https://files.pythonhosted.org/packages/48/da/61ae89a88732f5a785646f3ec6125dbb640fa98a540eb2b9889caa561403/pyarrow-24.0.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:8adc8e6ce5fccf5dc707046ae4914fd537def529709cc0d285d37a7f9cd442ca", size = 51909252, upload-time = "2026-04-21T10:49:31.164Z" }, + { url = "https://files.pythonhosted.org/packages/cb/1a/8dd5cafab7b66573fa91c03d06d213356ad4edd71813aa75e08ce2b3a844/pyarrow-24.0.0-cp313-cp313t-win_amd64.whl", hash = "sha256:9b18371ad2f44044b81a8d23bc2d8a9b6a6226dca775e8e16cfee640473d6c5d", size = 27388127, upload-time = "2026-04-21T10:49:37.334Z" }, + { url = "https://files.pythonhosted.org/packages/ad/80/d022a34ff05d2cbedd8ccf841fc1f532ecfa9eb5ed1711b56d0e0ea71fc9/pyarrow-24.0.0-cp314-cp314-macosx_12_0_arm64.whl", hash = "sha256:1cc9057f0319e26333b357e17f3c2c022f1a83739b48a88b25bfd5fa2dc18838", size = 35007997, upload-time = "2026-04-21T10:49:48.796Z" }, + { url = "https://files.pythonhosted.org/packages/1a/ff/f01485fda6f4e5d441afb8dd5e7681e4db18826c1e271852f5d3957d6a80/pyarrow-24.0.0-cp314-cp314-macosx_12_0_x86_64.whl", hash = "sha256:e6f1278ee4785b6db21229374a1c9e54ec7c549de5d1efc9630b6207de7e170b", size = 36678720, upload-time = "2026-04-21T10:49:55.858Z" }, + { url = "https://files.pythonhosted.org/packages/9e/c2/2d2d5fea814237923f71b36495211f20b43a1576f9a4d6da7e751a64ec6f/pyarrow-24.0.0-cp314-cp314-manylinux_2_28_aarch64.whl", hash = "sha256:adbbedc55506cbdabb830890444fb856bfb0060c46c6f8026c6c2f2cf86ae795", size = 45741852, upload-time = "2026-04-21T10:50:04.624Z" }, + { url = "https://files.pythonhosted.org/packages/8e/3a/28ba9c1c1ebdbb5f1b94dfebb46f207e52e6a554b7fe4132540fde29a3a0/pyarrow-24.0.0-cp314-cp314-manylinux_2_28_x86_64.whl", hash = "sha256:ae8a1145af31d903fa9bb166824d7abe9b4681a000b0159c9fb99c11bc11ad26", size = 48889852, upload-time = "2026-04-21T10:50:12.293Z" }, + { url = "https://files.pythonhosted.org/packages/df/51/4a389acfd31dca009f8fb82d7f510bb4130f2b3a8e18cf00194d0687d8ac/pyarrow-24.0.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:d7027eba1df3b2069e2e8d80f644fa0918b68c46432af3d088ddd390d063ecde", size = 49445207, upload-time = "2026-04-21T10:50:20.677Z" }, + { url = "https://files.pythonhosted.org/packages/19/4b/0bab2b23d2ae901b1b9a03c0efd4b2d070256f8ce3fc43f6e58c167b2081/pyarrow-24.0.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e56a1ffe9bf7b727432b89104cc0849c21582949dd7bdcb34f17b2001a351a76", size = 51954117, upload-time = "2026-04-21T10:50:29.14Z" }, + { url = "https://files.pythonhosted.org/packages/29/88/f4e9145da0417b3d2c12035a8492b35ff4a3dbc653e614fcfb51d9dedb38/pyarrow-24.0.0-cp314-cp314-win_amd64.whl", hash = "sha256:38be1808cdd068605b787e6ca9119b27eb275a0234e50212c3492331680c3b1e", size = 28001155, upload-time = "2026-04-21T10:51:22.337Z" }, + { url = "https://files.pythonhosted.org/packages/79/4f/46a49a63f43526da895b1a45bbb51d5baf8e4d77159f8528fc3e5490007f/pyarrow-24.0.0-cp314-cp314t-macosx_12_0_arm64.whl", hash = "sha256:418e48ce50a45a6a6c73c454677203a9c75c966cb1e92ca3370959185f197a05", size = 35250387, upload-time = "2026-04-21T10:50:35.552Z" }, + { url = "https://files.pythonhosted.org/packages/a0/da/d5e0cd5ef00796922404806d5f00325cdadc3441ce2c13fe7115f2df9a64/pyarrow-24.0.0-cp314-cp314t-macosx_12_0_x86_64.whl", hash = "sha256:2f16197705a230a78270cdd4ea8a1d57e86b2fdcbc34a1f6aebc72e65c986f9a", size = 36797102, upload-time = "2026-04-21T10:50:42.417Z" }, + { url = "https://files.pythonhosted.org/packages/34/c7/5904145b0a593a05236c882933d439b5720f0a145381179063722fbfc123/pyarrow-24.0.0-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:fb24ac194bfc5e86839d7dcd52092ee31e5fe6733fe11f5e3b06ef0812b20072", size = 45745118, upload-time = "2026-04-21T10:50:49.324Z" }, + { url = "https://files.pythonhosted.org/packages/13/d3/cca42fe166d1c6e4d5b80e530b7949104d10e17508a90ae202dac205ce2a/pyarrow-24.0.0-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:9700ebd9a51f5895ce75ff4ac4b3c47a7d4b42bc618be8e713e5d56bacf5f931", size = 48844765, upload-time = "2026-04-21T10:50:55.579Z" }, + { url = "https://files.pythonhosted.org/packages/b0/49/942c3b79878ba928324d1e17c274ed84581db8c0a749b24bcf4cbdf15bd3/pyarrow-24.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:d8ddd2768da81d3ee08cfea9b597f4abb4e8e1dc8ae7e204b608d23a0d3ab699", size = 49471890, upload-time = "2026-04-21T10:51:02.439Z" }, + { url = "https://files.pythonhosted.org/packages/76/97/ff71431000a75d84135a1ace5ca4ba11726a231a8007bbb320a4c54075d5/pyarrow-24.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:61a3d7eaa97a14768b542f3d284dc6400dd2470d9f080708b13cd46b6ae18136", size = 51932250, upload-time = "2026-04-21T10:51:10.576Z" }, + { url = "https://files.pythonhosted.org/packages/51/be/6f79d55816d5c22557cf27533543d5d70dfe692adfbee4b99f2760674f38/pyarrow-24.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:c91d00057f23b8d353039520dc3a6c09d8608164c692e9f59a175a42b2ae0c19", size = 28131282, upload-time = "2026-04-21T10:51:16.815Z" }, +] + +[[package]] +name = "pygments" +version = "2.20.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c3/b2/bc9c9196916376152d655522fdcebac55e66de6603a76a02bca1b6414f6c/pygments-2.20.0.tar.gz", hash = "sha256:6757cd03768053ff99f3039c1a36d6c0aa0b263438fcab17520b30a303a82b5f", size = 4955991, upload-time = "2026-03-29T13:29:33.898Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f4/7e/a72dd26f3b0f4f2bf1dd8923c85f7ceb43172af56d63c7383eb62b332364/pygments-2.20.0-py3-none-any.whl", hash = "sha256:81a9e26dd42fd28a23a2d169d86d7ac03b46e2f8b59ed4698fb4785f946d0176", size = 1231151, upload-time = "2026-03-29T13:29:30.038Z" }, +] + +[[package]] +name = "python-dateutil" +version = "2.9.0.post0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/66/c0/0c8b6ad9f17a802ee498c46e004a0eb49bc148f2fd230864601a86dcf6db/python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3", size = 342432, upload-time = "2024-03-01T18:36:20.211Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427", size = 229892, upload-time = "2024-03-01T18:36:18.57Z" }, +] + +[[package]] +name = "pyyaml" +version = "6.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/33/422b98d2195232ca1826284a76852ad5a86fe23e31b009c9886b2d0fb8b2/pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196", size = 182063, upload-time = "2025-09-25T21:32:11.445Z" }, + { url = "https://files.pythonhosted.org/packages/89/a0/6cf41a19a1f2f3feab0e9c0b74134aa2ce6849093d5517a0c550fe37a648/pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0", size = 173973, upload-time = "2025-09-25T21:32:12.492Z" }, + { url = "https://files.pythonhosted.org/packages/ed/23/7a778b6bd0b9a8039df8b1b1d80e2e2ad78aa04171592c8a5c43a56a6af4/pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28", size = 775116, upload-time = "2025-09-25T21:32:13.652Z" }, + { url = "https://files.pythonhosted.org/packages/65/30/d7353c338e12baef4ecc1b09e877c1970bd3382789c159b4f89d6a70dc09/pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c", size = 844011, upload-time = "2025-09-25T21:32:15.21Z" }, + { url = "https://files.pythonhosted.org/packages/8b/9d/b3589d3877982d4f2329302ef98a8026e7f4443c765c46cfecc8858c6b4b/pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc", size = 807870, upload-time = "2025-09-25T21:32:16.431Z" }, + { url = "https://files.pythonhosted.org/packages/05/c0/b3be26a015601b822b97d9149ff8cb5ead58c66f981e04fedf4e762f4bd4/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e", size = 761089, upload-time = "2025-09-25T21:32:17.56Z" }, + { url = "https://files.pythonhosted.org/packages/be/8e/98435a21d1d4b46590d5459a22d88128103f8da4c2d4cb8f14f2a96504e1/pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea", size = 790181, upload-time = "2025-09-25T21:32:18.834Z" }, + { url = "https://files.pythonhosted.org/packages/74/93/7baea19427dcfbe1e5a372d81473250b379f04b1bd3c4c5ff825e2327202/pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5", size = 137658, upload-time = "2025-09-25T21:32:20.209Z" }, + { url = "https://files.pythonhosted.org/packages/86/bf/899e81e4cce32febab4fb42bb97dcdf66bc135272882d1987881a4b519e9/pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b", size = 154003, upload-time = "2025-09-25T21:32:21.167Z" }, + { url = "https://files.pythonhosted.org/packages/1a/08/67bd04656199bbb51dbed1439b7f27601dfb576fb864099c7ef0c3e55531/pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd", size = 140344, upload-time = "2025-09-25T21:32:22.617Z" }, + { url = "https://files.pythonhosted.org/packages/d1/11/0fd08f8192109f7169db964b5707a2f1e8b745d4e239b784a5a1dd80d1db/pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8", size = 181669, upload-time = "2025-09-25T21:32:23.673Z" }, + { url = "https://files.pythonhosted.org/packages/b1/16/95309993f1d3748cd644e02e38b75d50cbc0d9561d21f390a76242ce073f/pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1", size = 173252, upload-time = "2025-09-25T21:32:25.149Z" }, + { url = "https://files.pythonhosted.org/packages/50/31/b20f376d3f810b9b2371e72ef5adb33879b25edb7a6d072cb7ca0c486398/pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c", size = 767081, upload-time = "2025-09-25T21:32:26.575Z" }, + { url = "https://files.pythonhosted.org/packages/49/1e/a55ca81e949270d5d4432fbbd19dfea5321eda7c41a849d443dc92fd1ff7/pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5", size = 841159, upload-time = "2025-09-25T21:32:27.727Z" }, + { url = "https://files.pythonhosted.org/packages/74/27/e5b8f34d02d9995b80abcef563ea1f8b56d20134d8f4e5e81733b1feceb2/pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6", size = 801626, upload-time = "2025-09-25T21:32:28.878Z" }, + { url = "https://files.pythonhosted.org/packages/f9/11/ba845c23988798f40e52ba45f34849aa8a1f2d4af4b798588010792ebad6/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6", size = 753613, upload-time = "2025-09-25T21:32:30.178Z" }, + { url = "https://files.pythonhosted.org/packages/3d/e0/7966e1a7bfc0a45bf0a7fb6b98ea03fc9b8d84fa7f2229e9659680b69ee3/pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be", size = 794115, upload-time = "2025-09-25T21:32:31.353Z" }, + { url = "https://files.pythonhosted.org/packages/de/94/980b50a6531b3019e45ddeada0626d45fa85cbe22300844a7983285bed3b/pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26", size = 137427, upload-time = "2025-09-25T21:32:32.58Z" }, + { url = "https://files.pythonhosted.org/packages/97/c9/39d5b874e8b28845e4ec2202b5da735d0199dbe5b8fb85f91398814a9a46/pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c", size = 154090, upload-time = "2025-09-25T21:32:33.659Z" }, + { url = "https://files.pythonhosted.org/packages/73/e8/2bdf3ca2090f68bb3d75b44da7bbc71843b19c9f2b9cb9b0f4ab7a5a4329/pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb", size = 140246, upload-time = "2025-09-25T21:32:34.663Z" }, + { url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" }, + { url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" }, + { url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" }, + { url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" }, + { url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" }, + { url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" }, + { url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" }, + { url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" }, + { url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" }, + { url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" }, + { url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" }, + { url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" }, + { url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" }, + { url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" }, + { url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" }, + { url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" }, + { url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" }, + { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, +] + +[[package]] +name = "requests" +version = "2.33.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "charset-normalizer" }, + { name = "idna" }, + { name = "urllib3" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5f/a4/98b9c7c6428a668bf7e42ebb7c79d576a1c3c1e3ae2d47e674b468388871/requests-2.33.1.tar.gz", hash = "sha256:18817f8c57c6263968bc123d237e3b8b08ac046f5456bd1e307ee8f4250d3517", size = 134120, upload-time = "2026-03-30T16:09:15.531Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d7/8e/7540e8a2036f79a125c1d2ebadf69ed7901608859186c856fa0388ef4197/requests-2.33.1-py3-none-any.whl", hash = "sha256:4e6d1ef462f3626a1f0a0a9c42dd93c63bad33f9f1c1937509b8c5c8718ab56a", size = 64947, upload-time = "2026-03-30T16:09:13.83Z" }, +] + +[[package]] +name = "rich" +version = "15.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c0/8f/0722ca900cc807c13a6a0c696dacf35430f72e0ec571c4275d2371fca3e9/rich-15.0.0.tar.gz", hash = "sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36", size = 230680, upload-time = "2026-04-12T08:24:00.75Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/82/3b/64d4899d73f91ba49a8c18a8ff3f0ea8f1c1d75481760df8c68ef5235bf5/rich-15.0.0-py3-none-any.whl", hash = "sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb", size = 310654, upload-time = "2026-04-12T08:24:02.83Z" }, +] + +[[package]] +name = "shellingham" +version = "1.5.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/58/15/8b3609fd3830ef7b27b655beb4b4e9c62313a4e8da8c676e142cc210d58e/shellingham-1.5.4.tar.gz", hash = "sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de", size = 10310, upload-time = "2023-10-24T04:13:40.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e0/f9/0595336914c5619e5f28a1fb793285925a8cd4b432c9da0a987836c7f822/shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686", size = 9755, upload-time = "2023-10-24T04:13:38.866Z" }, +] + +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, +] + +[[package]] +name = "tqdm" +version = "4.67.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/09/a9/6ba95a270c6f1fbcd8dac228323f2777d886cb206987444e4bce66338dd4/tqdm-4.67.3.tar.gz", hash = "sha256:7d825f03f89244ef73f1d4ce193cb1774a8179fd96f31d7e1dcde62092b960bb", size = 169598, upload-time = "2026-02-03T17:35:53.048Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/16/e1/3079a9ff9b8e11b846c6ac5c8b5bfb7ff225eee721825310c91b3b50304f/tqdm-4.67.3-py3-none-any.whl", hash = "sha256:ee1e4c0e59148062281c49d80b25b67771a127c85fc9676d3be5f243206826bf", size = 78374, upload-time = "2026-02-03T17:35:50.982Z" }, +] + +[[package]] +name = "typer" +version = "0.24.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-doc" }, + { name = "click" }, + { name = "rich" }, + { name = "shellingham" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/83/b8/9ebb531b6c2d377af08ac6746a5df3425b21853a5d2260876919b58a2a4a/typer-0.24.2.tar.gz", hash = "sha256:ec070dcfca1408e85ee203c6365001e818c3b7fffe686fd07ff2d68095ca0480", size = 119849, upload-time = "2026-04-22T17:45:34.413Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/d1/9484b497e0a0410b901c12b8251c3e746e1e863f7d28419ffe06f7892fda/typer-0.24.2-py3-none-any.whl", hash = "sha256:b618bc3d721f9a8d30f3e05565be26416d06e9bcc29d49bc491dc26aba674fa8", size = 55977, upload-time = "2026-04-22T17:45:33.055Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, +] + +[[package]] +name = "tzdata" +version = "2026.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ba/19/1b9b0e29f30c6d35cb345486df41110984ea67ae69dddbc0e8a100999493/tzdata-2026.2.tar.gz", hash = "sha256:9173fde7d80d9018e02a662e168e5a2d04f87c41ea174b139fbef642eda62d10", size = 198254, upload-time = "2026-04-24T15:22:08.651Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ce/e4/dccd7f47c4b64213ac01ef921a1337ee6e30e8c6466046018326977efd95/tzdata-2026.2-py2.py3-none-any.whl", hash = "sha256:bbe9af844f658da81a5f95019480da3a89415801f6cc966806612cc7169bffe7", size = 349321, upload-time = "2026-04-24T15:22:05.876Z" }, +] + +[[package]] +name = "urllib3" +version = "2.6.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz", hash = "sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed", size = 435556, upload-time = "2026-01-07T16:24:43.925Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" }, +] + +[[package]] +name = "xxhash" +version = "3.6.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/02/84/30869e01909fb37a6cc7e18688ee8bf1e42d57e7e0777636bd47524c43c7/xxhash-3.6.0.tar.gz", hash = "sha256:f0162a78b13a0d7617b2845b90c763339d1f1d82bb04a4b07f4ab535cc5e05d6", size = 85160, upload-time = "2025-10-02T14:37:08.097Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9a/07/d9412f3d7d462347e4511181dea65e47e0d0e16e26fbee2ea86a2aefb657/xxhash-3.6.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:01362c4331775398e7bb34e3ab403bc9ee9f7c497bc7dee6272114055277dd3c", size = 32744, upload-time = "2025-10-02T14:34:34.622Z" }, + { url = "https://files.pythonhosted.org/packages/79/35/0429ee11d035fc33abe32dca1b2b69e8c18d236547b9a9b72c1929189b9a/xxhash-3.6.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b7b2df81a23f8cb99656378e72501b2cb41b1827c0f5a86f87d6b06b69f9f204", size = 30816, upload-time = "2025-10-02T14:34:36.043Z" }, + { url = "https://files.pythonhosted.org/packages/b7/f2/57eb99aa0f7d98624c0932c5b9a170e1806406cdbcdb510546634a1359e0/xxhash-3.6.0-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:dc94790144e66b14f67b10ac8ed75b39ca47536bf8800eb7c24b50271ea0c490", size = 194035, upload-time = "2025-10-02T14:34:37.354Z" }, + { url = "https://files.pythonhosted.org/packages/4c/ed/6224ba353690d73af7a3f1c7cdb1fc1b002e38f783cb991ae338e1eb3d79/xxhash-3.6.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:93f107c673bccf0d592cdba077dedaf52fe7f42dcd7676eba1f6d6f0c3efffd2", size = 212914, upload-time = "2025-10-02T14:34:38.6Z" }, + { url = "https://files.pythonhosted.org/packages/38/86/fb6b6130d8dd6b8942cc17ab4d90e223653a89aa32ad2776f8af7064ed13/xxhash-3.6.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2aa5ee3444c25b69813663c9f8067dcfaa2e126dc55e8dddf40f4d1c25d7effa", size = 212163, upload-time = "2025-10-02T14:34:39.872Z" }, + { url = "https://files.pythonhosted.org/packages/ee/dc/e84875682b0593e884ad73b2d40767b5790d417bde603cceb6878901d647/xxhash-3.6.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:f7f99123f0e1194fa59cc69ad46dbae2e07becec5df50a0509a808f90a0f03f0", size = 445411, upload-time = "2025-10-02T14:34:41.569Z" }, + { url = "https://files.pythonhosted.org/packages/11/4f/426f91b96701ec2f37bb2b8cec664eff4f658a11f3fa9d94f0a887ea6d2b/xxhash-3.6.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:49e03e6fe2cac4a1bc64952dd250cf0dbc5ef4ebb7b8d96bce82e2de163c82a2", size = 193883, upload-time = "2025-10-02T14:34:43.249Z" }, + { url = "https://files.pythonhosted.org/packages/53/5a/ddbb83eee8e28b778eacfc5a85c969673e4023cdeedcfcef61f36731610b/xxhash-3.6.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:bd17fede52a17a4f9a7bc4472a5867cb0b160deeb431795c0e4abe158bc784e9", size = 210392, upload-time = "2025-10-02T14:34:45.042Z" }, + { url = "https://files.pythonhosted.org/packages/1e/c2/ff69efd07c8c074ccdf0a4f36fcdd3d27363665bcdf4ba399abebe643465/xxhash-3.6.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:6fb5f5476bef678f69db04f2bd1efbed3030d2aba305b0fc1773645f187d6a4e", size = 197898, upload-time = "2025-10-02T14:34:46.302Z" }, + { url = "https://files.pythonhosted.org/packages/58/ca/faa05ac19b3b622c7c9317ac3e23954187516298a091eb02c976d0d3dd45/xxhash-3.6.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:843b52f6d88071f87eba1631b684fcb4b2068cd2180a0224122fe4ef011a9374", size = 210655, upload-time = "2025-10-02T14:34:47.571Z" }, + { url = "https://files.pythonhosted.org/packages/d4/7a/06aa7482345480cc0cb597f5c875b11a82c3953f534394f620b0be2f700c/xxhash-3.6.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:7d14a6cfaf03b1b6f5f9790f76880601ccc7896aff7ab9cd8978a939c1eb7e0d", size = 414001, upload-time = "2025-10-02T14:34:49.273Z" }, + { url = "https://files.pythonhosted.org/packages/23/07/63ffb386cd47029aa2916b3d2f454e6cc5b9f5c5ada3790377d5430084e7/xxhash-3.6.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:418daf3db71e1413cfe211c2f9a528456936645c17f46b5204705581a45390ae", size = 191431, upload-time = "2025-10-02T14:34:50.798Z" }, + { url = "https://files.pythonhosted.org/packages/0f/93/14fde614cadb4ddf5e7cebf8918b7e8fac5ae7861c1875964f17e678205c/xxhash-3.6.0-cp312-cp312-win32.whl", hash = "sha256:50fc255f39428a27299c20e280d6193d8b63b8ef8028995323bf834a026b4fbb", size = 30617, upload-time = "2025-10-02T14:34:51.954Z" }, + { url = "https://files.pythonhosted.org/packages/13/5d/0d125536cbe7565a83d06e43783389ecae0c0f2ed037b48ede185de477c0/xxhash-3.6.0-cp312-cp312-win_amd64.whl", hash = "sha256:c0f2ab8c715630565ab8991b536ecded9416d615538be8ecddce43ccf26cbc7c", size = 31534, upload-time = "2025-10-02T14:34:53.276Z" }, + { url = "https://files.pythonhosted.org/packages/54/85/6ec269b0952ec7e36ba019125982cf11d91256a778c7c3f98a4c5043d283/xxhash-3.6.0-cp312-cp312-win_arm64.whl", hash = "sha256:eae5c13f3bc455a3bbb68bdc513912dc7356de7e2280363ea235f71f54064829", size = 27876, upload-time = "2025-10-02T14:34:54.371Z" }, + { url = "https://files.pythonhosted.org/packages/33/76/35d05267ac82f53ae9b0e554da7c5e281ee61f3cad44c743f0fcd354f211/xxhash-3.6.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:599e64ba7f67472481ceb6ee80fa3bd828fd61ba59fb11475572cc5ee52b89ec", size = 32738, upload-time = "2025-10-02T14:34:55.839Z" }, + { url = "https://files.pythonhosted.org/packages/31/a8/3fbce1cd96534a95e35d5120637bf29b0d7f5d8fa2f6374e31b4156dd419/xxhash-3.6.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7d8b8aaa30fca4f16f0c84a5c8d7ddee0e25250ec2796c973775373257dde8f1", size = 30821, upload-time = "2025-10-02T14:34:57.219Z" }, + { url = "https://files.pythonhosted.org/packages/0c/ea/d387530ca7ecfa183cb358027f1833297c6ac6098223fd14f9782cd0015c/xxhash-3.6.0-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:d597acf8506d6e7101a4a44a5e428977a51c0fadbbfd3c39650cca9253f6e5a6", size = 194127, upload-time = "2025-10-02T14:34:59.21Z" }, + { url = "https://files.pythonhosted.org/packages/ba/0c/71435dcb99874b09a43b8d7c54071e600a7481e42b3e3ce1eb5226a5711a/xxhash-3.6.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:858dc935963a33bc33490128edc1c12b0c14d9c7ebaa4e387a7869ecc4f3e263", size = 212975, upload-time = "2025-10-02T14:35:00.816Z" }, + { url = "https://files.pythonhosted.org/packages/84/7a/c2b3d071e4bb4a90b7057228a99b10d51744878f4a8a6dd643c8bd897620/xxhash-3.6.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ba284920194615cb8edf73bf52236ce2e1664ccd4a38fdb543506413529cc546", size = 212241, upload-time = "2025-10-02T14:35:02.207Z" }, + { url = "https://files.pythonhosted.org/packages/81/5f/640b6eac0128e215f177df99eadcd0f1b7c42c274ab6a394a05059694c5a/xxhash-3.6.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4b54219177f6c6674d5378bd862c6aedf64725f70dd29c472eaae154df1a2e89", size = 445471, upload-time = "2025-10-02T14:35:03.61Z" }, + { url = "https://files.pythonhosted.org/packages/5e/1e/3c3d3ef071b051cc3abbe3721ffb8365033a172613c04af2da89d5548a87/xxhash-3.6.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:42c36dd7dbad2f5238950c377fcbf6811b1cdb1c444fab447960030cea60504d", size = 193936, upload-time = "2025-10-02T14:35:05.013Z" }, + { url = "https://files.pythonhosted.org/packages/2c/bd/4a5f68381939219abfe1c22a9e3a5854a4f6f6f3c4983a87d255f21f2e5d/xxhash-3.6.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f22927652cba98c44639ffdc7aaf35828dccf679b10b31c4ad72a5b530a18eb7", size = 210440, upload-time = "2025-10-02T14:35:06.239Z" }, + { url = "https://files.pythonhosted.org/packages/eb/37/b80fe3d5cfb9faff01a02121a0f4d565eb7237e9e5fc66e73017e74dcd36/xxhash-3.6.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:b45fad44d9c5c119e9c6fbf2e1c656a46dc68e280275007bbfd3d572b21426db", size = 197990, upload-time = "2025-10-02T14:35:07.735Z" }, + { url = "https://files.pythonhosted.org/packages/d7/fd/2c0a00c97b9e18f72e1f240ad4e8f8a90fd9d408289ba9c7c495ed7dc05c/xxhash-3.6.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:6f2580ffab1a8b68ef2b901cde7e55fa8da5e4be0977c68f78fc80f3c143de42", size = 210689, upload-time = "2025-10-02T14:35:09.438Z" }, + { url = "https://files.pythonhosted.org/packages/93/86/5dd8076a926b9a95db3206aba20d89a7fc14dd5aac16e5c4de4b56033140/xxhash-3.6.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:40c391dd3cd041ebc3ffe6f2c862f402e306eb571422e0aa918d8070ba31da11", size = 414068, upload-time = "2025-10-02T14:35:11.162Z" }, + { url = "https://files.pythonhosted.org/packages/af/3c/0bb129170ee8f3650f08e993baee550a09593462a5cddd8e44d0011102b1/xxhash-3.6.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:f205badabde7aafd1a31e8ca2a3e5a763107a71c397c4481d6a804eb5063d8bd", size = 191495, upload-time = "2025-10-02T14:35:12.971Z" }, + { url = "https://files.pythonhosted.org/packages/e9/3a/6797e0114c21d1725e2577508e24006fd7ff1d8c0c502d3b52e45c1771d8/xxhash-3.6.0-cp313-cp313-win32.whl", hash = "sha256:2577b276e060b73b73a53042ea5bd5203d3e6347ce0d09f98500f418a9fcf799", size = 30620, upload-time = "2025-10-02T14:35:14.129Z" }, + { url = "https://files.pythonhosted.org/packages/86/15/9bc32671e9a38b413a76d24722a2bf8784a132c043063a8f5152d390b0f9/xxhash-3.6.0-cp313-cp313-win_amd64.whl", hash = "sha256:757320d45d2fbcce8f30c42a6b2f47862967aea7bf458b9625b4bbe7ee390392", size = 31542, upload-time = "2025-10-02T14:35:15.21Z" }, + { url = "https://files.pythonhosted.org/packages/39/c5/cc01e4f6188656e56112d6a8e0dfe298a16934b8c47a247236549a3f7695/xxhash-3.6.0-cp313-cp313-win_arm64.whl", hash = "sha256:457b8f85dec5825eed7b69c11ae86834a018b8e3df5e77783c999663da2f96d6", size = 27880, upload-time = "2025-10-02T14:35:16.315Z" }, + { url = "https://files.pythonhosted.org/packages/f3/30/25e5321c8732759e930c555176d37e24ab84365482d257c3b16362235212/xxhash-3.6.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:a42e633d75cdad6d625434e3468126c73f13f7584545a9cf34e883aa1710e702", size = 32956, upload-time = "2025-10-02T14:35:17.413Z" }, + { url = "https://files.pythonhosted.org/packages/9f/3c/0573299560d7d9f8ab1838f1efc021a280b5ae5ae2e849034ef3dee18810/xxhash-3.6.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:568a6d743219e717b07b4e03b0a828ce593833e498c3b64752e0f5df6bfe84db", size = 31072, upload-time = "2025-10-02T14:35:18.844Z" }, + { url = "https://files.pythonhosted.org/packages/7a/1c/52d83a06e417cd9d4137722693424885cc9878249beb3a7c829e74bf7ce9/xxhash-3.6.0-cp313-cp313t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:bec91b562d8012dae276af8025a55811b875baace6af510412a5e58e3121bc54", size = 196409, upload-time = "2025-10-02T14:35:20.31Z" }, + { url = "https://files.pythonhosted.org/packages/e3/8e/c6d158d12a79bbd0b878f8355432075fc82759e356ab5a111463422a239b/xxhash-3.6.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:78e7f2f4c521c30ad5e786fdd6bae89d47a32672a80195467b5de0480aa97b1f", size = 215736, upload-time = "2025-10-02T14:35:21.616Z" }, + { url = "https://files.pythonhosted.org/packages/bc/68/c4c80614716345d55071a396cf03d06e34b5f4917a467faf43083c995155/xxhash-3.6.0-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3ed0df1b11a79856df5ffcab572cbd6b9627034c1c748c5566fa79df9048a7c5", size = 214833, upload-time = "2025-10-02T14:35:23.32Z" }, + { url = "https://files.pythonhosted.org/packages/7e/e9/ae27c8ffec8b953efa84c7c4a6c6802c263d587b9fc0d6e7cea64e08c3af/xxhash-3.6.0-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:0e4edbfc7d420925b0dd5e792478ed393d6e75ff8fc219a6546fb446b6a417b1", size = 448348, upload-time = "2025-10-02T14:35:25.111Z" }, + { url = "https://files.pythonhosted.org/packages/d7/6b/33e21afb1b5b3f46b74b6bd1913639066af218d704cc0941404ca717fc57/xxhash-3.6.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fba27a198363a7ef87f8c0f6b171ec36b674fe9053742c58dd7e3201c1ab30ee", size = 196070, upload-time = "2025-10-02T14:35:26.586Z" }, + { url = "https://files.pythonhosted.org/packages/96/b6/fcabd337bc5fa624e7203aa0fa7d0c49eed22f72e93229431752bddc83d9/xxhash-3.6.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:794fe9145fe60191c6532fa95063765529770edcdd67b3d537793e8004cabbfd", size = 212907, upload-time = "2025-10-02T14:35:28.087Z" }, + { url = "https://files.pythonhosted.org/packages/4b/d3/9ee6160e644d660fcf176c5825e61411c7f62648728f69c79ba237250143/xxhash-3.6.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:6105ef7e62b5ac73a837778efc331a591d8442f8ef5c7e102376506cb4ae2729", size = 200839, upload-time = "2025-10-02T14:35:29.857Z" }, + { url = "https://files.pythonhosted.org/packages/0d/98/e8de5baa5109394baf5118f5e72ab21a86387c4f89b0e77ef3e2f6b0327b/xxhash-3.6.0-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:f01375c0e55395b814a679b3eea205db7919ac2af213f4a6682e01220e5fe292", size = 213304, upload-time = "2025-10-02T14:35:31.222Z" }, + { url = "https://files.pythonhosted.org/packages/7b/1d/71056535dec5c3177eeb53e38e3d367dd1d16e024e63b1cee208d572a033/xxhash-3.6.0-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:d706dca2d24d834a4661619dcacf51a75c16d65985718d6a7d73c1eeeb903ddf", size = 416930, upload-time = "2025-10-02T14:35:32.517Z" }, + { url = "https://files.pythonhosted.org/packages/dc/6c/5cbde9de2cd967c322e651c65c543700b19e7ae3e0aae8ece3469bf9683d/xxhash-3.6.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:5f059d9faeacd49c0215d66f4056e1326c80503f51a1532ca336a385edadd033", size = 193787, upload-time = "2025-10-02T14:35:33.827Z" }, + { url = "https://files.pythonhosted.org/packages/19/fa/0172e350361d61febcea941b0cc541d6e6c8d65d153e85f850a7b256ff8a/xxhash-3.6.0-cp313-cp313t-win32.whl", hash = "sha256:1244460adc3a9be84731d72b8e80625788e5815b68da3da8b83f78115a40a7ec", size = 30916, upload-time = "2025-10-02T14:35:35.107Z" }, + { url = "https://files.pythonhosted.org/packages/ad/e6/e8cf858a2b19d6d45820f072eff1bea413910592ff17157cabc5f1227a16/xxhash-3.6.0-cp313-cp313t-win_amd64.whl", hash = "sha256:b1e420ef35c503869c4064f4a2f2b08ad6431ab7b229a05cce39d74268bca6b8", size = 31799, upload-time = "2025-10-02T14:35:36.165Z" }, + { url = "https://files.pythonhosted.org/packages/56/15/064b197e855bfb7b343210e82490ae672f8bc7cdf3ddb02e92f64304ee8a/xxhash-3.6.0-cp313-cp313t-win_arm64.whl", hash = "sha256:ec44b73a4220623235f67a996c862049f375df3b1052d9899f40a6382c32d746", size = 28044, upload-time = "2025-10-02T14:35:37.195Z" }, + { url = "https://files.pythonhosted.org/packages/7e/5e/0138bc4484ea9b897864d59fce9be9086030825bc778b76cb5a33a906d37/xxhash-3.6.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:a40a3d35b204b7cc7643cbcf8c9976d818cb47befcfac8bbefec8038ac363f3e", size = 32754, upload-time = "2025-10-02T14:35:38.245Z" }, + { url = "https://files.pythonhosted.org/packages/18/d7/5dac2eb2ec75fd771957a13e5dda560efb2176d5203f39502a5fc571f899/xxhash-3.6.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a54844be970d3fc22630b32d515e79a90d0a3ddb2644d8d7402e3c4c8da61405", size = 30846, upload-time = "2025-10-02T14:35:39.6Z" }, + { url = "https://files.pythonhosted.org/packages/fe/71/8bc5be2bb00deb5682e92e8da955ebe5fa982da13a69da5a40a4c8db12fb/xxhash-3.6.0-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:016e9190af8f0a4e3741343777710e3d5717427f175adfdc3e72508f59e2a7f3", size = 194343, upload-time = "2025-10-02T14:35:40.69Z" }, + { url = "https://files.pythonhosted.org/packages/e7/3b/52badfb2aecec2c377ddf1ae75f55db3ba2d321c5e164f14461c90837ef3/xxhash-3.6.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4f6f72232f849eb9d0141e2ebe2677ece15adfd0fa599bc058aad83c714bb2c6", size = 213074, upload-time = "2025-10-02T14:35:42.29Z" }, + { url = "https://files.pythonhosted.org/packages/a2/2b/ae46b4e9b92e537fa30d03dbc19cdae57ed407e9c26d163895e968e3de85/xxhash-3.6.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:63275a8aba7865e44b1813d2177e0f5ea7eadad3dd063a21f7cf9afdc7054063", size = 212388, upload-time = "2025-10-02T14:35:43.929Z" }, + { url = "https://files.pythonhosted.org/packages/f5/80/49f88d3afc724b4ac7fbd664c8452d6db51b49915be48c6982659e0e7942/xxhash-3.6.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:3cd01fa2aa00d8b017c97eb46b9a794fbdca53fc14f845f5a328c71254b0abb7", size = 445614, upload-time = "2025-10-02T14:35:45.216Z" }, + { url = "https://files.pythonhosted.org/packages/ed/ba/603ce3961e339413543d8cd44f21f2c80e2a7c5cfe692a7b1f2cccf58f3c/xxhash-3.6.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0226aa89035b62b6a86d3c68df4d7c1f47a342b8683da2b60cedcddb46c4d95b", size = 194024, upload-time = "2025-10-02T14:35:46.959Z" }, + { url = "https://files.pythonhosted.org/packages/78/d1/8e225ff7113bf81545cfdcd79eef124a7b7064a0bba53605ff39590b95c2/xxhash-3.6.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c6e193e9f56e4ca4923c61238cdaced324f0feac782544eb4c6d55ad5cc99ddd", size = 210541, upload-time = "2025-10-02T14:35:48.301Z" }, + { url = "https://files.pythonhosted.org/packages/6f/58/0f89d149f0bad89def1a8dd38feb50ccdeb643d9797ec84707091d4cb494/xxhash-3.6.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:9176dcaddf4ca963d4deb93866d739a343c01c969231dbe21680e13a5d1a5bf0", size = 198305, upload-time = "2025-10-02T14:35:49.584Z" }, + { url = "https://files.pythonhosted.org/packages/11/38/5eab81580703c4df93feb5f32ff8fa7fe1e2c51c1f183ee4e48d4bb9d3d7/xxhash-3.6.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:c1ce4009c97a752e682b897aa99aef84191077a9433eb237774689f14f8ec152", size = 210848, upload-time = "2025-10-02T14:35:50.877Z" }, + { url = "https://files.pythonhosted.org/packages/5e/6b/953dc4b05c3ce678abca756416e4c130d2382f877a9c30a20d08ee6a77c0/xxhash-3.6.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:8cb2f4f679b01513b7adbb9b1b2f0f9cdc31b70007eaf9d59d0878809f385b11", size = 414142, upload-time = "2025-10-02T14:35:52.15Z" }, + { url = "https://files.pythonhosted.org/packages/08/a9/238ec0d4e81a10eb5026d4a6972677cbc898ba6c8b9dbaec12ae001b1b35/xxhash-3.6.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:653a91d7c2ab54a92c19ccf43508b6a555440b9be1bc8be553376778be7f20b5", size = 191547, upload-time = "2025-10-02T14:35:53.547Z" }, + { url = "https://files.pythonhosted.org/packages/f1/ee/3cf8589e06c2164ac77c3bf0aa127012801128f1feebf2a079272da5737c/xxhash-3.6.0-cp314-cp314-win32.whl", hash = "sha256:a756fe893389483ee8c394d06b5ab765d96e68fbbfe6fde7aa17e11f5720559f", size = 31214, upload-time = "2025-10-02T14:35:54.746Z" }, + { url = "https://files.pythonhosted.org/packages/02/5d/a19552fbc6ad4cb54ff953c3908bbc095f4a921bc569433d791f755186f1/xxhash-3.6.0-cp314-cp314-win_amd64.whl", hash = "sha256:39be8e4e142550ef69629c9cd71b88c90e9a5db703fecbcf265546d9536ca4ad", size = 32290, upload-time = "2025-10-02T14:35:55.791Z" }, + { url = "https://files.pythonhosted.org/packages/b1/11/dafa0643bc30442c887b55baf8e73353a344ee89c1901b5a5c54a6c17d39/xxhash-3.6.0-cp314-cp314-win_arm64.whl", hash = "sha256:25915e6000338999236f1eb68a02a32c3275ac338628a7eaa5a269c401995679", size = 28795, upload-time = "2025-10-02T14:35:57.162Z" }, + { url = "https://files.pythonhosted.org/packages/2c/db/0e99732ed7f64182aef4a6fb145e1a295558deec2a746265dcdec12d191e/xxhash-3.6.0-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:c5294f596a9017ca5a3e3f8884c00b91ab2ad2933cf288f4923c3fd4346cf3d4", size = 32955, upload-time = "2025-10-02T14:35:58.267Z" }, + { url = "https://files.pythonhosted.org/packages/55/f4/2a7c3c68e564a099becfa44bb3d398810cc0ff6749b0d3cb8ccb93f23c14/xxhash-3.6.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1cf9dcc4ab9cff01dfbba78544297a3a01dafd60f3bde4e2bfd016cf7e4ddc67", size = 31072, upload-time = "2025-10-02T14:35:59.382Z" }, + { url = "https://files.pythonhosted.org/packages/c6/d9/72a29cddc7250e8a5819dad5d466facb5dc4c802ce120645630149127e73/xxhash-3.6.0-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:01262da8798422d0685f7cef03b2bd3f4f46511b02830861df548d7def4402ad", size = 196579, upload-time = "2025-10-02T14:36:00.838Z" }, + { url = "https://files.pythonhosted.org/packages/63/93/b21590e1e381040e2ca305a884d89e1c345b347404f7780f07f2cdd47ef4/xxhash-3.6.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:51a73fb7cb3a3ead9f7a8b583ffd9b8038e277cdb8cb87cf890e88b3456afa0b", size = 215854, upload-time = "2025-10-02T14:36:02.207Z" }, + { url = "https://files.pythonhosted.org/packages/ce/b8/edab8a7d4fa14e924b29be877d54155dcbd8b80be85ea00d2be3413a9ed4/xxhash-3.6.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:b9c6df83594f7df8f7f708ce5ebeacfc69f72c9fbaaababf6cf4758eaada0c9b", size = 214965, upload-time = "2025-10-02T14:36:03.507Z" }, + { url = "https://files.pythonhosted.org/packages/27/67/dfa980ac7f0d509d54ea0d5a486d2bb4b80c3f1bb22b66e6a05d3efaf6c0/xxhash-3.6.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:627f0af069b0ea56f312fd5189001c24578868643203bca1abbc2c52d3a6f3ca", size = 448484, upload-time = "2025-10-02T14:36:04.828Z" }, + { url = "https://files.pythonhosted.org/packages/8c/63/8ffc2cc97e811c0ca5d00ab36604b3ea6f4254f20b7bc658ca825ce6c954/xxhash-3.6.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:aa912c62f842dfd013c5f21a642c9c10cd9f4c4e943e0af83618b4a404d9091a", size = 196162, upload-time = "2025-10-02T14:36:06.182Z" }, + { url = "https://files.pythonhosted.org/packages/4b/77/07f0e7a3edd11a6097e990f6e5b815b6592459cb16dae990d967693e6ea9/xxhash-3.6.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:b465afd7909db30168ab62afe40b2fcf79eedc0b89a6c0ab3123515dc0df8b99", size = 213007, upload-time = "2025-10-02T14:36:07.733Z" }, + { url = "https://files.pythonhosted.org/packages/ae/d8/bc5fa0d152837117eb0bef6f83f956c509332ce133c91c63ce07ee7c4873/xxhash-3.6.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:a881851cf38b0a70e7c4d3ce81fc7afd86fbc2a024f4cfb2a97cf49ce04b75d3", size = 200956, upload-time = "2025-10-02T14:36:09.106Z" }, + { url = "https://files.pythonhosted.org/packages/26/a5/d749334130de9411783873e9b98ecc46688dad5db64ca6e04b02acc8b473/xxhash-3.6.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:9b3222c686a919a0f3253cfc12bb118b8b103506612253b5baeaac10d8027cf6", size = 213401, upload-time = "2025-10-02T14:36:10.585Z" }, + { url = "https://files.pythonhosted.org/packages/89/72/abed959c956a4bfc72b58c0384bb7940663c678127538634d896b1195c10/xxhash-3.6.0-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:c5aa639bc113e9286137cec8fadc20e9cd732b2cc385c0b7fa673b84fc1f2a93", size = 417083, upload-time = "2025-10-02T14:36:12.276Z" }, + { url = "https://files.pythonhosted.org/packages/0c/b3/62fd2b586283b7d7d665fb98e266decadf31f058f1cf6c478741f68af0cb/xxhash-3.6.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5c1343d49ac102799905e115aee590183c3921d475356cb24b4de29a4bc56518", size = 193913, upload-time = "2025-10-02T14:36:14.025Z" }, + { url = "https://files.pythonhosted.org/packages/9a/9a/c19c42c5b3f5a4aad748a6d5b4f23df3bed7ee5445accc65a0fb3ff03953/xxhash-3.6.0-cp314-cp314t-win32.whl", hash = "sha256:5851f033c3030dd95c086b4a36a2683c2ff4a799b23af60977188b057e467119", size = 31586, upload-time = "2025-10-02T14:36:15.603Z" }, + { url = "https://files.pythonhosted.org/packages/03/d6/4cc450345be9924fd5dc8c590ceda1db5b43a0a889587b0ae81a95511360/xxhash-3.6.0-cp314-cp314t-win_amd64.whl", hash = "sha256:0444e7967dac37569052d2409b00a8860c2135cff05502df4da80267d384849f", size = 32526, upload-time = "2025-10-02T14:36:16.708Z" }, + { url = "https://files.pythonhosted.org/packages/0f/c9/7243eb3f9eaabd1a88a5a5acadf06df2d83b100c62684b7425c6a11bcaa8/xxhash-3.6.0-cp314-cp314t-win_arm64.whl", hash = "sha256:bb79b1e63f6fd84ec778a4b1916dfe0a7c3fdb986c06addd5db3a0d413819d95", size = 28898, upload-time = "2025-10-02T14:36:17.843Z" }, +] + +[[package]] +name = "yarl" +version = "1.23.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "multidict" }, + { name = "propcache" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/23/6e/beb1beec874a72f23815c1434518bfc4ed2175065173fb138c3705f658d4/yarl-1.23.0.tar.gz", hash = "sha256:53b1ea6ca88ebd4420379c330aea57e258408dd0df9af0992e5de2078dc9f5d5", size = 194676, upload-time = "2026-03-01T22:07:53.373Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/8a/94615bc31022f711add374097ad4144d569e95ff3c38d39215d07ac153a0/yarl-1.23.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:1932b6b8bba8d0160a9d1078aae5838a66039e8832d41d2992daa9a3a08f7860", size = 124737, upload-time = "2026-03-01T22:05:12.897Z" }, + { url = "https://files.pythonhosted.org/packages/e3/6f/c6554045d59d64052698add01226bc867b52fe4a12373415d7991fdca95d/yarl-1.23.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:411225bae281f114067578891bc75534cfb3d92a3b4dfef7a6ca78ba354e6069", size = 87029, upload-time = "2026-03-01T22:05:14.376Z" }, + { url = "https://files.pythonhosted.org/packages/19/2a/725ecc166d53438bc88f76822ed4b1e3b10756e790bafd7b523fe97c322d/yarl-1.23.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:13a563739ae600a631c36ce096615fe307f131344588b0bc0daec108cdb47b25", size = 86310, upload-time = "2026-03-01T22:05:15.71Z" }, + { url = "https://files.pythonhosted.org/packages/99/30/58260ed98e6ff7f90ba84442c1ddd758c9170d70327394a6227b310cd60f/yarl-1.23.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9cbf44c5cb4a7633d078788e1b56387e3d3cf2b8139a3be38040b22d6c3221c8", size = 97587, upload-time = "2026-03-01T22:05:17.384Z" }, + { url = "https://files.pythonhosted.org/packages/76/0a/8b08aac08b50682e65759f7f8dde98ae8168f72487e7357a5d684c581ef9/yarl-1.23.0-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:53ad387048f6f09a8969631e4de3f1bf70c50e93545d64af4f751b2498755072", size = 92528, upload-time = "2026-03-01T22:05:18.804Z" }, + { url = "https://files.pythonhosted.org/packages/52/07/0b7179101fe5f8385ec6c6bb5d0cb9f76bd9fb4a769591ab6fb5cdbfc69a/yarl-1.23.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4a59ba56f340334766f3a4442e0efd0af895fae9e2b204741ef885c446b3a1a8", size = 105339, upload-time = "2026-03-01T22:05:20.235Z" }, + { url = "https://files.pythonhosted.org/packages/d3/8a/36d82869ab5ec829ca8574dfcb92b51286fcfb1e9c7a73659616362dc880/yarl-1.23.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:803a3c3ce4acc62eaf01eaca1208dcf0783025ef27572c3336502b9c232005e7", size = 105061, upload-time = "2026-03-01T22:05:22.268Z" }, + { url = "https://files.pythonhosted.org/packages/66/3e/868e5c3364b6cee19ff3e1a122194fa4ce51def02c61023970442162859e/yarl-1.23.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a3d2bff8f37f8d0f96c7ec554d16945050d54462d6e95414babaa18bfafc7f51", size = 100132, upload-time = "2026-03-01T22:05:23.638Z" }, + { url = "https://files.pythonhosted.org/packages/cf/26/9c89acf82f08a52cb52d6d39454f8d18af15f9d386a23795389d1d423823/yarl-1.23.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c75eb09e8d55bceb4367e83496ff8ef2bc7ea6960efb38e978e8073ea59ecb67", size = 99289, upload-time = "2026-03-01T22:05:25.749Z" }, + { url = "https://files.pythonhosted.org/packages/6f/54/5b0db00d2cb056922356104468019c0a132e89c8d3ab67d8ede9f4483d2a/yarl-1.23.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:877b0738624280e34c55680d6054a307aa94f7d52fa0e3034a9cc6e790871da7", size = 96950, upload-time = "2026-03-01T22:05:27.318Z" }, + { url = "https://files.pythonhosted.org/packages/f6/40/10fa93811fd439341fad7e0718a86aca0de9548023bbb403668d6555acab/yarl-1.23.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:b5405bb8f0e783a988172993cfc627e4d9d00432d6bbac65a923041edacf997d", size = 93960, upload-time = "2026-03-01T22:05:28.738Z" }, + { url = "https://files.pythonhosted.org/packages/bc/d2/8ae2e6cd77d0805f4526e30ec43b6f9a3dfc542d401ac4990d178e4bf0cf/yarl-1.23.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:1c3a3598a832590c5a3ce56ab5576361b5688c12cb1d39429cf5dba30b510760", size = 104703, upload-time = "2026-03-01T22:05:30.438Z" }, + { url = "https://files.pythonhosted.org/packages/2f/0c/b3ceacf82c3fe21183ce35fa2acf5320af003d52bc1fcf5915077681142e/yarl-1.23.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:8419ebd326430d1cbb7efb5292330a2cf39114e82df5cc3d83c9a0d5ebeaf2f2", size = 98325, upload-time = "2026-03-01T22:05:31.835Z" }, + { url = "https://files.pythonhosted.org/packages/9d/e0/12900edd28bdab91a69bd2554b85ad7b151f64e8b521fe16f9ad2f56477a/yarl-1.23.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:be61f6fff406ca40e3b1d84716fde398fc08bc63dd96d15f3a14230a0973ed86", size = 105067, upload-time = "2026-03-01T22:05:33.358Z" }, + { url = "https://files.pythonhosted.org/packages/15/61/74bb1182cf79c9bbe4eb6b1f14a57a22d7a0be5e9cedf8e2d5c2086474c3/yarl-1.23.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3ceb13c5c858d01321b5d9bb65e4cf37a92169ea470b70fec6f236b2c9dd7e34", size = 100285, upload-time = "2026-03-01T22:05:35.4Z" }, + { url = "https://files.pythonhosted.org/packages/69/7f/cd5ef733f2550de6241bd8bd8c3febc78158b9d75f197d9c7baa113436af/yarl-1.23.0-cp312-cp312-win32.whl", hash = "sha256:fffc45637bcd6538de8b85f51e3df3223e4ad89bccbfca0481c08c7fc8b7ed7d", size = 82359, upload-time = "2026-03-01T22:05:36.811Z" }, + { url = "https://files.pythonhosted.org/packages/f5/be/25216a49daeeb7af2bec0db22d5e7df08ed1d7c9f65d78b14f3b74fd72fc/yarl-1.23.0-cp312-cp312-win_amd64.whl", hash = "sha256:f69f57305656a4852f2a7203efc661d8c042e6cc67f7acd97d8667fb448a426e", size = 87674, upload-time = "2026-03-01T22:05:38.171Z" }, + { url = "https://files.pythonhosted.org/packages/d2/35/aeab955d6c425b227d5b7247eafb24f2653fedc32f95373a001af5dfeb9e/yarl-1.23.0-cp312-cp312-win_arm64.whl", hash = "sha256:6e87a6e8735b44816e7db0b2fbc9686932df473c826b0d9743148432e10bb9b9", size = 81879, upload-time = "2026-03-01T22:05:40.006Z" }, + { url = "https://files.pythonhosted.org/packages/9a/4b/a0a6e5d0ee8a2f3a373ddef8a4097d74ac901ac363eea1440464ccbe0898/yarl-1.23.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:16c6994ac35c3e74fb0ae93323bf8b9c2a9088d55946109489667c510a7d010e", size = 123796, upload-time = "2026-03-01T22:05:41.412Z" }, + { url = "https://files.pythonhosted.org/packages/67/b6/8925d68af039b835ae876db5838e82e76ec87b9782ecc97e192b809c4831/yarl-1.23.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:4a42e651629dafb64fd5b0286a3580613702b5809ad3f24934ea87595804f2c5", size = 86547, upload-time = "2026-03-01T22:05:42.841Z" }, + { url = "https://files.pythonhosted.org/packages/ae/50/06d511cc4b8e0360d3c94af051a768e84b755c5eb031b12adaaab6dec6e5/yarl-1.23.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:7c6b9461a2a8b47c65eef63bb1c76a4f1c119618ffa99ea79bc5bb1e46c5821b", size = 85854, upload-time = "2026-03-01T22:05:44.85Z" }, + { url = "https://files.pythonhosted.org/packages/c4/f4/4e30b250927ffdab4db70da08b9b8d2194d7c7b400167b8fbeca1e4701ca/yarl-1.23.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2569b67d616eab450d262ca7cb9f9e19d2f718c70a8b88712859359d0ab17035", size = 98351, upload-time = "2026-03-01T22:05:46.836Z" }, + { url = "https://files.pythonhosted.org/packages/86/fc/4118c5671ea948208bdb1492d8b76bdf1453d3e73df051f939f563e7dcc5/yarl-1.23.0-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:e9d9a4d06d3481eab79803beb4d9bd6f6a8e781ec078ac70d7ef2dcc29d1bea5", size = 92711, upload-time = "2026-03-01T22:05:48.316Z" }, + { url = "https://files.pythonhosted.org/packages/56/11/1ed91d42bd9e73c13dc9e7eb0dd92298d75e7ac4dd7f046ad0c472e231cd/yarl-1.23.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f514f6474e04179d3d33175ed3f3e31434d3130d42ec153540d5b157deefd735", size = 106014, upload-time = "2026-03-01T22:05:50.028Z" }, + { url = "https://files.pythonhosted.org/packages/ce/c9/74e44e056a23fbc33aca71779ef450ca648a5bc472bdad7a82339918f818/yarl-1.23.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:fda207c815b253e34f7e1909840fd14299567b1c0eb4908f8c2ce01a41265401", size = 105557, upload-time = "2026-03-01T22:05:51.416Z" }, + { url = "https://files.pythonhosted.org/packages/66/fe/b1e10b08d287f518994f1e2ff9b6d26f0adeecd8dd7d533b01bab29a3eda/yarl-1.23.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:34b6cf500e61c90f305094911f9acc9c86da1a05a7a3f5be9f68817043f486e4", size = 101559, upload-time = "2026-03-01T22:05:52.872Z" }, + { url = "https://files.pythonhosted.org/packages/72/59/c5b8d94b14e3d3c2a9c20cb100119fd534ab5a14b93673ab4cc4a4141ea5/yarl-1.23.0-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:d7504f2b476d21653e4d143f44a175f7f751cd41233525312696c76aa3dbb23f", size = 100502, upload-time = "2026-03-01T22:05:54.954Z" }, + { url = "https://files.pythonhosted.org/packages/77/4f/96976cb54cbfc5c9fd73ed4c51804f92f209481d1fb190981c0f8a07a1d7/yarl-1.23.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:578110dd426f0d209d1509244e6d4a3f1a3e9077655d98c5f22583d63252a08a", size = 98027, upload-time = "2026-03-01T22:05:56.409Z" }, + { url = "https://files.pythonhosted.org/packages/63/6e/904c4f476471afdbad6b7e5b70362fb5810e35cd7466529a97322b6f5556/yarl-1.23.0-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:609d3614d78d74ebe35f54953c5bbd2ac647a7ddb9c30a5d877580f5e86b22f2", size = 95369, upload-time = "2026-03-01T22:05:58.141Z" }, + { url = "https://files.pythonhosted.org/packages/9d/40/acfcdb3b5f9d68ef499e39e04d25e141fe90661f9d54114556cf83be8353/yarl-1.23.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:4966242ec68afc74c122f8459abd597afd7d8a60dc93d695c1334c5fd25f762f", size = 105565, upload-time = "2026-03-01T22:06:00.286Z" }, + { url = "https://files.pythonhosted.org/packages/5e/c6/31e28f3a6ba2869c43d124f37ea5260cac9c9281df803c354b31f4dd1f3c/yarl-1.23.0-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:e0fd068364a6759bc794459f0a735ab151d11304346332489c7972bacbe9e72b", size = 99813, upload-time = "2026-03-01T22:06:01.712Z" }, + { url = "https://files.pythonhosted.org/packages/08/1f/6f65f59e72d54aa467119b63fc0b0b1762eff0232db1f4720cd89e2f4a17/yarl-1.23.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:39004f0ad156da43e86aa71f44e033de68a44e5a31fc53507b36dd253970054a", size = 105632, upload-time = "2026-03-01T22:06:03.188Z" }, + { url = "https://files.pythonhosted.org/packages/a3/c4/18b178a69935f9e7a338127d5b77d868fdc0f0e49becd286d51b3a18c61d/yarl-1.23.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:e5723c01a56c5028c807c701aa66722916d2747ad737a046853f6c46f4875543", size = 101895, upload-time = "2026-03-01T22:06:04.651Z" }, + { url = "https://files.pythonhosted.org/packages/8f/54/f5b870b5505663911dba950a8e4776a0dbd51c9c54c0ae88e823e4b874a0/yarl-1.23.0-cp313-cp313-win32.whl", hash = "sha256:1b6b572edd95b4fa8df75de10b04bc81acc87c1c7d16bcdd2035b09d30acc957", size = 82356, upload-time = "2026-03-01T22:06:06.04Z" }, + { url = "https://files.pythonhosted.org/packages/7a/84/266e8da36879c6edcd37b02b547e2d9ecdfea776be49598e75696e3316e1/yarl-1.23.0-cp313-cp313-win_amd64.whl", hash = "sha256:baaf55442359053c7d62f6f8413a62adba3205119bcb6f49594894d8be47e5e3", size = 87515, upload-time = "2026-03-01T22:06:08.107Z" }, + { url = "https://files.pythonhosted.org/packages/00/fd/7e1c66efad35e1649114fa13f17485f62881ad58edeeb7f49f8c5e748bf9/yarl-1.23.0-cp313-cp313-win_arm64.whl", hash = "sha256:fb4948814a2a98e3912505f09c9e7493b1506226afb1f881825368d6fb776ee3", size = 81785, upload-time = "2026-03-01T22:06:10.181Z" }, + { url = "https://files.pythonhosted.org/packages/9c/fc/119dd07004f17ea43bb91e3ece6587759edd7519d6b086d16bfbd3319982/yarl-1.23.0-cp313-cp313t-macosx_10_13_universal2.whl", hash = "sha256:aecfed0b41aa72b7881712c65cf764e39ce2ec352324f5e0837c7048d9e6daaa", size = 130719, upload-time = "2026-03-01T22:06:11.708Z" }, + { url = "https://files.pythonhosted.org/packages/e6/0d/9f2348502fbb3af409e8f47730282cd6bc80dec6630c1e06374d882d6eb2/yarl-1.23.0-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:a41bcf68efd19073376eb8cf948b8d9be0af26256403e512bb18f3966f1f9120", size = 89690, upload-time = "2026-03-01T22:06:13.429Z" }, + { url = "https://files.pythonhosted.org/packages/50/93/e88f3c80971b42cfc83f50a51b9d165a1dbf154b97005f2994a79f212a07/yarl-1.23.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:cde9a2ecd91668bcb7f077c4966d8ceddb60af01b52e6e3e2680e4cf00ad1a59", size = 89851, upload-time = "2026-03-01T22:06:15.53Z" }, + { url = "https://files.pythonhosted.org/packages/1c/07/61c9dd8ba8f86473263b4036f70fb594c09e99c0d9737a799dfd8bc85651/yarl-1.23.0-cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5023346c4ee7992febc0068e7593de5fa2bf611848c08404b35ebbb76b1b0512", size = 95874, upload-time = "2026-03-01T22:06:17.553Z" }, + { url = "https://files.pythonhosted.org/packages/9e/e9/f9ff8ceefba599eac6abddcfb0b3bee9b9e636e96dbf54342a8577252379/yarl-1.23.0-cp313-cp313t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:d1009abedb49ae95b136a8904a3f71b342f849ffeced2d3747bf29caeda218c4", size = 88710, upload-time = "2026-03-01T22:06:19.004Z" }, + { url = "https://files.pythonhosted.org/packages/eb/78/0231bfcc5d4c8eec220bc2f9ef82cb4566192ea867a7c5b4148f44f6cbcd/yarl-1.23.0-cp313-cp313t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a8d00f29b42f534cc8aa3931cfe773b13b23e561e10d2b26f27a8d309b0e82a1", size = 101033, upload-time = "2026-03-01T22:06:21.203Z" }, + { url = "https://files.pythonhosted.org/packages/cd/9b/30ea5239a61786f18fd25797151a17fbb3be176977187a48d541b5447dd4/yarl-1.23.0-cp313-cp313t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:95451e6ce06c3e104556d73b559f5da6c34a069b6b62946d3ad66afcd51642ea", size = 100817, upload-time = "2026-03-01T22:06:22.738Z" }, + { url = "https://files.pythonhosted.org/packages/62/e2/a4980481071791bc83bce2b7a1a1f7adcabfa366007518b4b845e92eeee3/yarl-1.23.0-cp313-cp313t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:531ef597132086b6cf96faa7c6c1dcd0361dd5f1694e5cc30375907b9b7d3ea9", size = 97482, upload-time = "2026-03-01T22:06:24.21Z" }, + { url = "https://files.pythonhosted.org/packages/e5/1e/304a00cf5f6100414c4b5a01fc7ff9ee724b62158a08df2f8170dfc72a2d/yarl-1.23.0-cp313-cp313t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:88f9fb0116fbfcefcab70f85cf4b74a2b6ce5d199c41345296f49d974ddb4123", size = 95949, upload-time = "2026-03-01T22:06:25.697Z" }, + { url = "https://files.pythonhosted.org/packages/68/03/093f4055ed4cae649ac53bca3d180bd37102e9e11d048588e9ab0c0108d0/yarl-1.23.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:e7b0460976dc75cb87ad9cc1f9899a4b97751e7d4e77ab840fc9b6d377b8fd24", size = 95839, upload-time = "2026-03-01T22:06:27.309Z" }, + { url = "https://files.pythonhosted.org/packages/b9/28/4c75ebb108f322aa8f917ae10a8ffa4f07cae10a8a627b64e578617df6a0/yarl-1.23.0-cp313-cp313t-musllinux_1_2_armv7l.whl", hash = "sha256:115136c4a426f9da976187d238e84139ff6b51a20839aa6e3720cd1026d768de", size = 90696, upload-time = "2026-03-01T22:06:29.048Z" }, + { url = "https://files.pythonhosted.org/packages/23/9c/42c2e2dd91c1a570402f51bdf066bfdb1241c2240ba001967bad778e77b7/yarl-1.23.0-cp313-cp313t-musllinux_1_2_ppc64le.whl", hash = "sha256:ead11956716a940c1abc816b7df3fa2b84d06eaed8832ca32f5c5e058c65506b", size = 100865, upload-time = "2026-03-01T22:06:30.525Z" }, + { url = "https://files.pythonhosted.org/packages/74/05/1bcd60a8a0a914d462c305137246b6f9d167628d73568505fce3f1cb2e65/yarl-1.23.0-cp313-cp313t-musllinux_1_2_riscv64.whl", hash = "sha256:fe8f8f5e70e6dbdfca9882cd9deaac058729bcf323cf7a58660901e55c9c94f6", size = 96234, upload-time = "2026-03-01T22:06:32.692Z" }, + { url = "https://files.pythonhosted.org/packages/90/b2/f52381aac396d6778ce516b7bc149c79e65bfc068b5de2857ab69eeea3b7/yarl-1.23.0-cp313-cp313t-musllinux_1_2_s390x.whl", hash = "sha256:a0e317df055958a0c1e79e5d2aa5a5eaa4a6d05a20d4b0c9c3f48918139c9fc6", size = 100295, upload-time = "2026-03-01T22:06:34.268Z" }, + { url = "https://files.pythonhosted.org/packages/e5/e8/638bae5bbf1113a659b2435d8895474598afe38b4a837103764f603aba56/yarl-1.23.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:6f0fd84de0c957b2d280143522c4f91a73aada1923caee763e24a2b3fda9f8a5", size = 97784, upload-time = "2026-03-01T22:06:35.864Z" }, + { url = "https://files.pythonhosted.org/packages/80/25/a3892b46182c586c202629fc2159aa13975d3741d52ebd7347fd501d48d5/yarl-1.23.0-cp313-cp313t-win32.whl", hash = "sha256:93a784271881035ab4406a172edb0faecb6e7d00f4b53dc2f55919d6c9688595", size = 88313, upload-time = "2026-03-01T22:06:37.39Z" }, + { url = "https://files.pythonhosted.org/packages/43/68/8c5b36aa5178900b37387937bc2c2fe0e9505537f713495472dcf6f6fccc/yarl-1.23.0-cp313-cp313t-win_amd64.whl", hash = "sha256:dd00607bffbf30250fe108065f07453ec124dbf223420f57f5e749b04295e090", size = 94932, upload-time = "2026-03-01T22:06:39.579Z" }, + { url = "https://files.pythonhosted.org/packages/c6/cc/d79ba8292f51f81f4dc533a8ccfb9fc6992cabf0998ed3245de7589dc07c/yarl-1.23.0-cp313-cp313t-win_arm64.whl", hash = "sha256:ac09d42f48f80c9ee1635b2fcaa819496a44502737660d3c0f2ade7526d29144", size = 84786, upload-time = "2026-03-01T22:06:41.988Z" }, + { url = "https://files.pythonhosted.org/packages/90/98/b85a038d65d1b92c3903ab89444f48d3cee490a883477b716d7a24b1a78c/yarl-1.23.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:21d1b7305a71a15b4794b5ff22e8eef96ff4a6d7f9657155e5aa419444b28912", size = 124455, upload-time = "2026-03-01T22:06:43.615Z" }, + { url = "https://files.pythonhosted.org/packages/39/54/bc2b45559f86543d163b6e294417a107bb87557609007c007ad889afec18/yarl-1.23.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:85610b4f27f69984932a7abbe52703688de3724d9f72bceb1cca667deff27474", size = 86752, upload-time = "2026-03-01T22:06:45.425Z" }, + { url = "https://files.pythonhosted.org/packages/24/f9/e8242b68362bffe6fb536c8db5076861466fc780f0f1b479fc4ffbebb128/yarl-1.23.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:23f371bd662cf44a7630d4d113101eafc0cfa7518a2760d20760b26021454719", size = 86291, upload-time = "2026-03-01T22:06:46.974Z" }, + { url = "https://files.pythonhosted.org/packages/ea/d8/d1cb2378c81dd729e98c716582b1ccb08357e8488e4c24714658cc6630e8/yarl-1.23.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:c4a80f77dc1acaaa61f0934176fccca7096d9b1ff08c8ba9cddf5ae034a24319", size = 99026, upload-time = "2026-03-01T22:06:48.459Z" }, + { url = "https://files.pythonhosted.org/packages/0a/ff/7196790538f31debe3341283b5b0707e7feb947620fc5e8236ef28d44f72/yarl-1.23.0-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:bd654fad46d8d9e823afbb4f87c79160b5a374ed1ff5bde24e542e6ba8f41434", size = 92355, upload-time = "2026-03-01T22:06:50.306Z" }, + { url = "https://files.pythonhosted.org/packages/c1/56/25d58c3eddde825890a5fe6aa1866228377354a3c39262235234ab5f616b/yarl-1.23.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:682bae25f0a0dd23a056739f23a134db9f52a63e2afd6bfb37ddc76292bbd723", size = 106417, upload-time = "2026-03-01T22:06:52.1Z" }, + { url = "https://files.pythonhosted.org/packages/51/8a/882c0e7bc8277eb895b31bce0138f51a1ba551fc2e1ec6753ffc1e7c1377/yarl-1.23.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a82836cab5f197a0514235aaf7ffccdc886ccdaa2324bc0aafdd4ae898103039", size = 106422, upload-time = "2026-03-01T22:06:54.424Z" }, + { url = "https://files.pythonhosted.org/packages/42/2b/fef67d616931055bf3d6764885990a3ac647d68734a2d6a9e1d13de437a2/yarl-1.23.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1c57676bdedc94cd3bc37724cf6f8cd2779f02f6aba48de45feca073e714fe52", size = 101915, upload-time = "2026-03-01T22:06:55.895Z" }, + { url = "https://files.pythonhosted.org/packages/18/6a/530e16aebce27c5937920f3431c628a29a4b6b430fab3fd1c117b26ff3f6/yarl-1.23.0-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c7f8dc16c498ff06497c015642333219871effba93e4a2e8604a06264aca5c5c", size = 100690, upload-time = "2026-03-01T22:06:58.21Z" }, + { url = "https://files.pythonhosted.org/packages/88/08/93749219179a45e27b036e03260fda05190b911de8e18225c294ac95bbc9/yarl-1.23.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:5ee586fb17ff8f90c91cf73c6108a434b02d69925f44f5f8e0d7f2f260607eae", size = 98750, upload-time = "2026-03-01T22:06:59.794Z" }, + { url = "https://files.pythonhosted.org/packages/d9/cf/ea424a004969f5d81a362110a6ac1496d79efdc6d50c2c4b2e3ea0fc2519/yarl-1.23.0-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:17235362f580149742739cc3828b80e24029d08cbb9c4bda0242c7b5bc610a8e", size = 94685, upload-time = "2026-03-01T22:07:01.375Z" }, + { url = "https://files.pythonhosted.org/packages/e2/b7/14341481fe568e2b0408bcf1484c652accafe06a0ade9387b5d3fd9df446/yarl-1.23.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:0793e2bd0cf14234983bbb371591e6bea9e876ddf6896cdcc93450996b0b5c85", size = 106009, upload-time = "2026-03-01T22:07:03.151Z" }, + { url = "https://files.pythonhosted.org/packages/0a/e6/5c744a9b54f4e8007ad35bce96fbc9218338e84812d36f3390cea616881a/yarl-1.23.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:3650dc2480f94f7116c364096bc84b1d602f44224ef7d5c7208425915c0475dd", size = 100033, upload-time = "2026-03-01T22:07:04.701Z" }, + { url = "https://files.pythonhosted.org/packages/0c/23/e3bfc188d0b400f025bc49d99793d02c9abe15752138dcc27e4eaf0c4a9e/yarl-1.23.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:f40e782d49630ad384db66d4d8b73ff4f1b8955dc12e26b09a3e3af064b3b9d6", size = 106483, upload-time = "2026-03-01T22:07:06.231Z" }, + { url = "https://files.pythonhosted.org/packages/72/42/f0505f949a90b3f8b7a363d6cbdf398f6e6c58946d85c6d3a3bc70595b26/yarl-1.23.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:94f8575fbdf81749008d980c17796097e645574a3b8c28ee313931068dad14fe", size = 102175, upload-time = "2026-03-01T22:07:08.4Z" }, + { url = "https://files.pythonhosted.org/packages/aa/65/b39290f1d892a9dd671d1c722014ca062a9c35d60885d57e5375db0404b5/yarl-1.23.0-cp314-cp314-win32.whl", hash = "sha256:c8aa34a5c864db1087d911a0b902d60d203ea3607d91f615acd3f3108ac32169", size = 83871, upload-time = "2026-03-01T22:07:09.968Z" }, + { url = "https://files.pythonhosted.org/packages/a9/5b/9b92f54c784c26e2a422e55a8d2607ab15b7ea3349e28359282f84f01d43/yarl-1.23.0-cp314-cp314-win_amd64.whl", hash = "sha256:63e92247f383c85ab00dd0091e8c3fa331a96e865459f5ee80353c70a4a42d70", size = 89093, upload-time = "2026-03-01T22:07:11.501Z" }, + { url = "https://files.pythonhosted.org/packages/e0/7d/8a84dc9381fd4412d5e7ff04926f9865f6372b4c2fd91e10092e65d29eb8/yarl-1.23.0-cp314-cp314-win_arm64.whl", hash = "sha256:70efd20be968c76ece7baa8dafe04c5be06abc57f754d6f36f3741f7aa7a208e", size = 83384, upload-time = "2026-03-01T22:07:13.069Z" }, + { url = "https://files.pythonhosted.org/packages/dd/8d/d2fad34b1c08aa161b74394183daa7d800141aaaee207317e82c790b418d/yarl-1.23.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:9a18d6f9359e45722c064c97464ec883eb0e0366d33eda61cb19a244bf222679", size = 131019, upload-time = "2026-03-01T22:07:14.903Z" }, + { url = "https://files.pythonhosted.org/packages/19/ff/33009a39d3ccf4b94d7d7880dfe17fb5816c5a4fe0096d9b56abceea9ac7/yarl-1.23.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:2803ed8b21ca47a43da80a6fd1ed3019d30061f7061daa35ac54f63933409412", size = 89894, upload-time = "2026-03-01T22:07:17.372Z" }, + { url = "https://files.pythonhosted.org/packages/0c/f1/dab7ac5e7306fb79c0190766a3c00b4cb8d09a1f390ded68c85a5934faf5/yarl-1.23.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:394906945aa8b19fc14a61cf69743a868bb8c465efe85eee687109cc540b98f4", size = 89979, upload-time = "2026-03-01T22:07:19.361Z" }, + { url = "https://files.pythonhosted.org/packages/aa/b1/08e95f3caee1fad6e65017b9f26c1d79877b502622d60e517de01e72f95d/yarl-1.23.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:71d006bee8397a4a89f469b8deb22469fe7508132d3c17fa6ed871e79832691c", size = 95943, upload-time = "2026-03-01T22:07:21.266Z" }, + { url = "https://files.pythonhosted.org/packages/c0/cc/6409f9018864a6aa186c61175b977131f373f1988e198e031236916e87e4/yarl-1.23.0-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:62694e275c93d54f7ccedcfef57d42761b2aad5234b6be1f3e3026cae4001cd4", size = 88786, upload-time = "2026-03-01T22:07:23.129Z" }, + { url = "https://files.pythonhosted.org/packages/76/40/cc22d1d7714b717fde2006fad2ced5efe5580606cb059ae42117542122f3/yarl-1.23.0-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a31de1613658308efdb21ada98cbc86a97c181aa050ba22a808120bb5be3ab94", size = 101307, upload-time = "2026-03-01T22:07:24.689Z" }, + { url = "https://files.pythonhosted.org/packages/8f/0d/476c38e85ddb4c6ec6b20b815bdd779aa386a013f3d8b85516feee55c8dc/yarl-1.23.0-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:fb1e8b8d66c278b21d13b0a7ca22c41dd757a7c209c6b12c313e445c31dd3b28", size = 100904, upload-time = "2026-03-01T22:07:26.287Z" }, + { url = "https://files.pythonhosted.org/packages/72/32/0abe4a76d59adf2081dcb0397168553ece4616ada1c54d1c49d8936c74f8/yarl-1.23.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:50f9d8d531dfb767c565f348f33dd5139a6c43f5cbdf3f67da40d54241df93f6", size = 97728, upload-time = "2026-03-01T22:07:27.906Z" }, + { url = "https://files.pythonhosted.org/packages/b7/35/7b30f4810fba112f60f5a43237545867504e15b1c7647a785fbaf588fac2/yarl-1.23.0-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:575aa4405a656e61a540f4a80eaa5260f2a38fff7bfdc4b5f611840d76e9e277", size = 95964, upload-time = "2026-03-01T22:07:30.198Z" }, + { url = "https://files.pythonhosted.org/packages/2d/86/ed7a73ab85ef00e8bb70b0cb5421d8a2a625b81a333941a469a6f4022828/yarl-1.23.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:041b1a4cefacf65840b4e295c6985f334ba83c30607441ae3cf206a0eed1a2e4", size = 95882, upload-time = "2026-03-01T22:07:32.132Z" }, + { url = "https://files.pythonhosted.org/packages/19/90/d56967f61a29d8498efb7afb651e0b2b422a1e9b47b0ab5f4e40a19b699b/yarl-1.23.0-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:d38c1e8231722c4ce40d7593f28d92b5fc72f3e9774fe73d7e800ec32299f63a", size = 90797, upload-time = "2026-03-01T22:07:34.404Z" }, + { url = "https://files.pythonhosted.org/packages/72/00/8b8f76909259f56647adb1011d7ed8b321bcf97e464515c65016a47ecdf0/yarl-1.23.0-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:d53834e23c015ee83a99377db6e5e37d8484f333edb03bd15b4bc312cc7254fb", size = 101023, upload-time = "2026-03-01T22:07:35.953Z" }, + { url = "https://files.pythonhosted.org/packages/ac/e2/cab11b126fb7d440281b7df8e9ddbe4851e70a4dde47a202b6642586b8d9/yarl-1.23.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:2e27c8841126e017dd2a054a95771569e6070b9ee1b133366d8b31beb5018a41", size = 96227, upload-time = "2026-03-01T22:07:37.594Z" }, + { url = "https://files.pythonhosted.org/packages/c2/9b/2c893e16bfc50e6b2edf76c1a9eb6cb0c744346197e74c65e99ad8d634d0/yarl-1.23.0-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:76855800ac56f878847a09ce6dba727c93ca2d89c9e9d63002d26b916810b0a2", size = 100302, upload-time = "2026-03-01T22:07:39.334Z" }, + { url = "https://files.pythonhosted.org/packages/28/ec/5498c4e3a6d5f1003beb23405671c2eb9cdbf3067d1c80f15eeafe301010/yarl-1.23.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:e09fd068c2e169a7070d83d3bde728a4d48de0549f975290be3c108c02e499b4", size = 98202, upload-time = "2026-03-01T22:07:41.717Z" }, + { url = "https://files.pythonhosted.org/packages/fe/c3/cd737e2d45e70717907f83e146f6949f20cc23cd4bf7b2688727763aa458/yarl-1.23.0-cp314-cp314t-win32.whl", hash = "sha256:73309162a6a571d4cbd3b6a1dcc703c7311843ae0d1578df6f09be4e98df38d4", size = 90558, upload-time = "2026-03-01T22:07:43.433Z" }, + { url = "https://files.pythonhosted.org/packages/e1/19/3774d162f6732d1cfb0b47b4140a942a35ca82bb19b6db1f80e9e7bdc8f8/yarl-1.23.0-cp314-cp314t-win_amd64.whl", hash = "sha256:4503053d296bc6e4cbd1fad61cf3b6e33b939886c4f249ba7c78b602214fabe2", size = 97610, upload-time = "2026-03-01T22:07:45.773Z" }, + { url = "https://files.pythonhosted.org/packages/51/47/3fa2286c3cb162c71cdb34c4224d5745a1ceceb391b2bd9b19b668a8d724/yarl-1.23.0-cp314-cp314t-win_arm64.whl", hash = "sha256:44bb7bef4ea409384e3f8bc36c063d77ea1b8d4a5b2706956c0d6695f07dcc25", size = 86041, upload-time = "2026-03-01T22:07:49.026Z" }, + { url = "https://files.pythonhosted.org/packages/69/68/c8739671f5699c7dc470580a4f821ef37c32c4cb0b047ce223a7f115757f/yarl-1.23.0-py3-none-any.whl", hash = "sha256:a2df6afe50dea8ae15fa34c9f824a3ee958d785fd5d089063d960bae1daa0a3f", size = 48288, upload-time = "2026-03-01T22:07:51.388Z" }, +] + +[[package]] +name = "zstandard" +version = "0.25.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fd/aa/3e0508d5a5dd96529cdc5a97011299056e14c6505b678fd58938792794b1/zstandard-0.25.0.tar.gz", hash = "sha256:7713e1179d162cf5c7906da876ec2ccb9c3a9dcbdffef0cc7f70c3667a205f0b", size = 711513, upload-time = "2025-09-14T22:15:54.002Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/82/fc/f26eb6ef91ae723a03e16eddb198abcfce2bc5a42e224d44cc8b6765e57e/zstandard-0.25.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7b3c3a3ab9daa3eed242d6ecceead93aebbb8f5f84318d82cee643e019c4b73b", size = 795738, upload-time = "2025-09-14T22:16:56.237Z" }, + { url = "https://files.pythonhosted.org/packages/aa/1c/d920d64b22f8dd028a8b90e2d756e431a5d86194caa78e3819c7bf53b4b3/zstandard-0.25.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:913cbd31a400febff93b564a23e17c3ed2d56c064006f54efec210d586171c00", size = 640436, upload-time = "2025-09-14T22:16:57.774Z" }, + { url = "https://files.pythonhosted.org/packages/53/6c/288c3f0bd9fcfe9ca41e2c2fbfd17b2097f6af57b62a81161941f09afa76/zstandard-0.25.0-cp312-cp312-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:011d388c76b11a0c165374ce660ce2c8efa8e5d87f34996aa80f9c0816698b64", size = 5343019, upload-time = "2025-09-14T22:16:59.302Z" }, + { url = "https://files.pythonhosted.org/packages/1e/15/efef5a2f204a64bdb5571e6161d49f7ef0fffdbca953a615efbec045f60f/zstandard-0.25.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:6dffecc361d079bb48d7caef5d673c88c8988d3d33fb74ab95b7ee6da42652ea", size = 5063012, upload-time = "2025-09-14T22:17:01.156Z" }, + { url = "https://files.pythonhosted.org/packages/b7/37/a6ce629ffdb43959e92e87ebdaeebb5ac81c944b6a75c9c47e300f85abdf/zstandard-0.25.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:7149623bba7fdf7e7f24312953bcf73cae103db8cae49f8154dd1eadc8a29ecb", size = 5394148, upload-time = "2025-09-14T22:17:03.091Z" }, + { url = "https://files.pythonhosted.org/packages/e3/79/2bf870b3abeb5c070fe2d670a5a8d1057a8270f125ef7676d29ea900f496/zstandard-0.25.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:6a573a35693e03cf1d67799fd01b50ff578515a8aeadd4595d2a7fa9f3ec002a", size = 5451652, upload-time = "2025-09-14T22:17:04.979Z" }, + { url = "https://files.pythonhosted.org/packages/53/60/7be26e610767316c028a2cbedb9a3beabdbe33e2182c373f71a1c0b88f36/zstandard-0.25.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5a56ba0db2d244117ed744dfa8f6f5b366e14148e00de44723413b2f3938a902", size = 5546993, upload-time = "2025-09-14T22:17:06.781Z" }, + { url = "https://files.pythonhosted.org/packages/85/c7/3483ad9ff0662623f3648479b0380d2de5510abf00990468c286c6b04017/zstandard-0.25.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:10ef2a79ab8e2974e2075fb984e5b9806c64134810fac21576f0668e7ea19f8f", size = 5046806, upload-time = "2025-09-14T22:17:08.415Z" }, + { url = "https://files.pythonhosted.org/packages/08/b3/206883dd25b8d1591a1caa44b54c2aad84badccf2f1de9e2d60a446f9a25/zstandard-0.25.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:aaf21ba8fb76d102b696781bddaa0954b782536446083ae3fdaa6f16b25a1c4b", size = 5576659, upload-time = "2025-09-14T22:17:10.164Z" }, + { url = "https://files.pythonhosted.org/packages/9d/31/76c0779101453e6c117b0ff22565865c54f48f8bd807df2b00c2c404b8e0/zstandard-0.25.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:1869da9571d5e94a85a5e8d57e4e8807b175c9e4a6294e3b66fa4efb074d90f6", size = 4953933, upload-time = "2025-09-14T22:17:11.857Z" }, + { url = "https://files.pythonhosted.org/packages/18/e1/97680c664a1bf9a247a280a053d98e251424af51f1b196c6d52f117c9720/zstandard-0.25.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:809c5bcb2c67cd0ed81e9229d227d4ca28f82d0f778fc5fea624a9def3963f91", size = 5268008, upload-time = "2025-09-14T22:17:13.627Z" }, + { url = "https://files.pythonhosted.org/packages/1e/73/316e4010de585ac798e154e88fd81bb16afc5c5cb1a72eeb16dd37e8024a/zstandard-0.25.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:f27662e4f7dbf9f9c12391cb37b4c4c3cb90ffbd3b1fb9284dadbbb8935fa708", size = 5433517, upload-time = "2025-09-14T22:17:16.103Z" }, + { url = "https://files.pythonhosted.org/packages/5b/60/dd0f8cfa8129c5a0ce3ea6b7f70be5b33d2618013a161e1ff26c2b39787c/zstandard-0.25.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:99c0c846e6e61718715a3c9437ccc625de26593fea60189567f0118dc9db7512", size = 5814292, upload-time = "2025-09-14T22:17:17.827Z" }, + { url = "https://files.pythonhosted.org/packages/fc/5f/75aafd4b9d11b5407b641b8e41a57864097663699f23e9ad4dbb91dc6bfe/zstandard-0.25.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:474d2596a2dbc241a556e965fb76002c1ce655445e4e3bf38e5477d413165ffa", size = 5360237, upload-time = "2025-09-14T22:17:19.954Z" }, + { url = "https://files.pythonhosted.org/packages/ff/8d/0309daffea4fcac7981021dbf21cdb2e3427a9e76bafbcdbdf5392ff99a4/zstandard-0.25.0-cp312-cp312-win32.whl", hash = "sha256:23ebc8f17a03133b4426bcc04aabd68f8236eb78c3760f12783385171b0fd8bd", size = 436922, upload-time = "2025-09-14T22:17:24.398Z" }, + { url = "https://files.pythonhosted.org/packages/79/3b/fa54d9015f945330510cb5d0b0501e8253c127cca7ebe8ba46a965df18c5/zstandard-0.25.0-cp312-cp312-win_amd64.whl", hash = "sha256:ffef5a74088f1e09947aecf91011136665152e0b4b359c42be3373897fb39b01", size = 506276, upload-time = "2025-09-14T22:17:21.429Z" }, + { url = "https://files.pythonhosted.org/packages/ea/6b/8b51697e5319b1f9ac71087b0af9a40d8a6288ff8025c36486e0c12abcc4/zstandard-0.25.0-cp312-cp312-win_arm64.whl", hash = "sha256:181eb40e0b6a29b3cd2849f825e0fa34397f649170673d385f3598ae17cca2e9", size = 462679, upload-time = "2025-09-14T22:17:23.147Z" }, + { url = "https://files.pythonhosted.org/packages/35/0b/8df9c4ad06af91d39e94fa96cc010a24ac4ef1378d3efab9223cc8593d40/zstandard-0.25.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:ec996f12524f88e151c339688c3897194821d7f03081ab35d31d1e12ec975e94", size = 795735, upload-time = "2025-09-14T22:17:26.042Z" }, + { url = "https://files.pythonhosted.org/packages/3f/06/9ae96a3e5dcfd119377ba33d4c42a7d89da1efabd5cb3e366b156c45ff4d/zstandard-0.25.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a1a4ae2dec3993a32247995bdfe367fc3266da832d82f8438c8570f989753de1", size = 640440, upload-time = "2025-09-14T22:17:27.366Z" }, + { url = "https://files.pythonhosted.org/packages/d9/14/933d27204c2bd404229c69f445862454dcc101cd69ef8c6068f15aaec12c/zstandard-0.25.0-cp313-cp313-manylinux2010_i686.manylinux2014_i686.manylinux_2_12_i686.manylinux_2_17_i686.whl", hash = "sha256:e96594a5537722fdfb79951672a2a63aec5ebfb823e7560586f7484819f2a08f", size = 5343070, upload-time = "2025-09-14T22:17:28.896Z" }, + { url = "https://files.pythonhosted.org/packages/6d/db/ddb11011826ed7db9d0e485d13df79b58586bfdec56e5c84a928a9a78c1c/zstandard-0.25.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:bfc4e20784722098822e3eee42b8e576b379ed72cca4a7cb856ae733e62192ea", size = 5063001, upload-time = "2025-09-14T22:17:31.044Z" }, + { url = "https://files.pythonhosted.org/packages/db/00/87466ea3f99599d02a5238498b87bf84a6348290c19571051839ca943777/zstandard-0.25.0-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:457ed498fc58cdc12fc48f7950e02740d4f7ae9493dd4ab2168a47c93c31298e", size = 5394120, upload-time = "2025-09-14T22:17:32.711Z" }, + { url = "https://files.pythonhosted.org/packages/2b/95/fc5531d9c618a679a20ff6c29e2b3ef1d1f4ad66c5e161ae6ff847d102a9/zstandard-0.25.0-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:fd7a5004eb1980d3cefe26b2685bcb0b17989901a70a1040d1ac86f1d898c551", size = 5451230, upload-time = "2025-09-14T22:17:34.41Z" }, + { url = "https://files.pythonhosted.org/packages/63/4b/e3678b4e776db00f9f7b2fe58e547e8928ef32727d7a1ff01dea010f3f13/zstandard-0.25.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:8e735494da3db08694d26480f1493ad2cf86e99bdd53e8e9771b2752a5c0246a", size = 5547173, upload-time = "2025-09-14T22:17:36.084Z" }, + { url = "https://files.pythonhosted.org/packages/4e/d5/ba05ed95c6b8ec30bd468dfeab20589f2cf709b5c940483e31d991f2ca58/zstandard-0.25.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:3a39c94ad7866160a4a46d772e43311a743c316942037671beb264e395bdd611", size = 5046736, upload-time = "2025-09-14T22:17:37.891Z" }, + { url = "https://files.pythonhosted.org/packages/50/d5/870aa06b3a76c73eced65c044b92286a3c4e00554005ff51962deef28e28/zstandard-0.25.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:172de1f06947577d3a3005416977cce6168f2261284c02080e7ad0185faeced3", size = 5576368, upload-time = "2025-09-14T22:17:40.206Z" }, + { url = "https://files.pythonhosted.org/packages/5d/35/398dc2ffc89d304d59bc12f0fdd931b4ce455bddf7038a0a67733a25f550/zstandard-0.25.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:3c83b0188c852a47cd13ef3bf9209fb0a77fa5374958b8c53aaa699398c6bd7b", size = 4954022, upload-time = "2025-09-14T22:17:41.879Z" }, + { url = "https://files.pythonhosted.org/packages/9a/5c/36ba1e5507d56d2213202ec2b05e8541734af5f2ce378c5d1ceaf4d88dc4/zstandard-0.25.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:1673b7199bbe763365b81a4f3252b8e80f44c9e323fc42940dc8843bfeaf9851", size = 5267889, upload-time = "2025-09-14T22:17:43.577Z" }, + { url = "https://files.pythonhosted.org/packages/70/e8/2ec6b6fb7358b2ec0113ae202647ca7c0e9d15b61c005ae5225ad0995df5/zstandard-0.25.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0be7622c37c183406f3dbf0cba104118eb16a4ea7359eeb5752f0794882fc250", size = 5433952, upload-time = "2025-09-14T22:17:45.271Z" }, + { url = "https://files.pythonhosted.org/packages/7b/01/b5f4d4dbc59ef193e870495c6f1275f5b2928e01ff5a81fecb22a06e22fb/zstandard-0.25.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:5f5e4c2a23ca271c218ac025bd7d635597048b366d6f31f420aaeb715239fc98", size = 5814054, upload-time = "2025-09-14T22:17:47.08Z" }, + { url = "https://files.pythonhosted.org/packages/b2/e5/fbd822d5c6f427cf158316d012c5a12f233473c2f9c5fe5ab1ae5d21f3d8/zstandard-0.25.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:4f187a0bb61b35119d1926aee039524d1f93aaf38a9916b8c4b78ac8514a0aaf", size = 5360113, upload-time = "2025-09-14T22:17:48.893Z" }, + { url = "https://files.pythonhosted.org/packages/8e/e0/69a553d2047f9a2c7347caa225bb3a63b6d7704ad74610cb7823baa08ed7/zstandard-0.25.0-cp313-cp313-win32.whl", hash = "sha256:7030defa83eef3e51ff26f0b7bfb229f0204b66fe18e04359ce3474ac33cbc09", size = 436936, upload-time = "2025-09-14T22:17:52.658Z" }, + { url = "https://files.pythonhosted.org/packages/d9/82/b9c06c870f3bd8767c201f1edbdf9e8dc34be5b0fbc5682c4f80fe948475/zstandard-0.25.0-cp313-cp313-win_amd64.whl", hash = "sha256:1f830a0dac88719af0ae43b8b2d6aef487d437036468ef3c2ea59c51f9d55fd5", size = 506232, upload-time = "2025-09-14T22:17:50.402Z" }, + { url = "https://files.pythonhosted.org/packages/d4/57/60c3c01243bb81d381c9916e2a6d9e149ab8627c0c7d7abb2d73384b3c0c/zstandard-0.25.0-cp313-cp313-win_arm64.whl", hash = "sha256:85304a43f4d513f5464ceb938aa02c1e78c2943b29f44a750b48b25ac999a049", size = 462671, upload-time = "2025-09-14T22:17:51.533Z" }, + { url = "https://files.pythonhosted.org/packages/3d/5c/f8923b595b55fe49e30612987ad8bf053aef555c14f05bb659dd5dbe3e8a/zstandard-0.25.0-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:e29f0cf06974c899b2c188ef7f783607dbef36da4c242eb6c82dcd8b512855e3", size = 795887, upload-time = "2025-09-14T22:17:54.198Z" }, + { url = "https://files.pythonhosted.org/packages/8d/09/d0a2a14fc3439c5f874042dca72a79c70a532090b7ba0003be73fee37ae2/zstandard-0.25.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:05df5136bc5a011f33cd25bc9f506e7426c0c9b3f9954f056831ce68f3b6689f", size = 640658, upload-time = "2025-09-14T22:17:55.423Z" }, + { url = "https://files.pythonhosted.org/packages/5d/7c/8b6b71b1ddd517f68ffb55e10834388d4f793c49c6b83effaaa05785b0b4/zstandard-0.25.0-cp314-cp314-manylinux2010_i686.manylinux_2_12_i686.manylinux_2_28_i686.whl", hash = "sha256:f604efd28f239cc21b3adb53eb061e2a205dc164be408e553b41ba2ffe0ca15c", size = 5379849, upload-time = "2025-09-14T22:17:57.372Z" }, + { url = "https://files.pythonhosted.org/packages/a4/86/a48e56320d0a17189ab7a42645387334fba2200e904ee47fc5a26c1fd8ca/zstandard-0.25.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:223415140608d0f0da010499eaa8ccdb9af210a543fac54bce15babbcfc78439", size = 5058095, upload-time = "2025-09-14T22:17:59.498Z" }, + { url = "https://files.pythonhosted.org/packages/f8/ad/eb659984ee2c0a779f9d06dbfe45e2dc39d99ff40a319895df2d3d9a48e5/zstandard-0.25.0-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2e54296a283f3ab5a26fc9b8b5d4978ea0532f37b231644f367aa588930aa043", size = 5551751, upload-time = "2025-09-14T22:18:01.618Z" }, + { url = "https://files.pythonhosted.org/packages/61/b3/b637faea43677eb7bd42ab204dfb7053bd5c4582bfe6b1baefa80ac0c47b/zstandard-0.25.0-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:ca54090275939dc8ec5dea2d2afb400e0f83444b2fc24e07df7fdef677110859", size = 6364818, upload-time = "2025-09-14T22:18:03.769Z" }, + { url = "https://files.pythonhosted.org/packages/31/dc/cc50210e11e465c975462439a492516a73300ab8caa8f5e0902544fd748b/zstandard-0.25.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e09bb6252b6476d8d56100e8147b803befa9a12cea144bbe629dd508800d1ad0", size = 5560402, upload-time = "2025-09-14T22:18:05.954Z" }, + { url = "https://files.pythonhosted.org/packages/c9/ae/56523ae9c142f0c08efd5e868a6da613ae76614eca1305259c3bf6a0ed43/zstandard-0.25.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:a9ec8c642d1ec73287ae3e726792dd86c96f5681eb8df274a757bf62b750eae7", size = 4955108, upload-time = "2025-09-14T22:18:07.68Z" }, + { url = "https://files.pythonhosted.org/packages/98/cf/c899f2d6df0840d5e384cf4c4121458c72802e8bda19691f3b16619f51e9/zstandard-0.25.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a4089a10e598eae6393756b036e0f419e8c1d60f44a831520f9af41c14216cf2", size = 5269248, upload-time = "2025-09-14T22:18:09.753Z" }, + { url = "https://files.pythonhosted.org/packages/1b/c0/59e912a531d91e1c192d3085fc0f6fb2852753c301a812d856d857ea03c6/zstandard-0.25.0-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:f67e8f1a324a900e75b5e28ffb152bcac9fbed1cc7b43f99cd90f395c4375344", size = 5430330, upload-time = "2025-09-14T22:18:11.966Z" }, + { url = "https://files.pythonhosted.org/packages/a0/1d/7e31db1240de2df22a58e2ea9a93fc6e38cc29353e660c0272b6735d6669/zstandard-0.25.0-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:9654dbc012d8b06fc3d19cc825af3f7bf8ae242226df5f83936cb39f5fdc846c", size = 5811123, upload-time = "2025-09-14T22:18:13.907Z" }, + { url = "https://files.pythonhosted.org/packages/f6/49/fac46df5ad353d50535e118d6983069df68ca5908d4d65b8c466150a4ff1/zstandard-0.25.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4203ce3b31aec23012d3a4cf4a2ed64d12fea5269c49aed5e4c3611b938e4088", size = 5359591, upload-time = "2025-09-14T22:18:16.465Z" }, + { url = "https://files.pythonhosted.org/packages/c2/38/f249a2050ad1eea0bb364046153942e34abba95dd5520af199aed86fbb49/zstandard-0.25.0-cp314-cp314-win32.whl", hash = "sha256:da469dc041701583e34de852d8634703550348d5822e66a0c827d39b05365b12", size = 444513, upload-time = "2025-09-14T22:18:20.61Z" }, + { url = "https://files.pythonhosted.org/packages/3a/43/241f9615bcf8ba8903b3f0432da069e857fc4fd1783bd26183db53c4804b/zstandard-0.25.0-cp314-cp314-win_amd64.whl", hash = "sha256:c19bcdd826e95671065f8692b5a4aa95c52dc7a02a4c5a0cac46deb879a017a2", size = 516118, upload-time = "2025-09-14T22:18:17.849Z" }, + { url = "https://files.pythonhosted.org/packages/f0/ef/da163ce2450ed4febf6467d77ccb4cd52c4c30ab45624bad26ca0a27260c/zstandard-0.25.0-cp314-cp314-win_arm64.whl", hash = "sha256:d7541afd73985c630bafcd6338d2518ae96060075f9463d7dc14cfb33514383d", size = 476940, upload-time = "2025-09-14T22:18:19.088Z" }, +]