From ae63cefcd9b3ff3f32dce5da8c6ffc03fda7eda5 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 04:24:45 +0700 Subject: [PATCH] M2.6: run PR coordination admission for every PR and gate expensive UI tests --- .github/workflows/ui-smoke.yml | 51 +++++++++---------- docs/workstreams/MULTI_AGENT_COORDINATION.md | 8 +++ scripts/check_workstream_coordination.mjs | 33 +++++++++++- tests/ci_workflow_efficiency_test.mjs | 30 ++++++++--- .../workstream_coordination_contract.test.mjs | 24 ++++++++- 5 files changed, 109 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index ecf320484..f99695af0 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -19,34 +19,13 @@ on: - 'tests/wire_graph_canonical_model.test.cjs' - 'tests/wire_main_native_handoff_contract.test.cjs' - 'tests/ci_workflow_efficiency_test.mjs' - - 'scripts/check_workstream_coordination.mjs' - - 'tests/workstream_coordination_contract.test.mjs' - 'tests/approved_native_m2_contract.test.cjs' - 'scripts/build_ui_css.py' - '.github/workflows/ui-smoke.yml' - '.github/workflows/pages-publish.yml' + # All PRs receive fast admission; Chromium is conditional on checked files. pull_request: - types: [opened, reopened, synchronize, ready_for_review] - paths: - - 'web/**' - - 'integration/console-v6/**' - - 'site/**' - - 'AR-MIX-Live-FX-Host-Standalone-v0.3.html' - - 'scripts/build_pages.py' - - 'scripts/build_ui_css.py' - - 'tests/*.py' - - 'tests/gui_workflow_contract_test.mjs' - - 'tests/*gui*contract*.mjs' - - 'tests/native_ui_contract_test.mjs' - - 'tests/native_orbit_ui_smoke.py' - - 'tests/ci_workflow_efficiency_test.mjs' - - 'scripts/check_workstream_coordination.mjs' - - 'tests/workstream_coordination_contract.test.mjs' - - 'tests/approved_native_m2_contract.test.cjs' - - 'tests/wire_graph_canonical_model.test.cjs' - - 'tests/wire_main_native_handoff_contract.test.cjs' - - '.github/workflows/ui-smoke.yml' - - '.github/workflows/pages-publish.yml' + types: [opened, reopened, synchronize, edited, ready_for_review] # Manual full suite (including immutable CSS migration tests) or release-integration PR. workflow_dispatch: @@ -61,17 +40,35 @@ permissions: pull-requests: read jobs: - frontend: - name: Standalone UI and geometry + coordination: + name: PR coordination admission runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 5 + outputs: + run_ui: ${{ steps.pr_scope.outputs.run_ui || steps.push_scope.outputs.run_ui }} steps: - uses: actions/checkout@v4 - - name: Cheap one-owner / overlapping-PR preflight (read-only) + - name: Audit PR metadata, file ownership and runtime collisions + id: pr_scope if: ${{ github.event_name == 'pull_request' }} env: GH_TOKEN: ${{ github.token }} run: node scripts/check_workstream_coordination.mjs --pr ${{ github.event.pull_request.number }} + - name: Main push retains Chromium verification + id: push_scope + if: ${{ github.event_name != 'pull_request' }} + shell: bash + run: echo "run_ui=true" >> "$GITHUB_OUTPUT" + - name: Fast offline coordination contract regression + run: node --test tests/workstream_coordination_contract.test.mjs + frontend: + needs: coordination + if: ${{ github.event_name != 'pull_request' || needs.coordination.outputs.run_ui == 'true' }} + name: Standalone UI and geometry + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" diff --git a/docs/workstreams/MULTI_AGENT_COORDINATION.md b/docs/workstreams/MULTI_AGENT_COORDINATION.md index ae69b3d8b..596b4d387 100644 --- a/docs/workstreams/MULTI_AGENT_COORDINATION.md +++ b/docs/workstreams/MULTI_AGENT_COORDINATION.md @@ -53,6 +53,14 @@ NEXT SINGLE MEANINGFUL MILESTONE: Do not create 10 micro-PRs or issue-only progress in place of code. The owning lane implements substantive code and targeted tests; one integrator joins exact checked SHA. GUI remains Pages-only visual authority; only ENGINE provides real PCM; FAT is the independent final judge. If the device is unavailable, mark physical FAT pending. Keep #15 crackling stop-ship. +## M2.6: always-on lightweight PR coordination + +The existing `.github/workflows/ui-smoke.yml` now checks **every pull request**, including docs-only, ENGINE-only and metadata-edited PRs. Its named `PR coordination admission` job checks owner markers, active PR overlaps and runtime domains and runs offline unit regressions. It sets `run_ui=true` only for UI/browser/approved-native changes; docs-only and ENGINE-only PRs do **not** start the heavyweight Chromium job. Windows native CI keeps its existing path filters. No fifth workflow or audio engine is added. + +For merge safety, require the exact GitHub Actions job check **PR coordination admission** in `main` branch protection or rulesets, require PR review, and require up-to-date head (or merge queue). Verify a real check run exists before selecting the status name. Do not universally require Windows/Chromium checks when their path-based jobs are intentionally skipped. Configure this in repository Settings → Branches or Settings → Rules → Rulesets using administrator access. Confirm the GitHub branch API reports `protected: true` afterward. + +**Admin limitation:** the connected GitHub app cannot write protection/rulesets. Until enabled, a successful CI job is a meaningful PR signal, but it cannot stop an authorized maintainer from bypassing review or pushing directly to `main`. Hardware FAT #15 and exact-sha production gates remain independent and mandatory. + ## Administrative limitation GitHub may allow a maintainer to merge even with a failed check unless **required status checks** and appropriate branch protection/rulesets are configured. App connections cannot always administer these. Treat #397 as the human coordination gate, and enable branch protection for existing Windows/Chromium checks (or a dedicated required coordination check if introduced later) through repository Settings when available. This policy does not magically observe unpushed private ChatGPT threads. diff --git a/scripts/check_workstream_coordination.mjs b/scripts/check_workstream_coordination.mjs index 8607071d2..bb678a561 100644 --- a/scripts/check_workstream_coordination.mjs +++ b/scripts/check_workstream_coordination.mjs @@ -1,9 +1,10 @@ #!/usr/bin/env node // SPDX-License-Identifier: AGPL-3.0-only // One-owner PR preflight. Runs in EXISTING GUI/Windows workflows only. -// Cheap GitHub REST reads; NEVER changes a repo, builds audio or blocks push/main. +// Cheap GitHub REST reads; NEVER changes a repo or builds audio. // New PRs fail closed on unowned production paths or active same-owner collisions. import { pathToFileURL } from 'node:url'; +import { appendFileSync } from 'node:fs'; export const POLICY_EPOCH_PR = 399; // Existing #396/#398 are legacy; new #400+ are strict. export const WORKSTREAMS = Object.freeze(['GUI', 'ENGINE', 'INTEGRATOR', 'FAT']); @@ -175,6 +176,30 @@ async function allPages(base, token, limit = 10) { } throw Error('GitHub API pagination exceeded bounded limit: '+base); } +// Scope expensive Chromium to the prior UI PR path policy, while every +// PR (docs-only / ENGINE-only included) receives fast ownership admission. +export function requiresUiSmoke(paths) { + return paths.some(path => + path.startsWith('site/') || + path.startsWith('web/') || + path.startsWith('integration/console-v6/') || + path === 'AR-MIX-Live-FX-Host-Standalone-v0.3.html' || + path === 'scripts/build_pages.py' || + path === 'scripts/build_ui_css.py' || + /^tests\/[^/]+\.py$/.test(path) || + /^tests\/[^/]*gui[^/]*contract[^/]*\.mjs$/.test(path) || + [ + 'tests/gui_workflow_contract_test.mjs', + 'tests/native_ui_contract_test.mjs', + 'tests/ci_workflow_efficiency_test.mjs', + 'tests/approved_native_m2_contract.test.cjs', + 'tests/wire_graph_canonical_model.test.cjs', + 'tests/wire_main_native_handoff_contract.test.cjs', + '.github/workflows/ui-smoke.yml', + '.github/workflows/pages-publish.yml' + ].includes(path)); +} + export async function auditGitHub({repo,number,token}) { if (!/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(repo)) throw Error('Invalid repository selector'); @@ -196,8 +221,9 @@ export async function auditGitHub({repo,number,token}) { .map(f=>f.filename); })); } - return audit({pr,files:files.map(f=>f.filename),others,filesByPR, + const result = audit({pr,files:files.map(f=>f.filename),others,filesByPR, fileStatuses:Object.fromEntries(files.map(f=>[f.filename,f.status]))}); + return {...result, runUi: requiresUiSmoke(files.map(f=>f.filename))}; } async function main() { const args=process.argv.slice(2); @@ -211,6 +237,9 @@ async function main() { repo:process.env.GITHUB_REPOSITORY || '', number,token:process.env.GH_TOKEN || '' }); + if (process.env.GITHUB_OUTPUT) { + appendFileSync(process.env.GITHUB_OUTPUT, 'run_ui='+(result.runUi?'true':'false')+'\n'); + } console.log('ArSonMix coordination: lane='+(result.lane||'UNDECLARED')+ ' files='+result.changedFiles+' legacy='+result.legacy+ ' authorized='+result.ok+' collision(s)='+result.activeCollisions); diff --git a/tests/ci_workflow_efficiency_test.mjs b/tests/ci_workflow_efficiency_test.mjs index 3f28e4d7d..5c18df988 100644 --- a/tests/ci_workflow_efficiency_test.mjs +++ b/tests/ci_workflow_efficiency_test.mjs @@ -3,6 +3,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import {readFileSync} from 'node:fs'; +import {requiresUiSmoke} from '../scripts/check_workstream_coordination.mjs'; const read = path => readFileSync(path, 'utf8'); const native = read('.github/workflows/p1-windows.yml'); @@ -38,7 +39,8 @@ function globMatches(pattern, filename) { const windowsPush = pathsFor(native, 'push', 'pull_request'); const windowsPR = pathsFor(native, 'pull_request', 'workflow_dispatch'); const uiPush = pathsFor(ui, 'push', 'pull_request'); -const uiPR = pathsFor(ui, 'pull_request', 'workflow_dispatch'); +// Unfiltered PR entry runs cheap admission; only UI-relevant paths run browser. +const uiPRSelected = filename => requiresUiSmoke([filename]); const selected = (paths, file) => paths.some(p => globMatches(p, file)); test('visual GUI changes never consume Windows native runner on a PR or on main', () => { @@ -47,7 +49,7 @@ test('visual GUI changes never consume Windows native runner on a PR or on main' 'web/mixer-layout.js', 'web/mixer-io.js', 'AR-MIX-Live-FX-Host-Standalone-v0.3.html' ]) { - assert.ok(selected(uiPR, filename), filename + ' must run frontend PR checks'); + assert.ok(uiPRSelected(filename), filename + ' must run frontend PR checks'); assert.ok(selected(uiPush, filename), filename + ' must qualify Pages'); assert.equal(selected(windowsPR, filename), false, filename + ' wrongly triggers native PR'); assert.equal(selected(windowsPush, filename), false, filename + ' wrongly triggers native main'); @@ -61,7 +63,7 @@ test('native PCM and device changes always use Windows/CTest, never Chromium by ]) { assert.ok(selected(windowsPR, filename), filename + ' must qualify native PR'); assert.ok(selected(windowsPush, filename), filename + ' must qualify native main'); - assert.equal(selected(uiPR, filename), false, filename + ' wrongly triggers browser PR'); + assert.equal(uiPRSelected(filename), false, filename + ' wrongly triggers browser PR'); assert.equal(selected(uiPush, filename), false, filename + ' wrongly triggers browser main'); } assert.match(native, /ctest --test-dir build -C Release --output-on-failure/); @@ -89,17 +91,21 @@ test('native WebView bridge and integration genuinely require both owners', () = for (const filename of [ 'web/bridge.js', 'web/monitor.js', 'integration/console-v6/contract.json' ]) { - for (const paths of [windowsPush, windowsPR, uiPush, uiPR]) { + for (const paths of [windowsPush, windowsPR, uiPush]) { assert.ok(selected(paths, filename), filename + ' needs native+GUI checks'); } + assert.ok(uiPRSelected(filename),filename+' needs PR Chromium tests'); } }); test('docs and isolated CI tests do not fan out into unrelated builds', () => { - const paths = [windowsPR, windowsPush, uiPR, uiPush]; + const paths = [windowsPR, windowsPush, uiPush]; for (const filename of [ 'README.md', 'docs/workstreams/START_HERE_WIRE_FIRST_20261104.md' - ]) assert.ok(paths.every(p => !selected(p, filename)), 'Doc triggered CI: ' + filename); + ]) { + assert.ok(paths.every(p => !selected(p, filename)), 'Doc triggered CI: ' + filename); + assert.equal(uiPRSelected(filename),false,'Doc only needs lightweight PR admission: '+filename); + } for (const filename of [ 'tests/pages_wire_first_canonical_main_smoke.py', 'tests/wire_graph_canonical_model.test.cjs', @@ -108,7 +114,7 @@ test('docs and isolated CI tests do not fan out into unrelated builds', () => { ]) { assert.equal(selected(windowsPR, filename), false); assert.equal(selected(windowsPush, filename), false); - assert.equal(selected(uiPR, filename), true); + assert.equal(uiPRSelected(filename), true); assert.equal(selected(uiPush, filename), true); } }); @@ -154,3 +160,13 @@ test('Pages is single guarded downstream publisher, never triggered by PR comple assert.match(factory, /schedule:/); assert.doesNotMatch(factory, /^\s{2}push:/m); }); + +test('M2.6 always-on coordination job has a stable name and skips unrelated Chromium', () => { + const prBlock=ui.split('\n pull_request:\n')[1]?.split('\n # Manual full suite')[0] || ''; + assert.match(prBlock,/types: \[opened, reopened, synchronize, edited, ready_for_review\]/); + assert.doesNotMatch(prBlock,/^\s+paths:/m); + assert.match(ui,/name: PR coordination admission/); + assert.match(ui,/needs: coordination/); + assert.match(ui,/needs\.coordination\.outputs\.run_ui == 'true'/); + assert.match(ui,/node --test tests\/workstream_coordination_contract\.test\.mjs/); +}); diff --git a/tests/workstream_coordination_contract.test.mjs b/tests/workstream_coordination_contract.test.mjs index 604c82ca8..012e57f5a 100644 --- a/tests/workstream_coordination_contract.test.mjs +++ b/tests/workstream_coordination_contract.test.mjs @@ -2,7 +2,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import {readFileSync} from 'node:fs'; -import {POLICY_EPOCH_PR, ownerOf, metadata, audit} from '../scripts/check_workstream_coordination.mjs'; +import {POLICY_EPOCH_PR, ownerOf, metadata, audit, requiresUiSmoke} from '../scripts/check_workstream_coordination.mjs'; const body=(lane,issue=397,parked=false)=> '\n'+ @@ -207,3 +207,25 @@ test('coordinator uses existing native + Chromium CI, not a fifth workflow',()=> assert.match(guide,/MULTI_AGENT_COORDINATION\.md/); assert.match(guide,/#397/); }); + +test('M2.6 always-on PR admission scopes Chromium to UI changes',()=>{ + for(const path of [ + 'docs/RELEASE_NOTES.md','README.md','src/LiveAudioEngine.h', + 'engine/core/PreparedMixerBlock.h', + 'scripts/check_workstream_coordination.mjs', + 'tests/workstream_coordination_contract.test.mjs' + ]) assert.equal(requiresUiSmoke([path]),false,path); + for(const path of [ + 'site/preview/index.html','web/approved-native-bridge.js', + 'integration/console-v6/contract.json','tests/pages_wire_first_canonical_main_smoke.py', + '.github/workflows/ui-smoke.yml' + ]) assert.equal(requiresUiSmoke([path]),true,path); + assert.equal(requiresUiSmoke(['README.md','src/Main.cpp','site/preview/index.html']),true); + const workflow=readFileSync('.github/workflows/ui-smoke.yml','utf8'); + const prBlock=workflow.split('\n pull_request:\n')[1]?.split('\n # Manual full suite')[0] || ''; + assert.ok(prBlock,'missing PR event'); + assert.doesNotMatch(prBlock,/^\s+paths:/m,'PR entrypoint must not filter docs or PCM PRs'); + assert.match(workflow,/name: PR coordination admission/); + assert.match(workflow,/needs: coordination/); + assert.match(workflow,/needs\.coordination\.outputs\.run_ui/); +});