diff --git a/.github/ci/promoted-image.json b/.github/ci/promoted-image.json index 550629d..4994fb8 100644 --- a/.github/ci/promoted-image.json +++ b/.github/ci/promoted-image.json @@ -1,6 +1,6 @@ { - "digest": "sha256:7930a1d55d0376a2578659a20d3974b7a5bd34476dcfb73bf999e25202f437e2", - "producerFingerprint": "f1240f42a615c8c655615be4443abca73b8128b6fb3b4642b0551b16c8d1e6c5", - "sourceRevision": "076f83679fbf3e0ce488560a9144f260216ff4db", + "digest": "sha256:2ab6e2efcde2843426ecdd008b462c4882a398edf5f6694e59db7ccdcad64957", + "producerFingerprint": "644cb756571c9b78d1c5053745c3deb4172220fec63b654933bd114b2b0a262c", + "sourceRevision": "f03e639cb62c831879f225e7ba5bcd70141da64f", "platform": "linux/amd64" } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d38ef31..82126bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: codex_only: ${{ steps.scope.outputs.codex_only }} 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' }} + cross_runtime_integration: ${{ steps.scope.outputs.cross_runtime_integration != 'false' || 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') }} @@ -75,7 +75,7 @@ jobs: if [[ "${path}" != .codex/* ]]; then codex_only=false fi - if [[ "${path}" = apps/desktop/src-tauri/* ]]; then + if [[ "${path}" = apps/desktop/src-tauri/* || "${path}" = .cargo/config.toml ]]; then desktop_tauri=true cross_runtime_integration=true else @@ -122,7 +122,7 @@ jobs: ;; packages/shared-types/AGENTS.md) ;; - apps/desktop/src-tauri/*) + apps/desktop/src-tauri/*|.cargo/config.toml) desktop_tauri=true ;; apps/desktop/*) @@ -175,7 +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 "cross-runtime integration" "${cross_runtime_integration}" print_scope_decision "site checks" "${site}" { @@ -198,7 +198,7 @@ jobs: 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 "- Cross-runtime integration: ${cross_runtime_integration}" echo "- Site checks: ${site}" if [[ -s "${changed_files}" ]]; then echo @@ -1107,8 +1107,7 @@ jobs: 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') }} + if: ${{ always() && (needs.ci-scope.result != 'success' || needs.ci-scope.outputs.cross_runtime_integration != 'false' || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped') }} runs-on: ubuntu-24.04 permissions: contents: read @@ -1129,9 +1128,9 @@ jobs: ref: ${{ github.sha }} persist-credentials: false - - name: Require candidate for integration pilot + - name: Reject unexpected candidate result for promoted image shell: bash - if: needs.ci-scope.outputs.image_selection != 'candidate' + if: needs.ci-scope.outputs.image_selection == 'promoted' && needs.ci-image-candidate.result != 'skipped' run: exit 1 - name: Require selected CI image diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7f746cd..b22086a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -160,6 +160,23 @@ pnpm contracts:generate CI will fail if `packages/shared-types/src/generated/openapi.ts` is out of sync. +### Cross-runtime integration matrix + +For changes to result sync between Python and Rust, run this from the repository +root in Bash after [development setup](#setup), with CMake 3.20+ on `PATH`. + +```bash +( + set -e + export PATH="$PWD/apps/backend/.venv/bin:$PATH" + source scripts/configure-tauri-build-env.sh + node scripts/build-soxr.mjs --target host-test + node scripts/build-music-core.mjs --fetch-sources + TUNEFORGE_SOXR_ROOT="$PWD/packaging/soxr/generated/host-test" \ + node scripts/ci-cross-runtime.mjs +) +``` + ## Commit Messages Tuneforge enforces [Conventional Commits](https://www.conventionalcommits.org/) via `commitlint`. The `commit-msg` Husky hook is installed automatically by `pnpm install`, and CI re-checks every commit on a PR plus the PR title (because the PR title becomes the squash commit message on `main`). diff --git a/TODO.md b/TODO.md index 508d286..dd82f0d 100644 --- a/TODO.md +++ b/TODO.md @@ -29,38 +29,6 @@ checks at processing and sync boundaries. Keep this separate from vocal refineme Related: [startup hydration](https://github.com/grazzolini/tuneforge/issues/636) and [manifest precomputation](https://github.com/grazzolini/tuneforge/issues/617). -## Cross-runtime integration CI - -[GitHub issue](https://github.com/grazzolini/tuneforge/issues/601) - -The Rust integration test exercises real Python result producers, native apply -and replay, then native edits verified by Python. Inference is mocked; persistence -and reconciliation remain real. Static shared fixtures do not provide equivalent proof. - -The test is compiled but ignored by default because `desktop_tauri` has no prepared -Python backend environment. Adding backend setup there would increase runtime and -cache costs. Keep the test and Python fixture available for explicit manual execution. - -Revisit when a dedicated cross-runtime lane can preserve this proof while maintaining -the current pipeline runtime and avoiding substantial cache growth. Validate image -dependency size, provenance, job scope, runtime, and cache impact before enabling it. - -Source pointers: - -- [Rust test and fixture launcher](apps/desktop/src-tauri/src/mobile_backend/reconciliation.rs) -- [Python fixture](apps/backend/tests/result_sync_fixture.py) -- [CI jobs and scope](.github/workflows/ci.yml) -- [CI image producer and consumer policy](.github/ci/README.md) - -For manual execution, use the prepared Python backend, repository-owned SoXR, and -fresh synthetic data, transport, cache, and temporary roots: - -```sh -cargo test --manifest-path apps/desktop/src-tauri/Cargo.toml --lib \ - mobile_backend::reconciliation::tests::python_producers_native_apply_result_matrix_and_bidirectional_replay \ - -- --exact --ignored -``` - ## Section playback and editing Consolidate the section UI before defining detailed follow-up issues. Future work diff --git a/scripts/ci-image-policy.mjs b/scripts/ci-image-policy.mjs index d7e93d9..6840b3d 100644 --- a/scripts/ci-image-policy.mjs +++ b/scripts/ci-image-policy.mjs @@ -535,6 +535,8 @@ export function validateCiImagePolicy(root) { 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", "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"); + check(scopeBlock.includes("\n cross_runtime_integration: ${{ steps.scope.outputs.cross_runtime_integration != 'false' || steps.image.outputs.selection != 'promoted' }}\n"), + "Cross-runtime integration must use its computed scope output and run on missing scope"); for (const name of ciImageConsumers) { const block = workflowJobBlock(mainWorkflow, name); check(block.includes(" runs-on: ubuntu-24.04"), name + " must use ubuntu-24.04"); @@ -546,7 +548,8 @@ export function validateCiImagePolicy(root) { "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') }}"; + scheduling = "${{ always() && (needs.ci-scope.result != 'success' || needs.ci-scope.outputs.cross_runtime_integration != 'false' || " + + "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'") + ") }}"; @@ -591,12 +594,22 @@ export function validateCiImagePolicy(root) { 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"); + const integrationSteps = crossRuntimeBlock.split(/^ {6}- /m).map(step => step.trimEnd()); + const candidateGuard = integrationSteps.indexOf("name: Reject unexpected candidate result for promoted image\n" + + " shell: bash\n if: needs.ci-scope.outputs.image_selection == 'promoted' && needs.ci-image-candidate.result != 'skipped'\n" + + " run: exit 1"); + const requireImage = integrationSteps.indexOf("name: Require selected CI image\n" + + " shell: bash\n run: bash scripts/ci-image-run.sh require"); + const verifyImage = integrationSteps.indexOf("name: Verify CI image\n run: bash scripts/verify-ci-image.sh"); + const acquisition = integrationSteps.indexOf("name: Acquire verified music-core sources\n" + + " run: node scripts/build-music-core.mjs --fetch-sources"); + const matrix = integrationSteps.indexOf("name: Test Python producers and native reconciliation\n" + + " run: node scripts/ci-cross-runtime.mjs --python /opt/tuneforge-ci/cross-runtime/venv/bin/python"); + check(candidateGuard > 0 && requireImage > candidateGuard && verifyImage > requireImage && + acquisition > verifyImage && matrix > acquisition && + crossRuntimeBlock.split("run: node scripts/ci-cross-runtime.mjs").length === 2 && + !/^ continue-on-error:|\buv (?:sync|pip)\b/m.test(crossRuntimeBlock), + "Cross-runtime integration must reject unexpected candidate results and 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); diff --git a/scripts/ci-image-policy.test.mjs b/scripts/ci-image-policy.test.mjs index 9e45319..1f1b5e9 100644 --- a/scripts/ci-image-policy.test.mjs +++ b/scripts/ci-image-policy.test.mjs @@ -368,14 +368,40 @@ 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", () => { +test("cross-runtime integration 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/); + ["needs.ci-scope.outputs.image_selection == 'promoted' && needs.ci-image-candidate.result != 'skipped'\n run: exit 1", "false\n run: exit 1"], + [" run: node scripts/ci-cross-runtime.mjs", " continue-on-error: true\n run: node scripts/ci-cross-runtime.mjs"], + [" run: node scripts/ci-cross-runtime.mjs", " if: false\n run: node scripts/ci-cross-runtime.mjs"], + [" run: node scripts/ci-cross-runtime.mjs", " shell: bash\n run: node scripts/ci-cross-runtime.mjs"], + ...[ + " run: node scripts/build-music-core.mjs --fetch-sources", + " run: node scripts/ci-cross-runtime.mjs --python /opt/tuneforge-ci/cross-runtime/venv/bin/python", + ].flatMap(run => ["if: false", "continue-on-error: true", "shell: bash"].map(key => [run, `${run}\n ${key}`])), + [ + " run: exit 1\n\n - name: Require selected CI image", + " run: exit 1\n continue-on-error: true\n\n - name: Require selected CI image", + ], + ], /must use one image-keyed|restores the exact Tauri Cargo cache|Cross-runtime integration must reject/); +}); + +test("cross-runtime scheduling requires relevant promoted changes and retains failure and candidate gates", () => { + assertMutationsFail(".github/workflows/ci.yml", [ + [" || needs.ci-scope.outputs.cross_runtime_integration != 'false'", ""], + ["needs.ci-scope.outputs.cross_runtime_integration != 'false'", "true"], + ["needs.ci-scope.outputs.cross_runtime_integration != 'false'", "needs.ci-scope.outputs.cross_runtime_integration == 'true'"], + [" || needs.ci-image-candidate.result != 'skipped') }}\n runs-on:", ") }}\n runs-on:"], + [" || needs.ci-scope.outputs.image_selection != 'promoted' || needs.ci-image-candidate.result != 'skipped') }}", " || needs.ci-image-candidate.result != 'skipped') }}"], + ], /cross_runtime_integration must retain fail-closed required-job scheduling/); + assertMutationsFail(".github/workflows/ci.yml", [ + ["steps.scope.outputs.cross_runtime_integration", "steps.scope.outputs.cross_runtime"], + ["steps.scope.outputs.cross_runtime_integration != 'false'", "steps.scope.outputs.cross_runtime_integration == 'true'"], + [" cross_runtime_integration: ${{ steps.scope.outputs.cross_runtime_integration != 'false' || steps.image.outputs.selection != 'promoted' }}\n", ""], + ], /Cross-runtime integration must use its computed scope output/); }); test("the cross-runtime producer rejects unverified dependencies and wheel", () => { diff --git a/scripts/ci-scope-policy.test.mjs b/scripts/ci-scope-policy.test.mjs index 434c271..7084a81 100644 --- a/scripts/ci-scope-policy.test.mjs +++ b/scripts/ci-scope-policy.test.mjs @@ -230,6 +230,12 @@ test("PR scope handles release, Codex, and cross-runtime paths, renames, deletio 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 }); + const cargoConfig = commit({ ...commonFiles, ".cargo/config.toml": "cargo config" }, common); + check("root Cargo config edit", common, cargoConfig, false, nativeScope); + check("root Cargo config deletion", cargoConfig, commit(commonFiles, cargoConfig), false, nativeScope); + check("root Cargo config rename to web", cargoConfig, + commit({ ...commonFiles, "apps/desktop/src/cargo-config.toml": "cargo config" }, cargoConfig), + false, { desktop: true, desktop_tauri: true, native_only: false, cross_runtime_integration: true, site: 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" }; @@ -252,7 +258,12 @@ test("producer inputs retain real gates and promotion gaps force all image consu 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/); + const integration = workflow.slice(workflow.indexOf(" cross_runtime_integration:\n")); + const schedule = integration.match(/^ if: (.*)$/m)?.[1]; + assert.match(schedule, /needs\.ci-scope\.result != 'success'/); + assert.match(schedule, /needs\.ci-scope\.outputs\.cross_runtime_integration != 'false'/); + assert.match(schedule, /needs\.ci-scope\.outputs\.image_selection != 'promoted'/); + assert.match(schedule, /needs\.ci-image-candidate\.result != 'skipped'/); + assert.match(integration, /if: needs\.ci-scope\.outputs\.image_selection == 'promoted' && needs\.ci-image-candidate\.result != 'skipped'\n run: exit 1/); + assert.doesNotMatch(integration, /if: needs\.ci-scope\.outputs\.image_selection != 'candidate'\n run: exit 1/); });