From a4d10dd9b634ea0e86724e9367f400ff1975049d Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Tue, 6 Oct 2026 03:49:02 -0400 Subject: [PATCH] [CI] (P13 W3b): retired-switch hygiene gate and the fatal census at its new floor --- .github/workflows/test.yml | 6 +++ scripts/ci/fatal_census_baseline.json | 5 +- scripts/ci/retired_switches.py | 76 +++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 scripts/ci/retired_switches.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5c251a1..a1c958a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3548,6 +3548,12 @@ jobs: - name: Espryt memo-key purity check run: python3 scripts/ci/espryt_memo_purity.py --self-test + # P13 W3b: the pull build's switches stay retired - a preprocessor conditional on + # MOBILEGL_PIPE_PUSH / MOBILEGL_PIPE_LEGACY_MEMOS, or an MGB_CTX spelling, coming back is a + # red here. --self-test plants each shape first and requires the gate to catch it. + - name: Retired pull-build switches stay retired (P13) + run: python3 scripts/ci/retired_switches.py --self-test + # The same question for the symbol tool the P1 gate is written in terms of. - name: Symbol report self-test run: python3 scripts/symbol_report.py --self-test diff --git a/scripts/ci/fatal_census_baseline.json b/scripts/ci/fatal_census_baseline.json index 95746b66..53bd0869 100644 --- a/scripts/ci/fatal_census_baseline.json +++ b/scripts/ci/fatal_census_baseline.json @@ -1,7 +1,7 @@ { - "abort_sites": 76, + "abort_sites": 75, "abort_sites_by_file": { - "MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp": 13, + "MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp": 12, "MobileGL/MG_Backend/DirectGLES/Managers.cpp": 12, "MobileGL/MG_Backend/DirectGLES/MultiDraw.cpp": 2, "MobileGL/MG_Backend/DirectGLES/Utils.cpp": 1, @@ -66,7 +66,6 @@ "UnmigratedPipeInput", "UnmigratedSurface", "UnmigratedVerb", - "UnnamedIdentity", "UnsetCallMask", "UnsizedReadback" ] diff --git a/scripts/ci/retired_switches.py b/scripts/ci/retired_switches.py new file mode 100644 index 00000000..faab406e --- /dev/null +++ b/scripts/ci/retired_switches.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python3 +"""P13 W3b: the pull build's switches stay retired. + +The pull build's macro (MOBILEGL_PIPE_PUSH as a preprocessor condition), the legacy-memo macro +(MOBILEGL_PIPE_LEGACY_MEMOS) and the MGB_CTX spelling of the backends' context were removed in +P13 W3b. Any of them coming back in source is a second arm nobody tests, so it is a red here. + +The RUNTIME MOBILEGL_PIPE_PUSH environment bitmask (bit 63 is still a switch, bits 0-13 are fixed +on) is a different thing and is not matched: only a preprocessor conditional naming the macro is. + +Usage: retired_switches.py [--self-test] +""" +import pathlib +import re +import subprocess +import sys + +ROOT = pathlib.Path(__file__).resolve().parents[2] +CODE_GLOBS = ('*.cpp', '*.h', '*.hpp', '*.inc', '*.def', '*.c') +RULES = ( + (re.compile(r'^\s*#\s*(?:if|ifdef|ifndef|elif)\b.*\b(?:MOBILEGL_PIPE_PUSH|MOBILEGL_PIPE_LEGACY_MEMOS)\b'), + 'a preprocessor conditional names a macro P13 W3b retired (MOBILEGL_PIPE_PUSH / ' + 'MOBILEGL_PIPE_LEGACY_MEMOS)'), + (re.compile(r'\bMGB_CTX(?:_LIVE|_IDENTITY)?\b'), + 'MGB_CTX is back; backends read MG_Pipe::gPipeInputs directly since P13 W3b'), +) + + +def scan(files): + findings = [] + for path, text in files: + for number, line in enumerate(text.splitlines(), start=1): + for pattern, message in RULES: + if pattern.search(line): + findings.append(f'{path}:{number}: {message}: {line.strip()}') + return findings + + +def tree_files(): + names = subprocess.check_output(['git', 'ls-files', '--', *CODE_GLOBS], cwd=ROOT, text=True).split() + for name in names: + try: + yield name, (ROOT / name).read_text(encoding='utf-8', errors='replace') + except FileNotFoundError: + continue + + +def self_test(): + planted = [('planted.cpp', '#if MOBILEGL_PIPE_PUSH\nx();\n#endif\n'), + ('planted.h', ' # elif !MOBILEGL_PIPE_LEGACY_MEMOS && FOO\n'), + ('planted.inc', 'auto v = MGB_CTX->GetX();\n'), + ('planted2.cpp', 'if (MGB_CTX_LIVE) {}\n')] + for item in planted: + assert scan([item]), f'the gate missed a planted line: {item}' + clean = [('clean.cpp', 'features.PipePush = QueryEnvUint64("MOBILEGL_PIPE_PUSH", 0x3fff);\n'), + ('clean.h', '// MOBILEGL_PIPE_PUSH=0x7f was the P2 mask\n'), + ('clean.inc', 'MG_Pipe::gPipeInputs.GetX();\n')] + for item in clean: + assert not scan([item]), f'the gate fired on a legitimate line: {item}' + print(f'retired switches self-test: {len(planted)} planted lines caught, {len(clean)} clean lines left alone') + + +def main(): + if '--self-test' in sys.argv[1:]: + self_test() + findings = scan(tree_files()) + for line in findings: + print(f'::error::{line}') + if findings: + return 1 + print('retired switches: none of MOBILEGL_PIPE_PUSH / MOBILEGL_PIPE_LEGACY_MEMOS (as #if) or MGB_CTX in source') + return 0 + + +if __name__ == '__main__': + sys.exit(main())