From dbbd5959934b5257b6d76aa29eb21d0de04dbe1c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 05:51:04 +0700 Subject: [PATCH 1/4] fix(ci): focused FAT uses trusted main workflow while preserving exact PR source SHA --- scripts/chat_ci_dispatch.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/chat_ci_dispatch.mjs b/scripts/chat_ci_dispatch.mjs index e1630d3d2..70e6246dd 100644 --- a/scripts/chat_ci_dispatch.mjs +++ b/scripts/chat_ci_dispatch.mjs @@ -117,8 +117,13 @@ export async function performMilestone({event,repo,api}) { const inputs=target.lane==='ui'?{expected_sha:target.sha}: {expected_sha:target.sha,package_fat:target.lane==='fat', ...(focusedHarmony?{focused_harmony_fat:true}:{})}; + // An old, still-open PR may predate the new focused-FAT workflow input. + // Execute the reviewed latest workflow FROM main, but the native job + // checks out inputs.expected_sha and verifies its exact 40-hex identity. + // This avoids silently running stale all-target YAML from a long-lived PR. + const workflowRef=focusedHarmony?'main':target.branch; await api('/actions/workflows/'+target.workflow+'/dispatches','POST', - {ref:target.branch,inputs}); + {ref:workflowRef,inputs}); return {kind:'dispatched',target}; } async function main(){ From 68dd3a0592c5dd52b4b803a24cb5fbf829eacdf0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 05:51:14 +0700 Subject: [PATCH 2/4] test(ci): assert focused Harmony dispatch uses main workflow and immutable PR SHA --- tests/chat_ci_dispatch_contract.test.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/chat_ci_dispatch_contract.test.mjs b/tests/chat_ci_dispatch_contract.test.mjs index 5523cc390..8cd828e0a 100644 --- a/tests/chat_ci_dispatch_contract.test.mjs +++ b/tests/chat_ci_dispatch_contract.test.mjs @@ -116,7 +116,8 @@ test('file-scoped Harmonice FAT is opt-in only with complete, isolated PR file p }); assert.equal(eligible.kind,'dispatched'); assert.deepEqual(calls.at(-1),{ - ref:harmonyPr.head.ref, + // The CI definition comes from main; the source still comes from SHA. + ref:'main', inputs:{expected_sha:sha,package_fat:true,focused_harmony_fat:true} }); await performMilestone({ From 38a07c1f6c8687d4c33d42f2972158bab41dd0c8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 05:51:24 +0700 Subject: [PATCH 3/4] fix(ci): report and recheck actual PR HEAD not main workflow commit --- .github/workflows/p1-windows.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index b838919e6..fcb46a789 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -284,7 +284,13 @@ jobs: ) & cmake --build build --config Release --parallel 2 --target $targets if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - Write-Host "HARMONY_FAT_NATIVE_TARGETS=$($targets.Count) SOURCE_SHA=$env:GITHUB_SHA" + # github.sha is the trusted workflow ref when dispatched from main, + # not the source commit of a long-lived candidate PR. + $sourceSha = (& git rev-parse HEAD).Trim() + if ($LASTEXITCODE -ne 0 -or $sourceSha -ne '${{ inputs.expected_sha }}') { + throw "HARMONY_FAT_SOURCE_SHA_MISMATCH expected=${{ inputs.expected_sha }} actual=$sourceSha" + } + Write-Host "HARMONY_FAT_NATIVE_TARGETS=$($targets.Count) SOURCE_SHA=$sourceSha" - name: Build executable and native RT tests if: ${{ env.FOCUSED_HARMONY_FAT != 'true' }} From 9460e2e2bd42eac5ec22ede4204eed81e50d5670 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 05:51:36 +0700 Subject: [PATCH 4/4] test(ci): enforce exact PR SHA with trusted main focused FAT YAML --- tests/ci_workflow_efficiency_test.mjs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ci_workflow_efficiency_test.mjs b/tests/ci_workflow_efficiency_test.mjs index ffe62121a..44e30382f 100644 --- a/tests/ci_workflow_efficiency_test.mjs +++ b/tests/ci_workflow_efficiency_test.mjs @@ -88,6 +88,11 @@ test('Full native/release qualification retains all CTests; isolated Harmonice F assert.match(native, /'ARMixCrackleWindowTests'/); assert.match(native, /FOCUSED_FAT_MISSING_REQUIRED_TESTS/); assert.match(native, /FULL_SUITE_NOT_CLAIMED/); + // An old PR can retain outdated workflow YAML; focused execution must + // use a trusted main workflow and still build the exact PR input SHA. + assert.match(read('scripts/chat_ci_dispatch.mjs'), + /workflowRef=focusedHarmony\?'main':target\.branch/); + assert.match(native, /HARMONY_FAT_SOURCE_SHA_MISMATCH/); }); test('approved Pages to JUCE build seam is a native gate, never an unrelated CSS-only job', () => {