From f4bdc53f0018995c771aed0b95a407aa86f74d05 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 23 Nov 2026 11:22:38 -0300 Subject: [PATCH] ci: add dedicated Python and Rust integration pilot Run the result-sync matrix on candidate images with a locked Python payload. Refs #601 --- .github/ci/Dockerfile | 42 ++- .github/ci/Dockerfile.dockerignore | 2 + .github/ci/README.md | 33 +++ .github/ci/cross-runtime-requirements.txt | 240 ++++++++++++++++++ .github/ci/image-inputs.json | 20 +- .github/workflows/ci-image.yml | 5 +- .github/workflows/ci.yml | 191 ++++++++++++-- apps/backend/pyproject.toml | 12 + apps/backend/uv.lock | 24 ++ .../src/mobile_backend/reconciliation.rs | 31 ++- scripts/ci-cross-runtime.mjs | 104 ++++++++ scripts/ci-cross-runtime.test.mjs | 119 +++++++++ scripts/ci-image-impact.test.mjs | 4 +- scripts/ci-image-policy.mjs | 52 +++- scripts/ci-image-policy.test.mjs | 20 +- scripts/ci-scope-policy.test.mjs | 80 +++++- scripts/qualify-ci-cross-runtime.sh | 87 +++++++ scripts/run-tests.sh | 1 + scripts/verify-ci-image.sh | 26 ++ scripts/verify-ci-image.test.mjs | 46 +++- 20 files changed, 1072 insertions(+), 67 deletions(-) create mode 100644 .github/ci/cross-runtime-requirements.txt create mode 100644 scripts/ci-cross-runtime.mjs create mode 100644 scripts/ci-cross-runtime.test.mjs create mode 100644 scripts/qualify-ci-cross-runtime.sh diff --git a/.github/ci/Dockerfile b/.github/ci/Dockerfile index b6937de..12e5f4e 100644 --- a/.github/ci/Dockerfile +++ b/.github/ci/Dockerfile @@ -61,7 +61,7 @@ RUN set -eux; \ | xargs -0 sha256sum \ > payload.sha256 -FROM ubuntu:24.04@sha256:1e0a86e57d247923571b75e0aaf48a1449cf8c543d51fb3e07a4a7d7bfa79316 AS music-core-builder +FROM ubuntu:24.04@sha256:1e0a86e57d247923571b75e0aaf48a1449cf8c543d51fb3e07a4a7d7bfa79316 AS music-core-tools SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -103,15 +103,50 @@ COPY .github/ci/ .github/ci/ COPY packages/music-core/ packages/music-core/ COPY packaging/soxr/ packaging/soxr/ COPY scripts/ scripts/ +COPY .python-version .python-version RUN node scripts/ci-image-impact.mjs --manifest > /tmp/producer-inputs.sha256 + +FROM music-core-tools AS music-core-builder RUN node scripts/build-music-core.mjs --target wasm --summary \ && node packages/music-core/test/artifact-metadata.mjs \ && node packages/music-core/test/wasm-boundary.mjs \ && node packages/music-core/test/runtime-parity.mjs \ && node scripts/ci-music-core.mjs stage /opt/tuneforge-ci/music-core -FROM ubuntu:24.04@sha256:1e0a86e57d247923571b75e0aaf48a1449cf8c543d51fb3e07a4a7d7bfa79316 +FROM music-core-tools AS cross-runtime-builder + +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends clang-18; \ + rm -rf /var/lib/apt/lists/*; \ + runtime=/opt/tuneforge-ci/cross-runtime; \ + deps=.github/ci/cross-runtime-requirements.txt; \ + test "$MUSIC_PYTHON_VERSION" = "$(cat .python-version)"; \ + mkdir -p "$runtime"; \ + cp -a /opt/music-tools/python "$runtime/python"; \ + rm -rf "$runtime/python/lib/python3.14/ensurepip"; \ + uv venv --no-cache --python "$runtime/python/bin/python3.14" "$runtime/venv"; \ + uv pip install --no-cache --python "$runtime/venv/bin/python" \ + --require-hashes --only-binary :all: -r "$deps"; \ + CC=/usr/bin/clang-18 CXX=/usr/bin/clang++-18 node scripts/build-music-core.mjs --target python --python 3.14 --summary; \ + node scripts/build-music-core.mjs --target python --python 3.14 --check > "$runtime/music-core.json"; \ + wheel="$(node -p "require('$runtime/music-core.json').files[0].path")"; \ + uv pip install --offline --no-cache --no-index --no-deps --python "$runtime/venv/bin/python" \ + "packages/music-core/build/artifacts/python/cp314/$wheel"; \ + uv pip check --offline --no-cache --python "$runtime/venv/bin/python"; \ + uv pip freeze --offline --no-cache --python "$runtime/venv/bin/python" --exclude tuneforge-music-core > "$runtime/packages.txt"; \ + if grep -Ei '^(torch|(openai-)?whisper|demucs[^=]*|onnxruntime[^=]*|beat-this|tensorflow[^=]*|nvidia-[^=]*)==' "$runtime/packages.txt"; then exit 1; fi; \ + "$runtime/venv/bin/python" -IB -c 'import librosa, soundfile; from tuneforge_music_core import _native'; \ + printf '%s\n' "$MUSIC_PYTHON_VERSION" "$MUSIC_PYTHON_URL" "$MUSIC_PYTHON_SHA256" > "$runtime/python-source.txt"; \ + { /usr/bin/clang-18 --version; /usr/bin/clang++-18 --version; uv --version; } > "$runtime/build-tools.txt"; \ + cp "$deps" "$runtime/requirements.txt"; \ + cp -a packages/music-core/LICENSE "$runtime/music-core-LICENSE"; \ + cp -a packages/music-core/licenses "$runtime/music-core-notices"; \ + cd "$runtime"; \ + find . -type f ! -name payload.sha256 -print0 | LC_ALL=C sort -z | xargs -0 sha256sum > payload.sha256 + +FROM ubuntu:24.04@sha256:1e0a86e57d247923571b75e0aaf48a1449cf8c543d51fb3e07a4a7d7bfa79316 AS shared-base ARG FFMPEG_VERSION=7:6.1.1-3ubuntu5 ARG FFMPEG_DEB_URL=https://archive.ubuntu.com/ubuntu/pool/universe/f/ffmpeg/ffmpeg_6.1.1-3ubuntu5_amd64.deb @@ -242,3 +277,6 @@ RUN set -eux; \ rm -rf /var/lib/apt/lists/* COPY .github/ci/README.md /usr/share/doc/tuneforge-ci/README.md + +FROM shared-base AS shared-final +COPY --from=cross-runtime-builder /opt/tuneforge-ci/cross-runtime /opt/tuneforge-ci/cross-runtime diff --git a/.github/ci/Dockerfile.dockerignore b/.github/ci/Dockerfile.dockerignore index d34126a..223091e 100644 --- a/.github/ci/Dockerfile.dockerignore +++ b/.github/ci/Dockerfile.dockerignore @@ -3,7 +3,9 @@ !.github/ci/Dockerfile !.github/ci/Dockerfile.dockerignore !.github/ci/README.md +!.github/ci/cross-runtime-requirements.txt !.github/ci/image-inputs.json +!.python-version !packages/music-core/CMakeLists.txt !packages/music-core/LICENSE !packages/music-core/bindings/python/native.cpp diff --git a/.github/ci/README.md b/.github/ci/README.md index e291117..56e9513 100644 --- a/.github/ci/README.md +++ b/.github/ci/README.md @@ -96,6 +96,15 @@ manifest digest and Docker config image ID retain their distinct meanings. selected-image consumers verify its integrity and notices. CI script-tests check generated contracts and metadata. Native ABI, Python 3.14/3.11 wheel and Rust transport checks remain local validation in this producer change. Existing applications do not consume it yet. +- Cross-runtime fixture pilot: a separate layer at `/opt/tuneforge-ci/cross-runtime` + contains the checksum-pinned CPython 3.14.7 archive's runtime, a wheel-only test + environment, and the native music-core Python binding built from this recipe's + current source snapshot. The package subset comes from + `apps/backend/uv.lock`; CI checks the projection whenever script tests run. + The layer keeps distribution license files, resolved package versions, upstream + Python source pins, the verified music-core wheel manifest and notices, and a + payload checksum manifest. The environment excludes inference runtimes, model + weights, installer caches, and the backend checkout. - CI utilities: only tools needed by setup actions and native builds. No repository checkout, dependency directory, model, user data, or credential is included; SoXR corresponding sources are the documented exception. @@ -161,6 +170,30 @@ the same run, verify metadata and bytes, and bind Docker's loaded config ID to t metadata. A config image ID is distinct from the registry manifest digest. Missing or expired rerun artifacts, selector failures and identity failures fail closed. +The cross-runtime job runs alongside the ordinary backend and Tauri jobs when +CI selects a candidate. It restores the same image-keyed Cargo cache as +`desktop_tauri`, which remains the only writer. Both Rust jobs disable uv +dependency caching. The pilot leaves the promoted digest unchanged. Routine +scope-based runs require trusted main publication, verified digest promotion, +and explicit activation in the promotion PR. + +For a lock change, regenerate the committed projection with the pinned uv +0.13.6 and review the changed requirements and wheel hashes: + +```sh +uv export --offline --locked --project apps/backend --no-header --no-annotate \ + --only-group cross-runtime > .github/ci/cross-runtime-requirements.txt +``` + +Compare the shared image with a separately transferred payload on the same +Linux AMD64 engine using `bash scripts/qualify-ci-cross-runtime.sh`. +It builds `shared-final` and its payload-free `shared-base`, compares gzip +archive sizes and local build/load times, and validates and times a separate +payload archive mounted into `shared-base`. These are Docker-archive and local +setup measurements. For a promotion decision, measure real candidate artifact +transfer separately from registry layer bytes and pull, and compare hosted +job wall times, Cargo cache hit/miss, and restore time. + All three consumers run on the host with the same [Docker helper](../../scripts/ci-image-run.sh) as their absolute custom shell. Actions, caches and artifact uploads remain on the host; installs, strict image diff --git a/.github/ci/cross-runtime-requirements.txt b/.github/ci/cross-runtime-requirements.txt new file mode 100644 index 0000000..4e677ff --- /dev/null +++ b/.github/ci/cross-runtime-requirements.txt @@ -0,0 +1,240 @@ +alembic==1.19.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:b39018cb3d9413a19cbd54cf3c02ad33998641f0538eb77413a488a21c3e14be \ + --hash=sha256:e0fca0518118c78acc493e31bcb5402f190057aaf6df8b5b95ce94c4789cf648 +annotated-doc==0.0.5 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:117bac03a25ede5df5440e855b32d556049ca169ead221505badf432fed4b101 \ + --hash=sha256:c7e58ce09192557605d8bbd92836d7e1d520ac9580096042c0bfd197efacf1bb +annotated-types==0.8.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7 \ + --hash=sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0 +anyio==4.14.2 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:9f505dda5ac9f0c8309b5e8bd445a8c2bf7246f3ce950121e45ea15bc41d1494 \ + --hash=sha256:cfa139f3ed1a23ee8f88a145ddb5ac7605b8bbfd8592baacd7ce3d8bb4313c7f +certifi==2026.7.22 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775 \ + --hash=sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55 +cffi==2.1.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2 \ + --hash=sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f \ + --hash=sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676 \ + --hash=sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13 \ + --hash=sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72 \ + --hash=sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c \ + --hash=sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96 \ + --hash=sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be \ + --hash=sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb +charset-normalizer==3.5.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:09a7bba9f739468c8e78c36a75c33768e53cb1959fc638f510454c14683f00d5 \ + --hash=sha256:15f024313246a4ed976c60f440bb8d257815513a681d212ff74fd46f7d715a90 \ + --hash=sha256:41876ee62a3dddf48ff1121ad8f0798032aa03f2fd35f21f34a4cab14f18d8d2 \ + --hash=sha256:4c9548dc78002099910abaebc0a72ac58b7d30931869e0351c09b507dff4ece3 \ + --hash=sha256:58d4aa13a59c969dbfdf9e6a9560e242cbfd9e8a8f50c2747714df1a423adf65 \ + --hash=sha256:6117b84ea48435e5356dc737f5121485c30920ba43375fa7b434fd753df0eac3 \ + --hash=sha256:6df0ec430f9a831772c23ca5a224cba36517a58a84bb32c32bb59a9fa67c47f6 \ + --hash=sha256:85d5855daafc240cc045c026d7a15fd198a09b0fc8ff6f5ecbb5297b509cb11e \ + --hash=sha256:9ac4444d8d4fd4c4bd08bf451ed3167aa9e7ec6cdb41b648794f1d1103652e36 \ + --hash=sha256:a6dac12ff6b846103483683f60c5f8fee205121adc58ffd87e90a90a3af69e99 \ + --hash=sha256:c428c6c31eb5f4277d7f8eccaf767fbd548ddd5ce3c8b4f4cbbfab3d96b5904c \ + --hash=sha256:e199fb99720074809a7720f1c0b4d919eea8b87e88713e0f8f602f7bef543d9d \ + --hash=sha256:f03ac127268b43ef4fe9e6ab6794a6794b49485a0cc0c1db79876d2f33f75bc7 \ + --hash=sha256:fbc597639158fd7c14d55e808718848319540f51b0e6746e3eefa59723a4a348 +click==8.5.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360 \ + --hash=sha256:ba0d2089de75ea0310e2dde03160e6ca10009947fb95a182f9b54021bb272e34 +cryptography==50.0.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:2a93d05e34d5f67fba6f891fe85d929999baa7195e853923ea6d7576c9e68c5e \ + --hash=sha256:30a125032e5642a21ff816e021152bd4e7e94f03eff3f4b7fca41cd22bc3110f \ + --hash=sha256:407fe2b6db00939c05c0e945e9914238f2f0a430974839429dafc82b1ee6bee5 \ + --hash=sha256:42be3bb70596b3abe4ac097b75be223e8b3ab614a0e5de068e3dcc54d71d6149 \ + --hash=sha256:51593d180cf6d179bde5c5d065bed81386b1f381656ae7d042b7ffc87a9895ad \ + --hash=sha256:51afcfceb15597cf2635068e4ac9a56b2abde622edde17f37d85fd7b5306497a \ + --hash=sha256:5dd9bda1c12b4162f6ff568eeb5e0ff956c28d14406e875cfe8a63a2d414ff20 \ + --hash=sha256:79bf008d1f9af6071c797ad133e39915dfee7614f18f18f4db9072eb715064a3 \ + --hash=sha256:8921d58f426793c5f1b47f0b59575780de9a095214958d0eb37d909593db8367 \ + --hash=sha256:8df2de9102026855887e4587084f6eabd80ed0f345b8ad8a7ac27ab9bf4723e0 \ + --hash=sha256:9dde0a357190eb3b1da1bb9ab750e9c85cba82ca5977aa0836cbb94e92611239 \ + --hash=sha256:9ebcdd5519be9b652a46f507817a74591774fc3d6923ac364e4dfa64e36b291b \ + --hash=sha256:b8f852c65863251b9e3a1b8c150ce21e59b522dbb6a7d4bc80e680d38388e986 \ + --hash=sha256:ca83d00d9e69cd5eb63f2e69c3a5a59e0cecae5ae14c6ae0b35830fe3b37bad0 \ + --hash=sha256:e22dfed744bd4002e909464cb23d2f0b05c6f3113a79ef2e9864a53db737c733 \ + --hash=sha256:ff838d62ec1bfce4f9ba7fa16f4a7b554cd8d0c299e6be37502161a660c84eef +decorator==5.3.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:4cbcdd55a6efadb9dbea26b858f4fb3264567b52d69ca0d25b721b553f60ea82 \ + --hash=sha256:f47fe6fdbd2edd623ecfe36875d37aba411624e2670dd395dddae1358689bb3c +fastapi==0.141.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:bfb91aa2d334c61cb35ba9a116fc123b3d3df31640b801cf57a7a78ec3f603b3 \ + --hash=sha256:e8822fc40db1e1858054d7a949a888695bc9bdce70139178e33bd2871a453ca1 +filelock==3.32.4 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:22e58ca3b1ae3b98993b762d7338367ae64fe50252bf78d59da3bfebcdf1cedd \ + --hash=sha256:2bde2e4cf732e0153406d8a7bc80620ecf5e621fe0d25e41143c4e3b4733ff30 +fsspec==2026.7.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:b57ddbafedfaef7018c1ecab32aa200a9d7ca26b77965f64e48b70061249d279 \ + --hash=sha256:c803c40f4cf860b49dea58ee3e1c33cb9c790520e233537e1340049f89b82a88 +greenlet==3.5.5 ; platform_machine == 'x86_64' and sys_platform == 'linux' \ + --hash=sha256:182de51c6b572a705f2fafaab2e783bcf7d2760940229dfe73086cbae037af3e \ + --hash=sha256:44f08341873200ba8a60a8bc14ace3d91f1754f7fa7bc66157714a8cd420a476 \ + --hash=sha256:72507285b5caa1d17904a3f7c322ca780823a54170a0e04ec3f37bcc60d4db71 \ + --hash=sha256:adb4bae02e91a8e863e48b177e4014bdcac8a6b5e047ea1df687a61534b85e6c \ + --hash=sha256:c6ce25fee6cabc8bf22cb8b52e642cbb821be5b9aec8094d07ff03378141b8e9 +h11==0.16.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1 \ + --hash=sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86 +hf-xet==1.6.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:23379c2f9ec8696d952b16414a2bae72cad86a52df869b050698ba60f538c675 \ + --hash=sha256:2e58454a340b3556dfa4972d5451aff4fba8dd42a236600ba1a1d2b1514f0fef \ + --hash=sha256:35cec30d75c6f9eb9c16a77cef68e85a103b72e24d4b473714ec9ff06428bab9 \ + --hash=sha256:8fb4f71cba6129110c3374a33f919001ff130488fc23553698e34cc1c2a1198c \ + --hash=sha256:d62671bb130879cef0ee4c9ebe47a14af6c66ec53e6d84dc15936e5ffdfac82f \ + --hash=sha256:f0906082d9932ae0c0057fa194041c22b4e2cdb46b2592ef3b91f020d62a081a \ + --hash=sha256:f2f7278c05c22fd60cb436cda1269649b3e81db65ecdc8496e5e164aa4143e7b +httpcore==1.0.9 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55 \ + --hash=sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8 +httpx==0.28.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc \ + --hash=sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad +huggingface-hub==1.29.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:6ebb385a581435325cf6d5c5b233d5d4bc91175834d99fd65dae14379b36e9ad \ + --hash=sha256:b00f7782afc14db4bc6572763810a635bdfbab8623d957bfb553bd18e03852cd +idna==3.19 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:5e0811a4383b21dc5838069f801c4fb62113b7447663d2530d2bd6e77b49bf15 \ + --hash=sha256:815e7be7a7806d54abb586dc943addc79e8b2ee16915059658cbeff4b1b43bf4 +joblib==1.5.3 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:5fc3c5039fc5ca8c0276333a188bbd59d6b7ab37fe6632daa76bc7f9ec18e713 \ + --hash=sha256:8561a3269e6801106863fd0d6d84bb737be9e7631e33aaed3fb9ce5953688da3 +lazy-loader==0.5 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:717f9179a0dbed357012ddad50a5ad3d5e4d9a0b8712680d4e687f5e6e6ed9b3 \ + --hash=sha256:ab0ea149e9c554d4ffeeb21105ac60bed7f3b4fd69b1d2360a4add51b170b005 +librosa==1.0.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:5910a6c0e1b2e494b92758c1615a7acbd0515a2315e138927ba2982f2af88857 \ + --hash=sha256:73ed480d4022e436e85dfa6f6b06ff38a259b9210039ac99939cd64854b61a57 +llvmlite==0.49.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:00f16db782f4a13c78c5804aedc434e46794a77e89999a168f9401106270e50a \ + --hash=sha256:4281a0171d66d2098adce4ba706b8c550b1b10718650f682d64cde16e84e4de5 \ + --hash=sha256:80a84683d04516bb51da1bbeebddaf2c2f558809c93078a8f91807909ae331f8 \ + --hash=sha256:d5555ea1d63928481cbf7fcb1d67452b216c7e5b393a4eb7aa1401e67f2a4fc4 \ + --hash=sha256:f3f2ff0aeb17d34fcce9f79b99baac441cfd3efa41b83e233ca4530a72381f72 +mako==1.4.2 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:7227a060ee3af55a493af61d73d6beef13044b81dba9586736c13945f09464ce \ + --hash=sha256:e70a2a4308952b33a21208bfd6725da79fae5a8c224578f8cfdeb60e5ace03df +markupsafe==3.0.3 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175 \ + --hash=sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe \ + --hash=sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97 \ + --hash=sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc \ + --hash=sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698 \ + --hash=sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026 \ + --hash=sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50 +msgpack==1.2.2 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:0dd9173c5ebaf5ecc5ca86e7ae1db92934e1d57b856f3dd90698941431f4fd77 \ + --hash=sha256:1f6b6f8deb07d49090e1808c6ef9cb7d23ca17bef3aa6ed3e5e03df16606e60c \ + --hash=sha256:55faa6f8395e23b848c535ad5dcb96b3462f37f5e7f4ac500d500434f7345da7 \ + --hash=sha256:73b0e05c32c3cfc3cd84994908e57430c0ebc6813abf905d3f18ff115d54df3f \ + --hash=sha256:7d095df2627e5dd59ac7b0c5ad627a671c76e6020171e03cbe4621a61f0562c3 \ + --hash=sha256:9eb0b0e602064527a045ea28c4f174ed69383587e29cebe28947e3b84106eb2a \ + --hash=sha256:b8dd6c71d20c28d2d0eb0c51e7cccf3584afde3b1364f6629596186c9025bd54 +narwhals==2.25.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:1f0f403e8c7e4463cde9bfe78b12fdd809e3ae3dda6d9b2f802934fb9c7a6a8f \ + --hash=sha256:62c036c810662bf7820b7737077176313bc59350eeeefb808510f388c743e4b2 +numba==0.67.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:4a2ed006635bbd0fe45681ed49f3b4f4bad1abf0c233bcc5842c9e3a34cabd61 \ + --hash=sha256:5269245a675abdd3e2c35ec6bb2f250355effa9032514d8f2354f0d2d10854bd \ + --hash=sha256:aa5f002f665bec321b950dacaa26ee009e1d720f6ac9d9856eed5efe1caa03a6 \ + --hash=sha256:cd75aa535b33fa05d9d930b1ae8af9f97a2881e96d72dfb38ec9b78284d9f851 \ + --hash=sha256:f99f880ff25f418a67f9a1d00d0ddfbc63430f627b523e515085a592a7567f4b +numpy==2.5.2 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:1ab3d4a901f844ea836c3e80bf463c6a27d7f3c14e8e292fcf28d348b25b9bce \ + --hash=sha256:24b9dc2e3d84aa58523798805194e23e736f3f6ce2d1a5b92583ae734e6dbda8 \ + --hash=sha256:318b9a4c845dbea06708a29c84ee429cc3065048db34cdb799047643492050ee \ + --hash=sha256:9e9413326d726c2545bfa65d2c0876871e8d8386e77f992c1d426e180bbd4323 \ + --hash=sha256:b879fb674276e331513fb136b78dbc6bd3c848309e0d841cfd63be3896c4cfc1 \ + --hash=sha256:d482d171c406ae88c5b19cad3b6a1c4c5209f886ab74bc44c2c865c23f52d860 \ + --hash=sha256:eaca7ff36f0f52e2111ec71f169d8fd3e889e7ddc0d2592e0d703fd8d3ce8fac \ + --hash=sha256:f06571a052127dc1b4e8b83029b4d1b20daa2b64a31cdd181fc6bc774e9000eb \ + --hash=sha256:fd0d703772bba096843785bd38371e31bb4a0c1151497ad5739d182114a73f7f +packaging==26.3 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79 \ + --hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c +platformdirs==4.11.5 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:89f8d42695853b89c7170bd49bc3dc593f98a71e695ede88e06a3b247bc4563b \ + --hash=sha256:e8b31f4f8bcbbedef91a6b57a706255e4f148d2a4e01648382a0a47342539173 +pooch==1.9.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:de46729579b9857ffd3e741987a2f6d5e0e03219892c167c6578c0091fb511ed \ + --hash=sha256:f265597baa9f760d25ceb29d0beb8186c243d6607b0f60b83ecf14078dbc703b +pycparser==3.0 ; (implementation_name != 'PyPy' and platform_machine == 'arm64' and sys_platform == 'darwin') or (implementation_name != 'PyPy' and platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29 \ + --hash=sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992 +pydantic==2.13.5 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:346a034f080da3755d8e9cb5e00e8b07de1d39e4f6e2c87d8ab7cafa0b269a73 \ + --hash=sha256:51a9c5f7b2f8e636f04c6cada605d9b6a3bf1348fdf945a3d8869b19bba0ee08 +pydantic-core==2.46.5 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:10416c15b8839ecc4ef4d0885da76da6fd0f67333a0eb8aff6d93c4b8f2910fc \ + --hash=sha256:1a353f84de772f423b5ffb11d7ae352fbbef0f446f3c0b0af0f8236d7233606e \ + --hash=sha256:2cbd9a5eff05e51c447c34dfa4632145b26b09120cf04bd0c871e44c1a5e1c9a \ + --hash=sha256:54d510bac3ee52247af28ed4bb18a1e799f040ac60fd2bf5ccd4c92f1fbe786f \ + --hash=sha256:bce57638e08ac148e5778cce7feb968307a727d66f8e2274a543d0cf0c9ad6a3 \ + --hash=sha256:cdbb78909f52b981d3b2d56b97328d71eb0b974c36bd77c920123a7ebb192829 \ + --hash=sha256:ff218293c9c806138dca139765e3b067621be52bcd93cdc14c7711be7ddc90a9 +pyyaml==6.0.3 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c \ + --hash=sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65 \ + --hash=sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310 \ + --hash=sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35 \ + --hash=sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba \ + --hash=sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5 \ + --hash=sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f +requests==2.34.2 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0 \ + --hash=sha256:f288924cae4e29463698d6d60bc6a4da69c89185ad1e0bcc4104f584e960b9ed +scikit-learn==1.9.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:1fea2cc5677ab49d6f5bade978c866da44957b712d92e9635e8b4f723013c3cb \ + --hash=sha256:24360002ae845e7866522b0a5bbf690802e7bc388cac8663502e78aa98598aa2 \ + --hash=sha256:5bad8f8b9950321b54c965fdcbac6c6c55e79e16646b49977bcf3668d3870a1a \ + --hash=sha256:8833266989d3a5110178a9fae30783675460724d0e1efb13b14901d2c660c557 \ + --hash=sha256:ee1a8db2c18c08e34c7412d4b10be1cac214cd4ea7dc9715a6a327eb49a37c96 +scipy==1.18.1 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:011413b7426b75012840e35649e00fe0a2c3bae89fed433876e3a99251572efc \ + --hash=sha256:0e82073ecc7acc6436fac4b31674109c7e1d3e596789767eda01258a8c9e8123 \ + --hash=sha256:11c423f1049c5755ad4409af52a9ada1cff96fe9b50795d4af3619f292901239 \ + --hash=sha256:52c4b7422442aba924d03ad4019852b08a92e64ea187b933135687bfe2747307 \ + --hash=sha256:95298364e251be3e60249facbeeca03631d3bb7584f85879516ec55ac717b81f \ + --hash=sha256:9554bcc6d715ee87a633a3cc8e7703c6628b100dd29cb8a2efc4c0533c7ff729 \ + --hash=sha256:a1d33a7836f7ddc1993427966a0823468ec41bcbdb1a9f9942d1d7e57f803ba3 \ + --hash=sha256:ac0333bdf38309aa3dcbe7e3fa7ea29e7a2c37c6ea306a757b700ded8e4596ad \ + --hash=sha256:ddef79fb382df40104a19bb7151b3b23e57c1778fcf857c71ceecd9bd264513f +soundfile==0.14.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:1e38bac1853412871318e82a1ba69a8be677619b56025bbfcccdb41b6cafe82d \ + --hash=sha256:8ba81ae3a89fd5ab3bef8a8eb481fbbe794e806309675a89b4df48b8d31908a8 \ + --hash=sha256:ba1c1a2d618bca5c406647c83b89f07cc8810fa506a50622a6993ba130c1de11 \ + --hash=sha256:d828d35a059626da52f1415b5faee610aeab393319cb3fc4a9aef47b619fc14c +soxr==1.1.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:3b033078e86f3c4a658e5697fac8995764fad9e799563616b630136b613167f1 \ + --hash=sha256:9f228ae21c78fa9359ca98d8a5e8e91f30639e438e574133dace62c5b5309e44 \ + --hash=sha256:d6a7ad82b8d5f3fcc04b1d2ca055562b96af571e1d4fa7c6c61d0fb509ac43b4 \ + --hash=sha256:f4977323ef9c3aa3c2a26ff5fe0191c84b8fd759daf7afb1f25a91a55ad8b730 \ + --hash=sha256:feebcba99ac99adb8009d46c8f4c1956b8c167576b0ae8a6fb47502e9a6f78e7 +sqlalchemy==2.0.52 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:3b81b8363a919ce53453591cdb93702e6bd54ade6c4fa2f468fc053baee5ed89 \ + --hash=sha256:410d52be41d17f1a236d19520fbe776257dc16516ed06bd16d433311842aefd9 \ + --hash=sha256:49565daf5af554f538e23aef1fc81a95a4e49658f152285e45c02f5fc44f04cd \ + --hash=sha256:5e2d46356ac2ccb7d268ab6c2319ac6a2b42f1b8d5fd8bd3d46855cd82abee97 \ + --hash=sha256:812bae5138bfc0aa46fb0686da0fc7f581f68e2bbb05bc24c3713bebaedd1437 \ + --hash=sha256:c1e61d08bdf4ee2f41024569e3400de7d6734ba498144766b11260936ccfa582 +starlette==1.6.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:a86dd39d14bb45f85a3d18525215a9ef0cfd1f192ac793220e72598c90335f0c \ + --hash=sha256:d4e3ac5e546444960c710297a3c9fc3f7ebae1b7e963f3d36173b49da535be9b +threadpoolctl==3.6.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:43a0b8fd5a2928500110039e43a5eed8480b918967083ea48dc3ab9f13c4a7fb \ + --hash=sha256:8ab8b4aa3491d812b623328249fab5302a68d2d71745c8a4c719a2fcaba9f44e +tqdm==4.70.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:55b0b0dbd97462d06ebee91e4dac24ed4d4702be82b24f07e6c1d27e08cea220 \ + --hash=sha256:7f585706bfddbdebf89daac705b2dfcc16890130727d3197ca62c732b4310953 +typing-extensions==4.16.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8 \ + --hash=sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5 +typing-inspection==0.4.4 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:547274fa6b0a561ccf549cc9524b999a578e737d015d8709d021f9d0d13bea47 \ + --hash=sha256:65b8397ba37ccbce054456aaccddfc91e6e3083c92824df348d96ca832f3f147 +urllib3==2.8.0 ; (platform_machine == 'arm64' and sys_platform == 'darwin') or (platform_machine == 'x86_64' and sys_platform == 'linux') \ + --hash=sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3 \ + --hash=sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63 diff --git a/.github/ci/image-inputs.json b/.github/ci/image-inputs.json index 4ea879f..9d205c0 100644 --- a/.github/ci/image-inputs.json +++ b/.github/ci/image-inputs.json @@ -8,7 +8,7 @@ "source": "repository recipe and documentation; Ubuntu 24.04 digest in Dockerfile", "license": "MIT recipe; installed Ubuntu copyright files and packages.txt for transitive packages", "probes": ["whole producer manifest", "base-image.txt", "packages.txt"], - "consumers": ["backend", "desktop_tauri", "e2e"] + "consumers": ["backend", "desktop_tauri", "e2e", "cross_runtime_integration"] }, { "name": "SoXR and PFFFT", @@ -16,7 +16,7 @@ "source": "source URL, revision, archive checksum, embedded PFFFT revision and patch in sources.lock.json", "license": "LGPL-2.1-or-later SoXR; BSD-3-Clause PFFFT; corresponding sources in image", "probes": ["build-inputs.sha256", "payload.sha256", "provenance.json", "synthetic C resampling"], - "consumers": ["desktop_tauri"], + "consumers": ["desktop_tauri", "cross_runtime_integration"], "locks": ["packaging/soxr/sources.lock.json"] }, { @@ -25,7 +25,7 @@ "source": "official Ubuntu FFmpeg package URL, package checksum and binary checksums in Dockerfile", "license": "GPL-2.0-or-later CI-only Ubuntu build; /usr/share/doc/ffmpeg/copyright", "probes": ["ffmpeg.sha256", "codec-validation.jsonl", "exact /usr/bin/ffmpeg and /usr/bin/ffprobe paths"], - "consumers": ["backend", "e2e"] + "consumers": ["backend", "e2e", "cross_runtime_integration"] }, { "name": "Playwright system libraries", @@ -41,7 +41,7 @@ "source": "APT packages from Dockerfile; compiler identity and resolved versions recorded in image", "license": "installed Ubuntu copyright files", "probes": ["native compiler identity and C++ regression verification", "cargo check", "cargo test", "setup-tool executable compatibility"], - "consumers": ["backend", "desktop_tauri", "e2e"] + "consumers": ["backend", "desktop_tauri", "e2e", "cross_runtime_integration"] }, { "name": "Music core portable WASM", @@ -118,7 +118,15 @@ "source": "Gingo archive/revision/file hashes in sources.lock.json; checksummed Emscripten and Python build dependencies in toolchains.lock.json; Node/uv/Python bootstrap pins in Dockerfile", "license": "MIT owned core and Gingo; Unicode-3.0 compatibility data; build tools remain in disposable stage", "probes": ["canonical artifact sourceFingerprint/metadata/payload verification", "portable WASM boundary/parity", "native ABI and Python/Rust transport parity", "payload.sha256 and build-tools.txt"], - "consumers": ["backend", "desktop_tauri", "e2e"] + "consumers": ["backend", "desktop_tauri", "e2e", "cross_runtime_integration"] + }, + { + "name": "Cross-runtime fixture Python", + "inputs": [".github/ci/Dockerfile", ".github/ci/cross-runtime-requirements.txt", ".python-version"], + "source": "CPython build-standalone archive pin in Dockerfile; hash-checked cross-runtime dependency group projection of apps/backend/uv.lock; verified music-core Python wheel built from source in the same producer", + "license": "CPython distribution notices, each Python wheel's distribution metadata and licenses, MIT/Unicode/BSD music-core notices; CI-only", + "probes": ["payload.sha256", "python-source.txt", "requirements.txt", "packages.txt", "music-core.json", "isolated fixture matrix"], + "consumers": ["cross_runtime_integration"] } ], "registeredReads": { @@ -154,7 +162,7 @@ "packages/music-core/bindings/wasm/index.mjs": "b5ea9985ff2dfc6b29384ace6a2a9cc1ad39e6758f992553b30978ad0070864d" }, "processInputs": [".github/workflows/ci-image.yml", "scripts/ci-image-policy.mjs"], - "compatibilityInputs": [".github/workflows/ci.yml", "scripts/verify-ci-image.sh", "scripts/ci-image-run.sh", ".github/ci/promoted-image.json", ".python-version", "apps/desktop/package.json", "pnpm-lock.yaml", "package.json", "apps/backend/pyproject.toml", "apps/backend/uv.lock"], + "compatibilityInputs": [".github/workflows/ci.yml", "scripts/verify-ci-image.sh", "scripts/ci-image-run.sh", "scripts/ci-cross-runtime.mjs", ".github/ci/promoted-image.json", "apps/desktop/package.json", "pnpm-lock.yaml", "package.json", "apps/backend/pyproject.toml", "apps/backend/uv.lock"], "sourceTrees": [ { "root": "packages/music-core", diff --git a/.github/workflows/ci-image.yml b/.github/workflows/ci-image.yml index 18096fd..e0021a2 100644 --- a/.github/workflows/ci-image.yml +++ b/.github/workflows/ci-image.yml @@ -8,8 +8,10 @@ on: - .github/ci/Dockerfile - .github/ci/Dockerfile.dockerignore - .github/ci/README.md + - .github/ci/cross-runtime-requirements.txt - .github/ci/image-inputs.json - .github/workflows/ci-image.yml + - .python-version - packages/music-core/** - packaging/soxr/patches/android-unversioned-soname.patch - packaging/soxr/sources.lock.json @@ -90,7 +92,7 @@ jobs: exit 1 fi - base_images="$(sed -n 's/^FROM \([^ ]*\).*$/\1/p' \ + base_images="$(sed -n 's/^FROM \(ubuntu:[^ ]*@sha256:[0-9a-f]\{64\}\).*$/\1/p' \ .github/ci/Dockerfile | LC_ALL=C sort -u)" if [[ "$(wc -l <<< "${base_images}")" -ne 1 ]]; then echo "CI image stages must use one exact base image reference." >&2 @@ -130,6 +132,7 @@ jobs: echo "- SoXR build evidence: \`/opt/tuneforge-ci/soxr/{build-tools.txt,build-inputs.sha256,payload.sha256}\`" echo "- Music core WASM, manifest, notices and pins: \`/opt/tuneforge-ci/music-core\`" echo "- Music core evidence: \`/opt/tuneforge-ci/music-core/{payload.sha256,build-tools.txt}\`" + echo "- Cross-runtime Python payload and evidence: \`/opt/tuneforge-ci/cross-runtime\`" echo "- BuildKit SBOM: attached by the successful build" echo "- BuildKit provenance: attached with \`mode=max\`" echo "- Image inventory: \`/usr/share/tuneforge-ci/packages.txt\`" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a373dd..d38ef31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,12 @@ jobs: backend_static: ${{ steps.scope.outputs.backend_static == 'true' || steps.image.outputs.selection != 'promoted' }} backend_ffmpeg: ${{ steps.scope.outputs.backend_ffmpeg == 'true' || steps.image.outputs.selection != 'promoted' }} codex_only: ${{ steps.scope.outputs.codex_only }} - desktop: ${{ steps.scope.outputs.desktop }} - desktop_tauri: ${{ steps.scope.outputs.desktop == 'true' || steps.image.outputs.selection != 'promoted' }} - release_media: ${{ steps.scope.outputs.release_media }} - site: ${{ steps.scope.outputs.site }} + desktop: ${{ steps.scope.outputs.desktop == 'true' && (steps.scope.outputs.native_only != 'true' || steps.image.outputs.selection != 'promoted') }} + desktop_tauri: ${{ steps.scope.outputs.desktop_tauri == 'true' || steps.scope.outputs.desktop == 'true' || steps.image.outputs.selection != 'promoted' }} + cross_runtime_integration: ${{ steps.scope.outputs.cross_runtime_integration == 'true' || steps.image.outputs.selection != 'promoted' }} + native_only: ${{ steps.scope.outputs.native_only }} + release_media: ${{ steps.scope.outputs.release_media == 'true' && (steps.scope.outputs.native_only != 'true' || steps.image.outputs.selection != 'promoted') }} + site: ${{ steps.scope.outputs.site == 'true' && (steps.scope.outputs.native_only != 'true' || steps.image.outputs.selection != 'promoted') }} image_selection: ${{ steps.image.outputs.selection }} image_fingerprint: ${{ steps.image.outputs.fingerprint }} steps: @@ -42,6 +44,9 @@ jobs: backend_ffmpeg=false codex_only=false desktop=false + desktop_tauri=false + cross_runtime_integration=false + native_only=false release_media=false site=false full_gate=false @@ -50,28 +55,46 @@ jobs: if [[ "${{ github.event_name }}" != "pull_request" ]]; then full_gate=true + cross_runtime_integration=true : > "${changed_files}" else base_sha="${{ github.event.pull_request.base.sha }}" head_sha="${{ github.event.pull_request.head.sha }}" - if ! git diff --name-only "${base_sha}" "${head_sha}" > "${changed_files}"; then + if ! git diff --name-only --no-renames -z "${base_sha}" "${head_sha}" > "${changed_files}" || + ! git diff --merge-base --name-only --no-renames -z "${base_sha}" "${head_sha}" > "${pr_changed_files}"; then echo "Could not compute changed files; running the full gate." >&2 full_gate=true + cross_runtime_integration=true : > "${changed_files}" - elif git diff --merge-base --name-only --no-renames -z "${base_sha}" "${head_sha}" > "${pr_changed_files}" && - [[ -s "${pr_changed_files}" ]]; then + elif [[ -s "${pr_changed_files}" ]]; then codex_only=true + native_only=true + # New lane scope follows paths changed by the PR itself. The legacy gates below + # still consider endpoint differences for shared and caller-affecting changes. while IFS= read -r -d '' path; do if [[ "${path}" != .codex/* ]]; then codex_only=false - break fi + if [[ "${path}" = apps/desktop/src-tauri/* ]]; then + desktop_tauri=true + cross_runtime_integration=true + else + native_only=false + fi + case "${path}" in + apps/backend/app/*|apps/backend/alembic/*|apps/backend/alembic.ini|apps/backend/tests/result_sync_fixture.py|apps/backend/tests/fixtures/*|apps/backend/pyproject.toml|apps/backend/uv.lock) + cross_runtime_integration=true + ;; + packages/music-core/*|packaging/soxr/*|.python-version|.github/ci/*|.github/workflows/ci-image.yml|.github/workflows/ci.yml|scripts/ci-*|scripts/verify-ci-image*|scripts/build-music-core*|scripts/build-soxr-runtime*|scripts/deterministic-source-snapshot.mjs|scripts/run-tests.sh|scripts/qualify-ci-cross-runtime.sh) + cross_runtime_integration=true + ;; + esac done < "${pr_changed_files}" fi fi if [[ -s "${changed_files}" ]]; then - while IFS= read -r path; do + while IFS= read -r -d '' path; do case "${path}" in scripts/capture-release-media.mjs|scripts/check-release-version.mjs) site=true @@ -86,10 +109,6 @@ jobs: site=true release_media=true ;; - apps/backend/pyproject.toml|apps/backend/uv.lock) - backend_static=true - backend_ffmpeg=true - ;; apps/backend/README.md) ;; apps/backend/app/api/*|apps/backend/app/schemas.py|apps/backend/app/main.py) @@ -103,6 +122,9 @@ jobs: ;; packages/shared-types/AGENTS.md) ;; + apps/desktop/src-tauri/*) + desktop_tauri=true + ;; apps/desktop/*) desktop=true site=true @@ -120,7 +142,7 @@ jobs: .github/ci/*|.github/workflows/ci-image.yml|.github/workflows/ci.yml|packaging/soxr/*) full_gate=true ;; - .agents/*|.codex/*|docs/*|CHANGELOG.md|README.md|CONTRIBUTING.md|CODE_OF_CONDUCT.md|LICENSE|THIRD_PARTY_NOTICES.md|SECURITY.md|AGENTS.md|.gitignore|packaging/flatpak/*|.github/ISSUE_TEMPLATE/*|.github/PULL_REQUEST_TEMPLATE.md) + .agents/*|.codex/*|docs/*|CHANGELOG.md|README.md|CONTRIBUTING.md|CODE_OF_CONDUCT.md|LICENSE|THIRD_PARTY_NOTICES.md|SECURITY.md|AGENTS.md|TODO.md|.gitignore|packaging/flatpak/*|.github/ISSUE_TEMPLATE/*|.github/PULL_REQUEST_TEMPLATE.md) ;; *) full_gate=true @@ -133,6 +155,7 @@ jobs: backend_static=true backend_ffmpeg=true desktop=true + desktop_tauri=true release_media=true site=true fi @@ -152,6 +175,7 @@ jobs: print_scope_decision "backend static checks" "${backend_static}" print_scope_decision "backend FFmpeg tests" "${backend_ffmpeg}" print_scope_decision "desktop checks" "${desktop}" + print_scope_decision "cross-runtime integration after activation" "${cross_runtime_integration}" print_scope_decision "site checks" "${site}" { @@ -159,6 +183,9 @@ jobs: echo "backend_ffmpeg=${backend_ffmpeg}" echo "codex_only=${codex_only}" echo "desktop=${desktop}" + echo "desktop_tauri=${desktop_tauri}" + echo "cross_runtime_integration=${cross_runtime_integration}" + echo "native_only=${native_only}" echo "release_media=${release_media}" echo "site=${site}" } >> "${GITHUB_OUTPUT}" @@ -169,13 +196,15 @@ jobs: echo "- Backend static checks: ${backend_static}" echo "- Backend FFmpeg tests: ${backend_ffmpeg}" echo "- Codex-only pull request: ${codex_only}" + echo "- Native-only pull request: ${native_only}" echo "- Desktop checks: ${desktop}" + echo "- Cross-runtime integration after activation: ${cross_runtime_integration}" echo "- Site checks: ${site}" if [[ -s "${changed_files}" ]]; then echo echo "
Changed files" echo - sed 's/^/- `/' "${changed_files}" | sed 's/$/`/' + while IFS= read -r -d '' path; do printf -- "- \`%q\`\n" "${path}"; done < "${changed_files}" echo echo "
" fi @@ -387,15 +416,28 @@ jobs: /tmp/tuneforge-zlib-probe - name: Test deterministic Node scripts - run: node --test scripts/build-info.test.mjs scripts/package-options.test.mjs scripts/flatpak-options.test.mjs scripts/flatpak-pnpm.test.mjs scripts/desktop-e2e.test.mjs scripts/sync-validation.test.mjs scripts/release-license-inventory.test.mjs scripts/capture-release-media.test.mjs scripts/ci-image-policy.test.mjs scripts/ci-music-core.test.mjs scripts/verify-ci-image.test.mjs scripts/ci-scope-policy.test.mjs scripts/ci-image-impact.test.mjs scripts/ci-image-run.test.mjs scripts/validate-android-release-jni.test.mjs scripts/package-dmg.test.mjs scripts/package-profile.test.mjs scripts/dev.test.mjs scripts/android-prepare-generated.test.mjs + run: node --test scripts/build-info.test.mjs scripts/package-options.test.mjs scripts/flatpak-options.test.mjs scripts/flatpak-pnpm.test.mjs scripts/desktop-e2e.test.mjs scripts/sync-validation.test.mjs scripts/release-license-inventory.test.mjs scripts/capture-release-media.test.mjs scripts/ci-image-policy.test.mjs scripts/ci-music-core.test.mjs scripts/verify-ci-image.test.mjs scripts/ci-scope-policy.test.mjs scripts/ci-image-impact.test.mjs scripts/ci-image-run.test.mjs scripts/validate-android-release-jni.test.mjs scripts/package-dmg.test.mjs scripts/package-profile.test.mjs scripts/dev.test.mjs scripts/android-prepare-generated.test.mjs scripts/ci-cross-runtime.test.mjs - name: Check standalone music-core generated contracts and metadata run: | pnpm --filter @tuneforge/music-core types:check node packages/music-core/test/artifact-metadata.mjs - - name: Set up uv for Android runtime audit fixtures + - name: Set up Python for the locked fixture projection + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version-file: .python-version + + - name: Set up uv for fixture projection and Android runtime audits uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + with: + version: "0.13.6" + + - name: Check cross-runtime requirements projection + run: | + set -euo pipefail + uv export --offline --locked --project apps/backend --no-header --no-annotate --only-group cross-runtime | + diff -u .github/ci/cross-runtime-requirements.txt - - name: Test Android packaging helpers run: node --test --test-reporter=spec scripts/package-android.test.mjs scripts/prepare-android-demucs-runtime.test.mjs scripts/prepare-android-model-assets.test.mjs @@ -429,7 +471,7 @@ jobs: e2e: needs: [ci-scope, ci-image-candidate, music-core-wasm] - if: ${{ always() && (needs.ci-scope.result != 'success' || needs.ci-scope.outputs.codex_only != 'true' || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped' || needs.music-core-wasm.result != 'success' || needs.music-core-wasm.outputs.artifact_id == '') }} + if: ${{ always() && (needs.ci-scope.result != 'success' || (needs.ci-scope.outputs.codex_only != 'true' && needs.ci-scope.outputs.native_only != 'true') || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped' || needs.music-core-wasm.result != 'success' || needs.music-core-wasm.outputs.artifact_id == '') }} runs-on: ubuntu-24.04 defaults: run: @@ -1001,7 +1043,7 @@ jobs: if: needs.ci-scope.outputs.desktop_tauri == 'true' uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 with: - cache-suffix: ${{ steps.image.outputs.identity }} + enable-cache: false - name: Install locked music-core CMake in hosted Python prefix if: needs.ci-scope.outputs.desktop_tauri == 'true' @@ -1062,3 +1104,114 @@ jobs: if: always() && steps.image.outputs.identity != '' shell: bash run: bash scripts/ci-image-run.sh cleanup + + cross_runtime_integration: + needs: [ci-scope, ci-image-candidate] + # Pilot only. Activate the computed path scope when the verified image is promoted. + if: ${{ always() && (needs.ci-scope.result != 'success' || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped') }} + runs-on: ubuntu-24.04 + permissions: + contents: read + defaults: + run: + shell: bash ${{ github.workspace }}/scripts/ci-image-run.sh script {0} + env: + CI_SCOPE_RESULT: ${{ needs.ci-scope.result }} + CI_IMAGE_SELECTION: ${{ needs.ci-scope.outputs.image_selection }} + CI_IMAGE_CANDIDATE_RESULT: ${{ needs.ci-image-candidate.result }} + CI_IMAGE_ARTIFACT_ID: ${{ needs.ci-image-candidate.outputs.artifact_id }} + CI_USE_UV: "true" + RUST_VERSION: "1.98.0" + steps: + - name: Check out code + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.sha }} + persist-credentials: false + + - name: Require candidate for integration pilot + shell: bash + if: needs.ci-scope.outputs.image_selection != 'candidate' + run: exit 1 + + - name: Require selected CI image + shell: bash + run: bash scripts/ci-image-run.sh require + + - name: Download exact candidate image + if: needs.ci-scope.outputs.image_selection == 'candidate' + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + artifact-ids: ${{ needs.ci-image-candidate.outputs.artifact_id }} + path: ${{ runner.temp }}/ci-image + digest-mismatch: error + + - name: Load and validate selected CI image + id: image + shell: bash + run: bash scripts/ci-image-run.sh load "$RUNNER_TEMP/ci-image" + + - name: Set up Node + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: "26" + package-manager-cache: false + + - name: Set up Python for music-core source generation + uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 + with: + python-version-file: .python-version + + - name: Set up uv + uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 + with: + enable-cache: false + + - name: Install locked music-core CMake in hosted Python prefix + shell: bash + run: | + set -euo pipefail + cmake_wheel="$(node scripts/build-music-core.mjs --download-tool cmake --platform linux-x64)" + python -m pip install --no-index --no-deps "$cmake_wheel" + cmake --version + + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1 + with: + toolchain: ${{ env.RUST_VERSION }} + cache: false + rustflags: "" + + - name: Restore Cargo dependencies and build output + id: cargo + continue-on-error: true + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + apps/desktop/src-tauri/target + !apps/desktop/src-tauri/target/debug/incremental + key: cargo-v2-${{ steps.image.outputs.identity }}-${{ runner.os }}-${{ runner.arch }}-rust-${{ env.RUST_VERSION }}-${{ hashFiles('apps/desktop/src-tauri/Cargo.lock', 'apps/desktop/src-tauri/Cargo.toml') }} + + - name: Verify CI image + run: bash scripts/verify-ci-image.sh + + - name: Acquire verified music-core sources + run: node scripts/build-music-core.mjs --fetch-sources + + - name: Test Python producers and native reconciliation + run: node scripts/ci-cross-runtime.mjs --python /opt/tuneforge-ci/cross-runtime/venv/bin/python + + - name: Record Cargo cache outcome + if: always() + shell: bash + env: + CACHE_HIT: ${{ steps.cargo.outputs.cache-hit }} + CACHE_OUTCOME: ${{ steps.cargo.outcome }} + run: printf 'Cargo exact cache hit = %s (restore %s)\n' "${CACHE_HIT:-false}" "$CACHE_OUTCOME" >> "$GITHUB_STEP_SUMMARY" + + - name: Clean selected image + if: always() && steps.image.outputs.identity != '' + shell: bash + run: bash scripts/ci-image-run.sh cleanup diff --git a/apps/backend/pyproject.toml b/apps/backend/pyproject.toml index 0b258d2..c786ee5 100644 --- a/apps/backend/pyproject.toml +++ b/apps/backend/pyproject.toml @@ -51,6 +51,18 @@ environments = [ allow-direct-references = true [dependency-groups] +cross-runtime = [ + "alembic", + "cryptography", + "fastapi", + "huggingface-hub", + "librosa", + "numpy", + "pydantic", + "pyyaml", + "soundfile", + "sqlalchemy", +] dev = [ "hatchling>=1.32.0,<2.0.0", "httpx>=0.28.1,<1.0.0", diff --git a/apps/backend/uv.lock b/apps/backend/uv.lock index bfeace5..c6df3c7 100644 --- a/apps/backend/uv.lock +++ b/apps/backend/uv.lock @@ -1663,6 +1663,18 @@ lv-chordia = [ ] [package.dev-dependencies] +cross-runtime = [ + { name = "alembic" }, + { name = "cryptography" }, + { name = "fastapi" }, + { name = "huggingface-hub" }, + { name = "librosa" }, + { name = "numpy" }, + { name = "pydantic" }, + { name = "pyyaml" }, + { name = "soundfile" }, + { name = "sqlalchemy" }, +] dev = [ { name = "hatchling" }, { name = "httpx" }, @@ -1703,6 +1715,18 @@ requires-dist = [ provides-extras = ["advanced-chords", "advanced-chords-onnx", "advanced-beats", "lv-chordia"] [package.metadata.requires-dev] +cross-runtime = [ + { name = "alembic" }, + { name = "cryptography" }, + { name = "fastapi" }, + { name = "huggingface-hub" }, + { name = "librosa" }, + { name = "numpy" }, + { name = "pydantic" }, + { name = "pyyaml" }, + { name = "soundfile" }, + { name = "sqlalchemy" }, +] dev = [ { name = "hatchling", specifier = ">=1.32.0,<2.0.0" }, { name = "httpx", specifier = ">=0.28.1,<1.0.0" }, diff --git a/apps/desktop/src-tauri/src/mobile_backend/reconciliation.rs b/apps/desktop/src-tauri/src/mobile_backend/reconciliation.rs index bd0f5b0..364708b 100644 --- a/apps/desktop/src-tauri/src/mobile_backend/reconciliation.rs +++ b/apps/desktop/src-tauri/src/mobile_backend/reconciliation.rs @@ -1219,20 +1219,27 @@ mod tests { verify_native: Option<&Path>, ) { let backend = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../backend"); - let mut command = std::process::Command::new("uv"); + let python = std::env::var_os("TUNEFORGE_CROSS_RUNTIME_PYTHON") + .filter(|python| Path::new(python).is_absolute()) + .expect("run this test with node scripts/ci-cross-runtime.mjs"); + let home = root.join("home"); + fs::create_dir_all(&home).unwrap(); + let mut command = std::process::Command::new(python); command .current_dir(&backend) + .env_clear() + .env("PATH", std::env::var_os("PATH").unwrap()) + .env("HOME", home) + .env("TMPDIR", root) + .env("HF_HUB_OFFLINE", "1") + .env("NUMBA_CACHE_DIR", root.join("numba-cache")) .args([ - "run", - "--offline", - "--no-sync", - "--python", - "3.14", - "python", + "-IB", + "-c", + "import os, runpy, sys; sys.path.insert(0, os.getcwd()); script = sys.argv.pop(1); sys.argv[0] = script; runpy.run_path(script, run_name='__main__')", "tests/result_sync_fixture.py", ]) .arg(root) - .env("PYTHONPATH", &backend) .env("TUNEFORGE_DATA_DIR", root.join("backend-data")) .env( "TUNEFORGE_SYNC_TRANSPORT_DATA_DIR", @@ -1251,7 +1258,9 @@ mod tests { let output = command.output().unwrap(); assert!( output.status.success(), - "Synthetic Python fixture failed: {}", + "Synthetic Python fixture failed ({count} {variant}, native verify: {}):\n{}\n{}", + verify_native.is_some(), + String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr) ); } @@ -1375,9 +1384,8 @@ mod tests { apply_sync_reconciliation_parts(connection, receiver_root, payload, Vec::new()).unwrap() } - // Dedicated CI follow-up: TODO.md#cross-runtime-integration-ci. #[test] - #[ignore = "Requires the prepared Python backend; dedicated cross-runtime CI is pending."] + #[ignore = "Run with node scripts/ci-cross-runtime.mjs."] fn python_producers_native_apply_result_matrix_and_bidirectional_replay() { for (variant, count) in [ ("analysis", 1), @@ -1541,6 +1549,7 @@ mod tests { .unwrap()["estimated_reference_hz"], json!(432.0) ); + println!("verified native result return"); } } let manifest_ms = started.elapsed().as_millis(); diff --git a/scripts/ci-cross-runtime.mjs b/scripts/ci-cross-runtime.mjs new file mode 100644 index 0000000..78a854a --- /dev/null +++ b/scripts/ci-cross-runtime.mjs @@ -0,0 +1,104 @@ +import { spawnSync } from "node:child_process"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { delimiter, dirname, join, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; + +const repo = fileURLToPath(new URL("..", import.meta.url)); +const backend = join(repo, "apps/backend"); +const testName = + "mobile_backend::reconciliation::tests::python_producers_native_apply_result_matrix_and_bidirectional_replay"; +const cases = [ + "analysis:1", "chords:1", "stems:1", "chords-stems:1", "combined:1", "analysis:25", "analysis:194", +]; + +function checkPass(output) { + const lines = output.split(/\r?\n/); + const actual = lines.flatMap((line) => { + const match = /^result matrix variant=(\S+) projects=(\d+) /.exec(line); + return match ? [`${match[1]}:${match[2]}`] : []; + }); + if (!lines.includes("running 1 test") || !lines.includes(`test ${testName} ... ok`) || + !lines.some((line) => /^test result: ok\. 1 passed; 0 failed; 0 ignored;/.test(line)) || + actual.join(",") !== cases.join(",") || + lines.filter((line) => line === "verified native result return").length !== 1) { + throw new Error("Expected one passing ignored Rust test, all seven matrix cases and one verified native return"); + } +} + +function run(command, args, env) { + const child = spawnSync(command, args, { + cwd: repo, env, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"], maxBuffer: 16 * 1024 * 1024, + }); + if (child.error || child.status !== 0) { + if (child.stdout) process.stdout.write(child.stdout); + throw new Error(`${command} failed: ${child.error?.message ?? child.signal ?? `exit ${child.status}`}`); + } + return child.stdout; +} + +function main(args) { + if (args.length && (args.length !== 2 || args[0] !== "--python" || !args[1])) { + throw new Error("Usage: node scripts/ci-cross-runtime.mjs [--python path/to/python]"); + } + const python = args.length ? resolve(args[1]) : join(backend, ".venv/bin/python"); + const pinnedPython = readFileSync(join(repo, ".python-version"), "utf8").trim(); + const soxr = process.env.TUNEFORGE_SOXR_ROOT; + if (!soxr) throw new Error("TUNEFORGE_SOXR_ROOT must point to the repository-built host-test runtime"); + const soxrRoot = resolve(soxr); + const soxrLib = join(soxrRoot, "lib"); + const extension = process.platform === "darwin" ? "dylib" : "so"; + if (!statSync(join(soxrRoot, "include/soxr.h")).isFile() || + !statSync(join(soxrLib, `libsoxr.${extension}`)).isFile() || + !readFileSync(join(soxrRoot, "provenance.json"), "utf8").includes('"-DWITH_PFFFT=ON"')) { + throw new Error(`Invalid SoXR host-test runtime: ${soxrRoot}`); + } + const fixture = join(backend, "tests/result_sync_fixture.py"); + if (!statSync(fixture).isFile()) throw new Error(`Missing Python producer fixture: ${fixture}`); + + const root = mkdtempSync(join(tmpdir(), "tuneforge-cross-runtime-")); + try { + const home = join(root, "home"); + mkdirSync(home); + const path = process.env.PATH; + const probeEnv = { PATH: path, HOME: home, TMPDIR: root, XDG_CACHE_HOME: join(root, "cache") }; + const version = run(python, ["-IB", "-c", + "import platform; print(platform.python_implementation(), platform.python_version())"], probeEnv).trim(); + if (version !== `CPython ${pinnedPython}`) { + throw new Error(`Expected CPython ${pinnedPython}, got ${version} from ${python}`); + } + run(python, ["-IB", "-c", + "import alembic, cryptography, fastapi, numpy, soundfile, sqlalchemy; from tuneforge_music_core import _native"], + probeEnv); + run("ffmpeg", ["-version"], probeEnv); + run("ffprobe", ["-version"], probeEnv); + + const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => + !/^(TUNEFORGE_|PYTHON|DYLD_|HF_|HUGGINGFACE_|TORCH_|XDG_|APPDATA$|LOCALAPPDATA$)/.test(name))); + const loader = process.platform === "darwin" ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH"; + const cargoHome = process.env.CARGO_HOME ?? join(process.env.HOME ?? dirname(home), ".cargo"); + const rustupHome = process.env.RUSTUP_HOME ?? join(process.env.HOME ?? dirname(home), ".rustup"); + const started = performance.now(); + const output = run("cargo", [ + "test", "--locked", "--color", "never", "--manifest-path", "apps/desktop/src-tauri/Cargo.toml", + "--lib", testName, "--", "--exact", "--ignored", "--show-output", + ], { + ...env, HOME: home, CARGO_HOME: cargoHome, RUSTUP_HOME: rustupHome, + TMPDIR: root, TMP: root, TEMP: root, XDG_CACHE_HOME: join(root, "cache"), + TUNEFORGE_SOXR_ROOT: soxrRoot, TUNEFORGE_CROSS_RUNTIME_PYTHON: python, + [loader]: [soxrLib, process.env[loader]].filter(Boolean).join(delimiter), + }); + process.stdout.write(output); + checkPass(output); + console.log(`Cross-runtime matrix passed in ${((performance.now() - started) / 1000).toFixed(1)}s (Cargo and tests)`); + } finally { + rmSync(root, { recursive: true, force: true }); + } +} + +try { + main(process.argv.slice(2)); +} catch (error) { + console.error(error.message); + process.exitCode = 1; +} diff --git a/scripts/ci-cross-runtime.test.mjs b/scripts/ci-cross-runtime.test.mjs new file mode 100644 index 0000000..1573cf9 --- /dev/null +++ b/scripts/ci-cross-runtime.test.mjs @@ -0,0 +1,119 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { delimiter, join } from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +const launcher = fileURLToPath(new URL("./ci-cross-runtime.mjs", import.meta.url)); +const pin = readFileSync(new URL("../.python-version", import.meta.url), "utf8").trim(); +const name = "mobile_backend::reconciliation::tests::python_producers_native_apply_result_matrix_and_bidirectional_replay"; +const cases = ["analysis 1", "chords 1", "stems 1", "chords-stems 1", "combined 1", "analysis 25", "analysis 194"]; +const passed = [ + "running 1 test", + `test ${name} ... ok`, + ...cases.map((entry) => { + const [variant, count] = entry.split(" "); + return `result matrix variant=${variant} projects=${count} initial_import_ms=0`; + }), + "verified native result return", + "test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 589 filtered out", +].join("\n"); + +function fixture(context, options = {}) { + const root = mkdtempSync(join(tmpdir(), "cross-runtime-launcher-test-")); + context.after(() => rmSync(root, { force: true, recursive: true })); + const bin = join(root, "bin"); + const soxr = join(root, "soxr"); + mkdirSync(bin); + mkdirSync(join(soxr, "include"), { recursive: true }); + mkdirSync(join(soxr, "lib")); + writeFileSync(join(soxr, "include/soxr.h"), ""); + writeFileSync(join(soxr, `lib/libsoxr.${process.platform === "darwin" ? "dylib" : "so"}`), ""); + writeFileSync(join(soxr, "provenance.json"), '{"options":["-DWITH_PFFFT=ON"]}'); + function tool(name, script) { + const path = join(bin, name); + writeFileSync(path, `#!${process.execPath}\n${script}\n`, { mode: 0o700 }); + return path; + } + const python = tool("python", ` +if (process.env.PYTHONPATH || process.env.TUNEFORGE_DATA_DIR) process.exit(6); +if (process.argv[4].includes("platform")) console.log(${JSON.stringify(options.version ?? `CPython ${pin}`)}); +else if (${options.missingBindings ?? false}) { console.error("No module named tuneforge_music_core"); process.exit(1); } +`); + tool("cargo", ` +const fs = require("node:fs"); +fs.writeFileSync(${JSON.stringify(join(root, "cargo.json"))}, JSON.stringify({ + args: process.argv.slice(2), + home: process.env.HOME, tmp: process.env.TMPDIR, data: process.env.TUNEFORGE_DATA_DIR, + model: process.env.TUNEFORGE_MODEL_BUNDLE_DIR, python: process.env.TUNEFORGE_CROSS_RUNTIME_PYTHON, +})); +console.log(${JSON.stringify(options.output ?? passed)}); +process.exit(${options.exit ?? 0}); +`); + tool("ffmpeg", ""); + tool("ffprobe", options.missingFfprobe ? "process.exit(127);" : ""); + const result = spawnSync(process.execPath, [launcher, "--python", python], { + env: { + ...process.env, + PATH: [bin, process.env.PATH].join(delimiter), + TMPDIR: root, + TUNEFORGE_SOXR_ROOT: options.missingSoxr ? "" : soxr, + TUNEFORGE_DATA_DIR: join(root, "unexpected-data"), + TUNEFORGE_MODEL_BUNDLE_DIR: join(root, "unexpected-models"), + PYTHONPATH: join(root, "unexpected-imports"), + }, + encoding: "utf8", + }); + const record = join(root, "cargo.json"); + return { result, python, cargo: existsSync(record) ? JSON.parse(readFileSync(record, "utf8")) : null }; +} + +test("launcher requires the exact ignored library test and cleans up isolated roots", (context) => { + const { result, cargo, python } = fixture(context); + assert.equal(result.status, 0, result.stderr); + assert.deepEqual(cargo.args, ["test", "--locked", "--color", "never", "--manifest-path", + "apps/desktop/src-tauri/Cargo.toml", "--lib", name, "--", "--exact", "--ignored", "--show-output"]); + assert.equal(cargo.data, undefined); + assert.equal(cargo.model, undefined); + assert.equal(cargo.python, python); + assert.equal(cargo.home, join(cargo.tmp, "home")); + assert.equal(existsSync(cargo.tmp), false); +}); + +test("launcher rejects silent test selection and incomplete matrix output", (context) => { + for (const output of [ + "running 0 tests\ntest result: ok. 0 passed; 0 failed; 0 ignored;", + passed.replace(name, "a::different_test"), + passed.replace("result matrix variant=analysis projects=194", "result matrix variant=analysis projects=193"), + passed.replace("verified native result return", ""), + ]) { + const { result, cargo } = fixture(context, { output }); + assert.ok(cargo); + assert.equal(result.status, 1); + assert.match(result.stderr, /Expected one passing ignored Rust test/); + } +}); + +test("launcher fails before Cargo for wrong Python, binding or FFmpeg/SoXR prerequisites", (context) => { + for (const [options, error] of [ + [{ version: "CPython 3.14.0" }, /Expected CPython/], + [{ missingBindings: true }, /No module named tuneforge_music_core/], + [{ missingFfprobe: true }, /ffprobe failed/], + [{ missingSoxr: true }, /TUNEFORGE_SOXR_ROOT/], + ]) { + const { result, cargo } = fixture(context, options); + assert.equal(cargo, null); + assert.equal(result.status, 1); + assert.match(result.stderr, error); + } +}); + +test("launcher preserves Cargo and fixture errors and cleans up after failure", (context) => { + const { result, cargo } = fixture(context, { output: "Synthetic Python fixture failed", exit: 101 }); + assert.equal(result.status, 1); + assert.match(result.stdout, /Synthetic Python fixture failed/); + assert.match(result.stderr, /cargo failed: exit 101/); + assert.equal(existsSync(cargo.tmp), false); +}); diff --git a/scripts/ci-image-impact.test.mjs b/scripts/ci-image-impact.test.mjs index 6386b0e..1ce7e17 100644 --- a/scripts/ci-image-impact.test.mjs +++ b/scripts/ci-image-impact.test.mjs @@ -41,14 +41,14 @@ test("equivalent planned path spelling cannot miss producer impact", () => { assert.deepEqual(impacts.map((impact) => impact.path), ["scripts/build-soxr-runtime.mjs", "scripts/build-soxr-runtime.mjs", ".github/ci/Dockerfile"]); assert.throws(() => imageImpact(["scripts/../scripts/build-soxr-runtime.mjs"], root), /Unsafe planned/); - assert.equal(imageImpact([".python-version"], root)[0].classification, "consumer-compatibility"); + assert.equal(imageImpact([".python-version"], root)[0].classification, "producer"); }); test("every registered producer byte changes whole recipe identity; promotion does not", (context) => { const directory = fixture(context); const before = producerIdentity(directory); assert.match(before.fingerprint, /^[a-f0-9]{64}$/); - for (const input of [".github/ci/Dockerfile", ".github/ci/README.md"]) { + for (const input of [".github/ci/Dockerfile", ".github/ci/README.md", ".github/ci/cross-runtime-requirements.txt"]) { const original = fs.readFileSync(path.join(directory, input)); fs.appendFileSync(path.join(directory, input), "\n# changed\n"); assert.notEqual(producerIdentity(directory).fingerprint, before.fingerprint, input); diff --git a/scripts/ci-image-policy.mjs b/scripts/ci-image-policy.mjs index d7b58a5..d7e93d9 100644 --- a/scripts/ci-image-policy.mjs +++ b/scripts/ci-image-policy.mjs @@ -56,7 +56,7 @@ const playwrightNoblePackages = [ "libxrandr2", ]; -const ciImageConsumers = ["backend", "e2e", "desktop_tauri", "music-core-wasm"]; +const ciImageConsumers = ["backend", "e2e", "desktop_tauri", "cross_runtime_integration", "music-core-wasm"]; function read(root, relativePath) { return fs.readFileSync(path.join(root, relativePath), "utf8"); } @@ -135,7 +135,7 @@ function verifierCallIndexes(block) { } function lockedCmakeInstallStep(name) { - const condition = name === "e2e" ? [] : [" if: " + (name === "backend" + const condition = ["e2e", "cross_runtime_integration"].includes(name) ? [] : [" if: " + (name === "backend" ? "needs.ci-scope.outputs.backend_static == 'true' || needs.ci-scope.outputs.backend_ffmpeg == 'true'" : `needs.ci-scope.outputs.${name === "desktop_frontend" ? "desktop" : "desktop_tauri"} == 'true'`)]; return [ @@ -285,12 +285,17 @@ export function validateCiImagePolicy(root) { const baseImages = [...dockerfile.matchAll( /^FROM (\S+)(?: AS (\S+))?$/gm, )].map((match) => ({ image: match[1], stage: match[2] })); + const ubuntu = baseImages[0]?.image; check( - baseImages.length === 3 && - baseImages[0].stage === "soxr-builder" && - baseImages[1].stage === "music-core-builder" && - baseImages[2].stage === undefined && - baseImages.every(base => base.image === baseImages[0].image) && + /^ubuntu:24\.04@sha256:[a-f0-9]{64}$/.test(ubuntu) && + JSON.stringify(baseImages) === JSON.stringify([ + { image: ubuntu, stage: "soxr-builder" }, + { image: ubuntu, stage: "music-core-tools" }, + { image: "music-core-tools", stage: "music-core-builder" }, + { image: "music-core-tools", stage: "cross-runtime-builder" }, + { image: ubuntu, stage: "shared-base" }, + { image: "shared-base", stage: "shared-final" }, + ]) && !dockerfile.includes("FROM --platform="), "CI image must use the same pinned Ubuntu base without constant FROM platform flags", ); @@ -323,11 +328,18 @@ export function validateCiImagePolicy(root) { dockerfile.includes('"${MUSIC_' + tool + '_SHA256}" /tmp/' + tool.toLowerCase() + (tool === "NODE" ? '.tar.xz' : tool === "UV" ? '.whl' : '.tar.gz') + ' | sha256sum -c -'), "Music-core builder must checksum-pin " + tool + " bootstrap artifacts"); } - const finalStage = dockerfile.slice(dockerfile.lastIndexOf("FROM ")); + const sharedBaseStart = dockerfile.indexOf(`FROM ${ubuntu} AS shared-base`); + const finalStage = dockerfile.slice(sharedBaseStart); check(!/COPY --from=music-core-builder (?!\/opt\/tuneforge-ci\/music-core |\/tmp\/producer-inputs.sha256 )/.test(finalStage) && !/apt-get install[^;]*(?:nodejs|python3|emscripten)/.test(finalStage), "Music-core build tools and checkout must remain outside final image"); - const builderStages = dockerfile.slice(0, dockerfile.lastIndexOf("FROM ")); + const builderStages = dockerfile.slice(0, sharedBaseStart); + const fixtureBuilder = builderStages.slice(builderStages.indexOf("FROM music-core-tools AS cross-runtime-builder")); + check(fixtureBuilder.includes('--require-hashes --only-binary :all: -r "$deps"') && + fixtureBuilder.includes("node scripts/build-music-core.mjs --target python --python 3.14 --check") && + dockerArg(dockerfile, "MUSIC_PYTHON_VERSION") === read(root, ".python-version").trim() && + finalStage.endsWith("FROM shared-base AS shared-final\nCOPY --from=cross-runtime-builder /opt/tuneforge-ci/cross-runtime /opt/tuneforge-ci/cross-runtime\n"), + "The shared fixture layer must contain only the finished pinned CPython, wheel-only dependency payload and verified native binding"); check(/apt-get install[^;]*\sclang-18\s/.test(finalStage) && finalStage.includes("ENV CC=/usr/bin/clang-18 CXX=/usr/bin/clang++-18") && !/^ENV .*\b(?:CC|CXX)=/m.test(builderStages) && @@ -521,7 +533,7 @@ export function validateCiImagePolicy(root) { const scopeBlock = workflowJobBlock(mainWorkflow, "ci-scope"); check(scopeBlock.includes("image_selection: ${{ steps.image.outputs.selection }}") && scopeBlock.includes("run: bash scripts/ci-image-run.sh select") && scopeBlock.includes("run: node scripts/ci-image-impact.mjs --check") && - ["backend_static", "backend_ffmpeg", "desktop_tauri"].every((name) => scopeBlock.split("\n").some((line) => line.includes(name + ": ") && line.includes("steps.image.outputs.selection != 'promoted'"))), + ["backend_static", "backend_ffmpeg", "desktop_tauri", "cross_runtime_integration"].every((name) => scopeBlock.split("\n").some((line) => line.includes(name + ": ") && line.includes("steps.image.outputs.selection != 'promoted'"))), "Image selection must compare the full checkout recipe and force consumer gates during bootstrap or a promotion gap"); for (const name of ciImageConsumers) { const block = workflowJobBlock(mainWorkflow, name); @@ -530,9 +542,11 @@ export function validateCiImagePolicy(root) { let scheduling = "${{ always() }}"; if (name === "e2e") { scheduling = "${{ always() && (needs.ci-scope.result != 'success' || " + - "needs.ci-scope.outputs.codex_only != 'true' || needs.ci-scope.outputs.image_selection != 'promoted' || " + + "(needs.ci-scope.outputs.codex_only != 'true' && needs.ci-scope.outputs.native_only != 'true') || needs.ci-scope.outputs.image_selection != 'promoted' || " + "needs.ci-image-candidate.result != 'skipped' || needs.music-core-wasm.result != 'success' || " + "needs.music-core-wasm.outputs.artifact_id == '') }}"; + } else if (name === "cross_runtime_integration") { + scheduling = "${{ always() && (needs.ci-scope.result != 'success' || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped') }}"; } else if (name !== "music-core-wasm") { scheduling = "${{ always() && (needs.ci-image-candidate.result == 'failure' || needs.ci-image-candidate.result == 'cancelled' || needs.ci-scope.result != 'success' || " + (name === "backend" ? "needs.ci-scope.outputs.backend_static == 'true' || needs.ci-scope.outputs.backend_ffmpeg == 'true'" : "needs.ci-scope.outputs.desktop_tauri == 'true'") + ") }}"; @@ -563,13 +577,27 @@ export function validateCiImagePolicy(root) { } check(JSON.stringify(jobs.filter(({ block }) => verifierCallIndexes(block).length).map(({ name }) => name).sort()) === JSON.stringify([...ciImageConsumers].sort()), "Only CI image consumers may call the shared verifier"); const e2eBlock = workflowJobBlock(mainWorkflow, "e2e"), tauriBlock = workflowJobBlock(mainWorkflow, "desktop_tauri"); + const crossRuntimeBlock = workflowJobBlock(mainWorkflow, "cross_runtime_integration"); check(e2eBlock.includes("pnpm --filter @tuneforge/desktop exec playwright install chromium"), "e2e must install only the lockfile-matched Chromium browser at runtime"); check(e2eBlock.includes(".github/ci/.selected-image-key") && ["backend", "e2e"].every((name) => workflowJobBlock(mainWorkflow, name).includes("cache-suffix: ${{ steps.image.outputs.identity }}")), "pnpm and uv caches must include selected image and producer identity"); check(tauriBlock.includes("uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659") && tauriBlock.includes("toolchain: ${{ env.RUST_VERSION }}") && tauriBlock.includes(" cache: false\n") && tauriBlock.includes('rustflags: ""'), "desktop_tauri must bootstrap pinned Rust without action-managed caching or rustflags"); check((tauriBlock.match(/uses: actions\/cache@/g) ?? []).length === 1 && tauriBlock.includes("key: cargo-v2-${{ steps.image.outputs.identity }}-") && tauriBlock.includes('soxr_root="${TUNEFORGE_SOXR_ROOT:?}"') && !tauriBlock.includes("node scripts/build-soxr.mjs"), "desktop_tauri must use one image-keyed Cargo cache and the prebuilt SoXR payload"); - for (const name of ["backend", "e2e", "desktop_tauri", "desktop_frontend"]) { + const cacheSettings = (job) => job.match(/^ path: \|\n((?: {12}[^\n]+\n)+) key: (cargo-v2-[^\n]+)$/m)?.[0]; + check(crossRuntimeBlock.includes("uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9") && + !/uses: actions\/cache(?:@|\/save@)|restore-keys:/.test(crossRuntimeBlock) && + cacheSettings(crossRuntimeBlock) && cacheSettings(crossRuntimeBlock) === cacheSettings(tauriBlock) && + crossRuntimeBlock.match(/^ RUST_VERSION: .*$/m)?.[0] === tauriBlock.match(/^ RUST_VERSION: .*$/m)?.[0] && + [tauriBlock, crossRuntimeBlock].every((job) => /uses: astral-sh\/setup-uv@[^\n]+\n with:\n enable-cache: false\n/.test(job)), + "Cross-runtime integration restores the exact Tauri Cargo cache without writing; both Rust jobs disable persistent uv caching"); + const matrix = crossRuntimeBlock.indexOf("run: node scripts/ci-cross-runtime.mjs --python /opt/tuneforge-ci/cross-runtime/venv/bin/python"); + const acquisition = crossRuntimeBlock.indexOf("run: node scripts/build-music-core.mjs --fetch-sources"); + check(acquisition > verifierCallIndexes(crossRuntimeBlock)[0] && matrix > acquisition && + crossRuntimeBlock.includes("if: needs.ci-scope.outputs.image_selection != 'candidate'\n run: exit 1") && + !/\buv (?:sync|pip)\b/.test(crossRuntimeBlock), + "The candidate pilot must require the verified image, native sources, and one launcher without backend setup"); + for (const name of ["backend", "e2e", "desktop_tauri", "desktop_frontend", "cross_runtime_integration"]) { const block = workflowJobBlock(mainWorkflow, name); const install = lockedCmakeInstallStep(name); const remaining = block.replace(install, ""); diff --git a/scripts/ci-image-policy.test.mjs b/scripts/ci-image-policy.test.mjs index 967cbbe..9e45319 100644 --- a/scripts/ci-image-policy.test.mjs +++ b/scripts/ci-image-policy.test.mjs @@ -356,7 +356,7 @@ test("candidate consumers reject artifact substitution and verification skip-gre [" - name: Verify CI image\n run:", " - name: Verify CI image\n if: false\n run:"], [" - name: Require selected CI image\n shell: bash", " - name: Require selected CI image\n continue-on-error: true\n shell: bash"], [" if: ${{ always() }}", " if: ${{ false && always() }}"], - [" || needs.ci-scope.outputs.codex_only != 'true'", ""], + [" || (needs.ci-scope.outputs.codex_only != 'true' && needs.ci-scope.outputs.native_only != 'true')", ""], [" || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped'", ""], [" || needs.music-core-wasm.result != 'success' || needs.music-core-wasm.outputs.artifact_id", " || needs.music-core-wasm.outputs.artifact_id"], [" || needs.music-core-wasm.outputs.artifact_id == ''", ""], @@ -368,6 +368,24 @@ test("whole recipe selection cannot lose promotion-gap gates", () => assertMutationsFail(".github/workflows/ci.yml", [["steps.image.outputs.selection != 'promoted'", "false"], ["run: bash scripts/ci-image-run.sh select", "run: echo promoted"]], /force consumer gates/)); +test("the cross-runtime pilot rejects writable or different caches and missing validation", () => { + assertMutationsFail(".github/workflows/ci.yml", [ + ["uses: actions/cache/restore@", "uses: actions/cache@"], + ["key: cargo-v2-", "key: different-"], + ["enable-cache: false", "enable-cache: true"], + ["--python /opt/tuneforge-ci/cross-runtime/venv/bin/python", "--python apps/backend/.venv/bin/python"], + ["if: needs.ci-scope.outputs.image_selection != 'candidate'\n run: exit 1", "run: true"], + ], /must use one image-keyed|restores the exact Tauri Cargo cache|candidate pilot must require/); +}); + +test("the cross-runtime producer rejects unverified dependencies and wheel", () => { + assertMutationsFail(".github/ci/Dockerfile", [ + ["--require-hashes --only-binary :all:", "--only-binary :all:"], + ["node scripts/build-music-core.mjs --target python --python 3.14 --check", "true"], + ["FROM shared-base AS shared-final", "FROM cross-runtime-builder AS shared-final"], + ], /same pinned Ubuntu base|shared fixture layer/); +}); + test("promotion cannot trigger publisher and branch dispatch cannot publish", () => assertMutationsFail(".github/workflows/ci-image.yml", [[" - .github/ci/Dockerfile", " - .github/ci/**"], [" if: github.ref == 'refs/heads/main'", " if: true"]], /trusted main image inputs/)); diff --git a/scripts/ci-scope-policy.test.mjs b/scripts/ci-scope-policy.test.mjs index 8912085..434c271 100644 --- a/scripts/ci-scope-policy.test.mjs +++ b/scripts/ci-scope-policy.test.mjs @@ -13,15 +13,25 @@ function caseArm(pattern) { return match[0]; } -test("CI reads the exact Python pin once and leaves uv project selection unoverridden", () => { +test("CI reads the exact Python pin and leaves uv project selection unoverridden", () => { const pythonSetups = workflow.match(/uses: actions\/setup-python@[\s\S]*?python-version-file: \.python-version/g) ?? []; - assert.equal(pythonSetups.length, 4); + assert.equal(pythonSetups.length, 6); assert.doesNotMatch(workflow, /python-version: "3\.14"/); assert.doesNotMatch(workflow, /python-version:.*3\.14/); assert.doesNotMatch(workflow, /uv run --python/); }); +test("a cold script-tests runner provisions pinned Python and uv before checking the offline projection", () => { + const job = workflow.slice(workflow.indexOf(" script-tests:\n"), workflow.indexOf(" e2e:\n")); + const python = job.indexOf("python-version-file: .python-version"); + const uv = job.indexOf('version: "0.13.6"'); + const check = job.indexOf("uv export --offline --locked"); + assert.ok(python >= 0 && python < uv && uv < check); + assert.match(job, /uses: actions\/setup-python@[a-f0-9]{40}/); + assert.match(job, /diff -u \.github\/ci\/cross-runtime-requirements\.txt -/); +}); + test("WASM consumers require the selected image payload and verify the same-run artifact before use", () => { const producer = workflow.slice(workflow.indexOf(" music-core-wasm:\n"), workflow.indexOf("\n commitlint:")); assert.match(producer, /runs-on: ubuntu-24\.04/); @@ -56,7 +66,8 @@ test("native CI installs locked CMake on the host before source consumers enter [" e2e:\n", " site:\n", "uv sync --locked --all-groups"], [" backend:\n", " desktop_frontend:\n", "uv sync --locked --all-groups"], [" desktop_frontend:\n", " desktop_tauri:\n", "uv sync --locked --all-groups"], - [" desktop_tauri:\n", null, "run: cargo check"], + [" desktop_tauri:\n", " cross_runtime_integration:\n", "run: cargo check"], + [" cross_runtime_integration:\n", null, "run: node scripts/ci-cross-runtime.mjs"], ]) { const job = workflow.slice(workflow.indexOf(start), end ? workflow.indexOf(end) : undefined); const install = job.indexOf(" - name: Install locked music-core CMake in hosted Python prefix\n"); @@ -71,7 +82,11 @@ test("native CI installs locked CMake on the host before source consumers enter }); test("release-media CI scope captures desktop-affecting changes without widening site-only checks", () => { - assert.match(workflow, /release_media: \$\{\{ steps\.scope\.outputs\.release_media \}\}/); + for (const gate of ["desktop", "release_media", "site"]) { + assert.ok(workflow.includes( + `${gate}: ${"$"}{{ steps.scope.outputs.${gate} == 'true' && (steps.scope.outputs.native_only != 'true' || steps.image.outputs.selection != 'promoted') }}`, + )); + } assert.match(workflow, /release_media=false/); assert.match(workflow, /echo "release_media=\$\{release_media\}"/); const captureScript = caseArm(String.raw`scripts/capture-release-media\.mjs\|scripts/check-release-version\.mjs\)`); @@ -113,7 +128,7 @@ test(".codex changes and third-party notices remain documentation-only CI scope" assert.doesNotMatch(imageInputs, /THIRD_PARTY_NOTICES\.md/); const documentation = caseArm( - String.raw`\.agents/\*\|\.codex/\*\|docs/\*\|CHANGELOG\.md\|README\.md\|CONTRIBUTING\.md\|CODE_OF_CONDUCT\.md\|LICENSE\|THIRD_PARTY_NOTICES\.md\|SECURITY\.md\|AGENTS\.md\|\.gitignore\|packaging/flatpak/\*\|\.github/ISSUE_TEMPLATE/\*\|\.github/PULL_REQUEST_TEMPLATE\.md\)`, + String.raw`\.agents/\*\|\.codex/\*\|docs/\*\|CHANGELOG\.md\|README\.md\|CONTRIBUTING\.md\|CODE_OF_CONDUCT\.md\|LICENSE\|THIRD_PARTY_NOTICES\.md\|SECURITY\.md\|AGENTS\.md\|TODO\.md\|\.gitignore\|packaging/flatpak/\*\|\.github/ISSUE_TEMPLATE/\*\|\.github/PULL_REQUEST_TEMPLATE\.md\)`, ); assert.doesNotMatch( documentation, @@ -122,7 +137,7 @@ test(".codex changes and third-party notices remain documentation-only CI scope" }); -test("only nonempty .codex pull request diffs exempt script tests", (context) => { +test("PR scope handles release, Codex, and cross-runtime paths, renames, deletions and diff failure", (context) => { const scope = workflow.slice( workflow.indexOf(" - name: Determine CI scope\n"), workflow.indexOf(" - name: Select whole CI image recipe\n"), @@ -157,7 +172,7 @@ test("only nonempty .codex pull request diffs exempt script tests", (context) => ...(parent ? ["-p", parent] : []), "-m", "CI scope fixture"]); } - function check(label, base, head, codexOnly, { event = "pull_request", desktop } = {}) { + function check(label, base, head, codexOnly, { event = "pull_request", ...expected } = {}) { const script = shell.replaceAll("${{ github.event_name }}", event) .replaceAll("${{ github.event.pull_request.base.sha }}", base) .replaceAll("${{ github.event.pull_request.head.sha }}", head); @@ -165,7 +180,9 @@ test("only nonempty .codex pull request diffs exempt script tests", (context) => execFileSync("bash", ["-c", script], { cwd: directory, env, stdio: "pipe" }); const flags = Object.fromEntries(readFileSync(output, "utf8").trim().split("\n").map((line) => line.split("="))); assert.equal(flags.codex_only, String(codexOnly), label); - if (desktop !== undefined) assert.equal(flags.desktop, String(desktop), label); + for (const [name, value] of Object.entries(expected)) { + assert.equal(flags[name], String(value), `${label}: ${name}`); + } } const commonFiles = { ".codex/config.toml": "original", "apps/desktop/example.ts": "original desktop" }; @@ -184,19 +201,58 @@ test("only nonempty .codex pull request diffs exempt script tests", (context) => check("rename out of .codex", common, commit({ "config.toml": "original", "apps/desktop/example.ts": "original desktop" }, common), false); check("similar prefix", common, commit({ ...commonFiles, ".codex-other/config.toml": "new" }, common), false); check("empty diff", common, common, false); - check("missing base revision", "missing", codexHead, false); - check("unrelated histories", common, commit(codexFiles), false); - check("push", common, codexHead, false, { event: "push" }); + check("missing base revision", "missing", codexHead, false, { cross_runtime_integration: true }); + check("unrelated histories", common, commit(codexFiles), false, { cross_runtime_integration: true }); + check("push", common, codexHead, false, { event: "push", cross_runtime_integration: true }); + + for (const path of [ + "apps/backend/app/services/sync_bundle.py", + "apps/backend/app/api/routes/projects.py", + "apps/backend/alembic/versions/0001_base.py", + "apps/backend/alembic.ini", + "apps/backend/tests/result_sync_fixture.py", + "apps/backend/tests/fixtures/bundle.json", + "apps/backend/pyproject.toml", "apps/backend/uv.lock", + "packages/music-core/src/core.cpp", "packaging/soxr/sources.lock.json", ".github/workflows/ci.yml", + ]) { + check(path, common, commit({ ...commonFiles, [path]: "new" }, common), false, + { cross_runtime_integration: true }); + } + for (const path of ["apps/desktop/src/playback.tsx", "apps/site/src/App.tsx", "docs/guide.md", "TODO.md", + "apps/backend/tests/test_unrelated.py", "packages/shared-types/src/generated/openapi.ts"]) { + check(path, common, commit({ ...commonFiles, [path]: "new" }, common), false, + { cross_runtime_integration: false }); + } + const native = commit({ ...commonFiles, "apps/desktop/src-tauri/src/test\ncase.rs": "native" }, common); + const nativeScope = { desktop: false, desktop_tauri: true, native_only: true, + cross_runtime_integration: true, site: false, release_media: false }; + check("native edit", common, native, false, nativeScope); + check("native deletion", native, commit(commonFiles, native), false, nativeScope); + check("native-only PR with web drift in main", main, native, false, + { ...nativeScope, desktop: true, site: true, release_media: true }); + check("rename native into frontend", native, commit({ ...commonFiles, "apps/desktop/src/test.rs": "native" }, native), + false, { desktop: true, native_only: false, cross_runtime_integration: true, site: true }); + const fixture = { ...commonFiles, "apps/backend/tests/result_sync_fixture.py": "fixture" }; + const fixtureHead = commit(fixture, common); + check("rename fixture out of backend", fixtureHead, + commit({ ...commonFiles, "docs/moved_fixture.py": "fixture" }, fixtureHead), false, { cross_runtime_integration: true }); + const backendMain = commit({ ...commonFiles, "apps/backend/app/api/routes/projects.py": "only main backend" }, common); + const siteOnly = commit({ ...commonFiles, "apps/site/src/page.tsx": "only PR web" }, common); + check("site-only PR with backend drift in main", backendMain, siteOnly, false, + { native_only: false, cross_runtime_integration: false, backend_static: true, desktop: true, site: true }); }); test("producer inputs retain real gates and promotion gaps force all image consumer gates", () => { assert.match(caseArm(String.raw`scripts/\*\)`), /full_gate=true/); assert.match(caseArm(String.raw`\.github/ci/\*\|\.github/workflows/ci-image\.yml\|\.github/workflows/ci\.yml\|packaging/soxr/\*\)`), /full_gate=true/); assert.match(workflow, /run: bash scripts\/ci-image-run\.sh select/); - for (const flag of ["backend_static", "backend_ffmpeg", "desktop_tauri"]) { + for (const flag of ["backend_static", "backend_ffmpeg", "desktop_tauri", "cross_runtime_integration"]) { assert.match(workflow.split("\n").find((line) => line.includes(`${flag}: `)), /steps\.image\.outputs\.selection != 'promoted'/); } const candidate = workflow.slice(workflow.indexOf(" ci-image-candidate:\n"), workflow.indexOf("\n commitlint:")); assert.match(candidate, /needs: ci-scope/); assert.match(candidate, /always\(\).*needs\.ci-scope\.result != 'success'/); + const pilot = workflow.slice(workflow.indexOf(" cross_runtime_integration:\n")); + assert.match(pilot, /needs\.ci-scope\.outputs\.image_selection != 'promoted'/); + assert.match(pilot, /if: needs\.ci-scope\.outputs\.image_selection != 'candidate'\n run: exit 1/); }); diff --git a/scripts/qualify-ci-cross-runtime.sh b/scripts/qualify-ci-cross-runtime.sh new file mode 100644 index 0000000..e9b2d6b --- /dev/null +++ b/scripts/qualify-ci-cross-runtime.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "$(dirname "$0")/.." +work="$(mktemp -d "${TMPDIR:-/tmp}/tuneforge-ci-qualify.XXXXXX")" +suffix="${work##*.}" +shared="tuneforge-ci-qualify:shared-${suffix}" +base="tuneforge-ci-qualify:base-${suffix}" +container= +owns_images=false +cleanup() { + if [[ -n "$container" ]]; then docker rm "$container" >/dev/null || true; fi + if "$owns_images"; then docker image rm "$shared" "$base" >/dev/null 2>&1 || true; fi + rm -rf "$work" +} +trap cleanup EXIT + +if [[ "$#" = 0 ]]; then + owns_images=true + started="$(date +%s)" + docker build --platform linux/amd64 --no-cache --pull --file .github/ci/Dockerfile --tag "$shared" . + printf 'Shared cold build: %s s\n' "$(( $(date +%s) - started ))" + started="$(date +%s)" + docker build --platform linux/amd64 --file .github/ci/Dockerfile --target shared-base --tag "$base" . + printf 'Base build with shared layers cached: %s s\n' "$(( $(date +%s) - started ))" +elif [[ "$#" = 2 ]]; then + shared="$1" + base="$2" +else + echo "Usage: bash scripts/qualify-ci-cross-runtime.sh [SHARED_IMAGE BASE_IMAGE]" >&2 + exit 1 +fi + +shared_layers="$(docker image inspect --format '{{json .RootFS.Layers}}' "$shared")" +base_layers="$(docker image inspect --format '{{json .RootFS.Layers}}' "$base")" +node --input-type=module -e ' + const [shared, base] = process.argv.slice(1).map(JSON.parse); + if (shared.length !== base.length + 1 || base.some((layer, index) => layer !== shared[index])) { + throw new Error("Expected identical shared base layers with exactly one additional payload layer"); + } +' "$shared_layers" "$base_layers" + +archive() { + local label="$1" image="$2" started + started="$(date +%s)" + docker image save "$image" | gzip -n -6 > "$work/$label.tar.gz" + printf '%s Docker archive: %s bytes, export/compress %s s\n' "$label" \ + "$(wc -c < "$work/$label.tar.gz" | tr -d ' ')" "$(( $(date +%s) - started ))" + started="$(date +%s)" + docker image load --input "$work/$label.tar.gz" >/dev/null + printf '%s local load with cached layers: %s s\n' "$label" "$(( $(date +%s) - started ))" +} +archive shared "$shared" +archive base "$base" + +runtime=/opt/tuneforge-ci/cross-runtime +docker run --rm --platform linux/amd64 --network none "$base" test ! -e "$runtime" +container="$(docker create --platform linux/amd64 "$shared")" +started="$(date +%s)" +docker cp "$container:$runtime/." - | gzip -n -6 > "$work/payload.tar.gz" +printf 'Separate payload archive: %s bytes, export/compress %s s\n' \ + "$(wc -c < "$work/payload.tar.gz" | tr -d ' ')" "$(( $(date +%s) - started ))" +docker cp "$container:$runtime/payload.sha256" "$work/expected.sha256" +expected_manifest="$(node -p ' + const manifest = require("node:fs").readFileSync(process.argv[1]); + require("node:crypto").createHash("sha256").update(manifest).digest("hex"); +' "$work/expected.sha256")" + +probe="$(cat <<'BASH' +set -euo pipefail +cd /opt/tuneforge-ci/cross-runtime +if [[ "$#" = 1 ]]; then + tar --no-overwrite-dir -xzf - + printf "%s payload.sha256\n" "$1" | sha256sum --check --strict +fi +sha256sum --check --strict --status payload.sha256 +venv/bin/python -IB -c "import librosa, soundfile; from tuneforge_music_core import _native" +BASH +)" +started="$(date +%s)" +docker run --rm --platform linux/amd64 --network none "$shared" bash -c "$probe" +printf 'Shared container startup, verify and import: %s s\n' "$(( $(date +%s) - started ))" +started="$(date +%s)" +# A Linux filesystem preserves case-sensitive archive entries on macOS hosts. +docker run --rm -i --platform linux/amd64 --network none --tmpfs "$runtime:rw,exec" \ + "$base" bash -c "$probe" bash "$expected_manifest" < "$work/payload.tar.gz" +printf 'Separate container startup, local stream, extract, verify and import: %s s\n' "$(( $(date +%s) - started ))" diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 92fb9d3..3a20985 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -76,6 +76,7 @@ android_package_start=${SECONDS} uv run --python 3.14 --no-project python packages/music-core/test/source-acquisition.py node --test scripts/package-android.test.mjs node --test scripts/build-ffmpeg.test.mjs + node --test scripts/ci-cross-runtime.test.mjs if [[ "$(uname -s)" == "Linux" ]]; then node --test scripts/ci-image-impact.test.mjs scripts/ci-image-run.test.mjs scripts/verify-ci-image.test.mjs fi diff --git a/scripts/verify-ci-image.sh b/scripts/verify-ci-image.sh index 21d20dc..23a4372 100644 --- a/scripts/verify-ci-image.sh +++ b/scripts/verify-ci-image.sh @@ -51,6 +51,32 @@ if [[ ! -f "${music_root}/payload.sha256" ]] || fi node "${GITHUB_WORKSPACE}/scripts/ci-music-core.mjs" verify "${music_root}" +if [[ "$GITHUB_JOB" = cross_runtime_integration ]]; then + runtime=/opt/tuneforge-ci/cross-runtime + if [[ ! -f "$runtime/payload.sha256" ]] || + ! (cd "$runtime" && sha256sum --check --strict --status payload.sha256) || + ! cmp -s "$runtime/requirements.txt" "$GITHUB_WORKSPACE/.github/ci/cross-runtime-requirements.txt"; then + echo "CI image cross-runtime Python payload is missing, corrupt, or stale." >&2 + exit 1 + fi + ( + cd "$GITHUB_WORKSPACE" + node --input-type=module - "$runtime" "$music_root" <<'JS' +import { readFileSync } from "node:fs"; +import { verifyManifestMetadata } from "./packages/music-core/tools/build.mjs"; +const [runtime, music] = process.argv.slice(2); +const python = JSON.parse(readFileSync(runtime + "/music-core.json")); +const wasm = JSON.parse(readFileSync(music + "/wasm/manifest.json")); +verifyManifestMetadata(python, "python"); +if (python.sourceFingerprint !== wasm.sourceFingerprint || + python.pythonVersion !== readFileSync(".python-version", "utf8").trim()) { + throw new Error("CI image Python binding source or interpreter does not match the selected checkout"); +} +JS + ) + printf -- '- Cross-runtime Python: %s (verified dependencies and native binding)\n' "$runtime" >> "$GITHUB_STEP_SUMMARY" +fi + if [[ "${CC:-}" != /usr/bin/clang-18 || "${CXX:-}" != /usr/bin/clang++-18 ]]; then echo "CI image must select CC=/usr/bin/clang-18 and CXX=/usr/bin/clang++-18; got CC=${CC:-unset} CXX=${CXX:-unset}." >&2 exit 1 diff --git a/scripts/verify-ci-image.test.mjs b/scripts/verify-ci-image.test.mjs index 648ee17..75c8740 100644 --- a/scripts/verify-ci-image.test.mjs +++ b/scripts/verify-ci-image.test.mjs @@ -80,14 +80,17 @@ chmod +x "$2" fs.writeFileSync(compilerEvidence, [cc, cxx].map(compiler => `selected: ${compiler}\nresolved: ${fs.realpathSync(compiler)}\nUbuntu clang version 18.1.3\n`).join("")); const fixtureVerifier = path.join(root, "verify-ci-image.sh"); + const crossRuntime = path.join(root, "cross-runtime"); fs.writeFileSync(fixtureVerifier, fs.readFileSync(verifier, "utf8") + .replaceAll("/opt/tuneforge-ci/cross-runtime", crossRuntime) .replaceAll("/usr/bin/clang++-18", cxx).replaceAll("/usr/bin/clang-18", cc)); const music = payloadFixture(path.join(root, "music-core"), workspace); const summary = path.join(root, "summary.md"); const imageManifest = path.join(root, "producer-inputs.sha256"); const identity = producerIdentity(workspace); fs.writeFileSync(imageManifest, identity.manifest); - return { root, workspace, soxr, runtime, bin, summary, imageManifest, music, cc, cxx, compilerEvidence, fixtureVerifier, fingerprint: identity.fingerprint }; + return { root, workspace, soxr, runtime, bin, summary, imageManifest, music, crossRuntime, + cc, cxx, compilerEvidence, fixtureVerifier, fingerprint: identity.fingerprint }; } function run(value, overrides = {}) { @@ -124,6 +127,47 @@ test("CI image verifier accepts matching SoXR payload and checkout inputs", (con assert.match(fs.readFileSync(value.summary, "utf8"), /verified payload and build inputs/); }); +test("cross-runtime pilot verifies Python payload presence, hashes, requirements and binding metadata", (context) => { + const value = fixture(); + context.after(() => fs.rmSync(value.root, { recursive: true, force: true })); + const pilot = { GITHUB_JOB: "cross_runtime_integration" }; + assert.match(run(value, pilot).stderr, /Python payload is missing, corrupt, or stale/); + + const requirements = path.join(value.crossRuntime, "requirements.txt"); + const manifest = path.join(value.crossRuntime, "music-core.json"); + const wasm = JSON.parse(fs.readFileSync(path.join(value.music, "wasm/manifest.json"), "utf8")); + const arch = process.arch === "x64" ? "x86_64" : "aarch64"; + const darwin = process.platform === "darwin"; + const wheelPlatform = darwin ? "macosx_13_0_arm64" : `linux_${arch}`; + const binding = { + ...wasm, target: "python", platform: `${process.platform}-${process.arch}`, pythonAbi: "cp314", + pythonVersion: fs.readFileSync(path.join(value.workspace, ".python-version"), "utf8").trim(), + extensionSuffix: darwin ? ".cpython-314-darwin.so" : `.cpython-314-${arch}-linux-gnu.so`, + pybind11Version: JSON.parse(fs.readFileSync(path.join(value.workspace, "packages/music-core/toolchains.lock.json"))).tools.pybind11.version, + wheelPlatform, files: [{ path: `tuneforge_music_core-${wasm.packageVersion}-cp314-cp314-${wheelPlatform}.whl` }], + }; + function bindChecksum() { + fs.writeFileSync(path.join(value.crossRuntime, "payload.sha256"), + `${sha256(requirements)} requirements.txt\n${sha256(manifest)} music-core.json\n`); + } + fs.mkdirSync(value.crossRuntime); + const projection = path.join(value.workspace, ".github/ci/cross-runtime-requirements.txt"); + fs.copyFileSync(projection, requirements); + fs.writeFileSync(manifest, JSON.stringify(binding)); + bindChecksum(); + const accepted = run(value, pilot); + assert.equal(accepted.status, 0, accepted.stderr); + + fs.appendFileSync(requirements, "corrupt\n"); + assert.match(run(value, pilot).stderr, /Python payload is missing, corrupt, or stale/); + bindChecksum(); + assert.match(run(value, pilot).stderr, /Python payload is missing, corrupt, or stale/); + fs.copyFileSync(projection, requirements); + fs.writeFileSync(manifest, JSON.stringify({ ...binding, sourceFingerprint: "1".repeat(64) })); + bindChecksum(); + assert.match(run(value, pilot).stderr, /Python binding source or interpreter does not match/); +}); + test("CI image verifier ignores repository-wide notice changes", (context) => { const value = fixture(); context.after(() => fs.rmSync(value.root, { recursive: true, force: true }));