nex_animation/scripts/ui/gateprobe.py

1358 lines
96 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""反向验证:证明九道闸门的每一条判据「坏了会响、好了不响」(2026-11 第七轮起常驻)。
条数别写死在标题里——它随夹具增减,实数以末行 `GATEPROBE_OK N/N` 为准(2026-11-08 阶段 12 起为 21 条,
2026-11-09 阶段 16 加了产物预算闸的静态反向验证 = 22 条、阶段 17 加图标命名闸 ㉓ = 23 条、
阶段 23 加 AT 图形中文名闸 ㉔ = 24 条、阶段 25 加图标登记表两级表闸 ㉖ = 25 条、
阶段 31 加归属尺自证空转闸 ㉗ = 26 条、阶段 33 加项目切换探测器自证闸 ㉘ = 27 条、
阶段 34 加 S-2 宿主级缺名闸 ㉙ = 28 条、阶段 35 加原生文件控件文案闸 ㉚ = 29 条)。
`gridcheck` / `rhythmcheck` / `tagcheck` / `btnrowcheck` / `footercheck` / `btnclustercheck` /
`tableaudit` 量像素,`semanticcheck` 量辅助技术语义与真实按键——八道闸门自己也需要被体检一次:豁免写宽一格、阈值调松一档,
闸门就会永远安静地返回 0,而页面该修的地方一个都没修。
这里不碰源码、不触发 HMR——直接在页面上种两块 fixture:
· `pb-*`(bad) :故意造出十七种缺陷——同族子块该用栅格却自然排列、流程条横向滚动、
同一行裸控件没坐进控件行(中心差 35px)、同一容器两档纵向间距、
收缩错位、标签铺语义色块、按钮组被劈成 2+1、
格子里并排内容越出单元格、整句散文当只读标签捅出容器右缘、
卡头行里还剩一整块没挪走却先把标题切成两行、
header 里那组横排按钮被劈成 2+1(第 17 轮删掉的旧豁免不许复活)、
浮层底部三颗按钮挤成 2+1(footercheck 管的那一族)、
不带任何类名的一簇按钮挤成 2+1(btnclustercheck 管的那一族)、
`div[role=button]` 没补 tabindex 的鼠标热区、带 `data-clickable` 却没键盘
路径的可点行、我们自己写的 `role=tab` 没进走位清单
(三条都是 semanticcheck 管的那一族)、
只装了一颗 `aria-label=upload` 图标的裸按钮——它的辅助技术名称整个
就是英文字形码(S-2 管的那一族)
——十七种页面夹具缺陷,每条判据必须**点名**到它;
· `pg-*`(good):故意造出二十二种**合法**形态(卡底 mt-auto 钉底、整块居中的排版、
正文 max-w-[72ch] 栏宽、.nex-chipbar 胶囊流、
容器自适应的流程条、让位后与字段同行的复选框、
放得下的「进度条 + 百分数」单元格、
kit Tag 自己收窄成 ellipsis 的长标签、
右端整块掉到第二行之后标题拿到整行的卡头、
整组竖排等宽的按钮组(现行唯一那条豁免)、
整组竖排等宽的浮层底部(ActionGroup 翻竖排之后的形状)、
补了 `tabindex=0` 的自定义控件、原生 `button`、热区里那颗 pointer 图标、
有按钮的行连同它里面的图标、自绘的 `role=img`、antd v5 的图标根节点、
antd 自己的页签(阶段 2 的既定修法与 antd 内部结构,闸门必须放行)、
字形码图标但宿主自己写了 aria-label(名称被接管,必须仍然被采到)、
同一只图标改成 `aria-hidden=true`(登记表的修法)、图标被显式给了
中文名「清空搜索」(后两种必须连候选都不进,S-2)。
· 判据 ⑱(`TABKBD`):**这一条种不出 div 夹具**。被裁的页签在 DOM 里 rect 完整、AX 树照读,
临时 fixture 复现不出「窗口太窄、rc-tabs 自己把页签收进溢出菜单」;假造的
`.ant-tabs-nav-more` 又不会响应 ↓/Enter/Esc,正例永远过不了。所以它开一个真 430
的窗口走 `/models`,在**真触发器**上改坏五次(tabindex=-1 / 抹掉名称来源 /
名称换成字形码 ellipsis / aria-expanded 写死 true / 整颗触发器删掉),
五种必须逐条点名;原样那一遍除了静音还要求 `lists>=1 且 picked>=1`
——它必须真的用键盘选中过一颗被裁页签,读数取不到溢出就直接停。
· 判据 ⑲(`semanticcheck.GLYPH-whole`):**也不是靠页面夹具**。它是「整条可读名称
恰好等于一个登记表字形码」这一支的全部逻辑,本质是一个字符串函数
(DOM 侧与 AX 侧共用),所以直接喂名称表:五个坏名称必须逐条认出,
八个好名称必须逐条放行——`/api/meta`(正文里的路径,撞中的是 `api`)
和 `upload 导入脚本`(半中半英,归 DOM 侧那条管)放行了才算这条没写宽。
· 判据 ⑳(`semanticcheck.LOCALE` / `-seen`,阶段 12 · S-3 根因):语言包静默回落 enUS 时
只有 antd 内置件自己写的文案会变英文(分页 `Previous Page`、空态 `No data`)。
夹具种在 `.ant-pagination` / `.ant-empty` / `.ant-input-number` 三个真作用域里:
三条坏形状必须点名(`Previous Page`、`No data`、步进器的 `Increase Value`——
最后那条 2026-11-09 阶段 18 起在册豁免已清空,kit 改名一失效它就该响);
`上一页`、`暂无数据`、`增加数值` 三条好形状必须放行,
**而且必须仍然被采集面点名**——采不到就等于判据瞎了,
「放行」是空转(GLYPH 那对 seen/verdict 的教训,别再犯一次)。
任何一条对不上就退出 1——说明闸门瞎了或者过敏,先修闸门再谈页面。
同一块夹具会被几条判据分别评,所以夹具种数(`pb-*` 坏形状 / `pg-*` 好形状,按类名实数会随判据增减,
另外 5 种是判据 ⑱ 在真页面上改出来的坏形状,判据 ⑲ 喂的是名称表不是夹具)
与判据条数本来就对不上:末行 `GATEPROBE_OK N/N` 数的是**判据**(`len(checks) + 11`:
页面 18 条 + TABKBD ⑱ + 整名 ⑲ + classaudit 第 2 闸 ⑰ + 产物预算闸 ㉒ + 图标命名闸 ㉓
+ AT 图形中文名闸 ㉔(阶段 23 · S-2 收口,静态喂形状表)
+ 图标登记表两级表闸 ㉖(阶段 25 · Bundle 收口,四棵临时树喂 classaudit)
+ 归属尺自证空转闸 ㉗(阶段 31 · Bundle 结案,三棵临时 dist 喂 chunkinfo:点名 / 静音 / 空转必须各就各位)
+ 项目切换探测器自证闸 ㉘(阶段 33 · 第 14 道常驻探针,喂合成读数给 `matches()`:命中与不命中必须各就各位)
+ S-2 宿主级缺名闸 ㉙(阶段 34 · 喂「名称已为空的宿主」形状表给 `nameless_icon_host`:七坏五好各就各位)
+ 原生文件控件文案闸 ㉚(阶段 35 · S-3 · 喂 `<input type=file>` 的**算完名称表**给 `file_name_defect`:三坏四好各就各位 —— 这一族的英文活在影子 DOM 里,LOCALE 与 GLYPH 五支都量不到,只能钉名称表:没有 aria-label、纯英文 aria-label 必须点名,中文名称与「动作 + 选择文件」这种带上下文的长名必须放行)= 29 条),
别拿它去核对 fixture 个数。
判据 ⑰(`classaudit.GATE2-*`)不在页面上:**静态闸门读的是源文件,页面上种不出反例**,
所以把真登记表抄进临时目录、改出三种绕过 `decorative()` 的写法喂给 classaudit——
坏形状必须逐条点名、真登记表必须全程静音,锚点在登记表里找不到时直接停(不许退化成恒真)。
再一条同理不吃页面:`classaudit.GATE2B-*`(阶段 17 · S-2 复扫)读源码,喂的是临时目录里的
一份夹具 + 两份**真页面文件**(抽屉 ✕、分镜行内图标钮)——坏形状三条点名、好形状整片静音、
真文件也必须静音,这条闸管的是「图标被藏起来之后控件彻底没名字」,占这一族一半的浮层控件
只有源码闸量得到。
最后一条判据(`chunkbudget.*` · 阶段 16)同理不吃页面:它读的是**构建产物**,所以喂临时 dist——
七种坏/好形状 + 真产物必须静音,其中「没 budget 要喊 DEGRADED」与「DEGRADED 仍按 1 500 kB 判」
两条钉的是同一个退化路径的两面(只钉一面,工具可以永远走兜底 / 永远把兜底当放宽)。
用法:
.venv/bin/python scripts/ui/gateprobe.py
"""
import importlib.util
import os
import json
import pathlib
import re
import subprocess
import sys
import tempfile
from playwright.sync_api import sync_playwright
HERE = pathlib.Path(__file__).resolve().parent
BASE = os.environ.get("NEX_BASE", "http://127.0.0.1:5173")
USER = os.environ.get("NEX_USER", "admin")
PWD = os.environ.get("NEX_PASS", "admin@123")
CLASSAUDIT = HERE / "classaudit.mjs"
CHUNKBUDGET = HERE / "chunkbudget.mjs"
REAL_DIST = HERE.parents[1] / "frontend" / "dist"
REAL_DIST_SM = HERE.parents[1] / "frontend" / "dist-sm" # 带 map 的产物;没有就退到 dist(归属段自动跳过)
CHUNKINFO = HERE / "chunkinfo.mjs"
REGISTRY = HERE.parents[1] / "frontend" / "src" / "components" / "icons" # 阶段 25 起是目录(core.ts / extra.ts / index.ts / _kit.ts)
def registry_files():
"""登记表目录里的全部 .ts —— 反向验证的锚点必须在**整个目录**里找。
只读 `index.ts` 的话,拆表后 `IconUpload` 搬进 `extra.ts`,锚点找不到,
这条判据会当场停(而不是退化成恒真):房规「登记一把尺必须当场试一次这把尺」。
"""
out = {p.name: p.read_text(encoding="utf8") for p in sorted(REGISTRY.glob("*.ts"))}
if not out:
raise SystemExit(f"GATEPROBE_FAIL —— 登记表目录里一个 .ts 都没有:{REGISTRY}")
return out
def write_registry(d, files):
"""把一份登记表原样落到临时源码树里(保持多文件形状,别摊成一个 index.ts)。"""
(d / "components" / "icons").mkdir(parents=True, exist_ok=True)
for name, text in files.items():
(d / "components" / "icons" / name).write_text(text, encoding="utf8")
return d
# 判据 ⑰ 的反例:登记表里**真实存在**的三行,逐行换成三种「绕过 decorative()」的写法。
# 锚点找不到就直接停——登记表改名时这条反向验证会先喊,而不是悄悄退化成恒真。
BAD_SHAPES = [
("export const IconUpload = decorative(UploadOutlined, 'IconUpload')",
"export { UploadOutlined } from '@ant-design/icons'\nexport const IconUpload = UploadOutlined"),
("export const IconChevronDown = decorative(DownOutlined, 'IconChevronDown')",
"export const IconChevronDown = decorative(DownOutlined, 'IconArrowDown')"),
]
# ── 判据 ⑱(TABKBD · 阶段 9 · S-3)的反例:窄屏溢出页签那颗「更多」触发器。
# 这一条**种不出 div 夹具**:被裁的那几颗页签在 DOM 里 rect 完整、AX 树照读得到,
# 源码字符串与临时 fixture 都造不出「窗口太窄、rc-tabs 把页签收进溢出菜单」这个前提——
# 只有真的把窗口收到 430、让组件自己溢出,判据才有东西可看。所以这段直接在真页面上
# **改真东西**(每改一种坏形状重新加载一次,页面自己复位,不留残留):
# 五反一正。正例除了「静音」还要求 `picked>=1`——它必须在 430 的溢出条带上真的用键盘
# 选中过一颗被裁页签,才算这条判据没有空转(它历史上空转过一次:恒 0 看着像全绿)。
# · pb-tkbd-unfocusable:给那颗真 button 铺 tabindex=-1 → 键盘到不了(判据①)
# · pb-tkbd-nameless :抹掉名称来源(内层图标的 aria-label)→ AT 读作未命名按钮(判据②)
# · pb-tkbd-glyph :名称换成字形码 ellipsis → S-2 那族缺陷换个位置复发(判据②)
# · pb-tkbd-stuckopen :aria-expanded 写死 true 不翻 → 声明与行为不一致(判据③)
# · pb-tkbd-nowmore :触发器整颗没了但页签仍被裁 → 窄屏把页签弄丢了(前置检查)
TKBD_ROUTE = "/models"
TKBD_DEFECTS = [
("pb-tkbd-unfocusable",
"() => { const m = document.querySelector('.ant-tabs-nav-more');"
" m.tabIndex = -1; return 1 }",
"不可聚焦"),
("pb-tkbd-nameless",
"() => { const m = document.querySelector('.ant-tabs-nav-more');"
" const s = m.querySelector('[role=img],.anticon');"
" if (s) { s.removeAttribute('aria-label'); s.setAttribute('aria-hidden','true'); } return 1 }",
"没有名字"),
("pb-tkbd-glyph",
"() => { const m = document.querySelector('.ant-tabs-nav-more');"
" const s = m.querySelector('[role=img],.anticon');"
" if (s) s.setAttribute('aria-label','ellipsis'); return 1 }",
"混进字形码"),
("pb-tkbd-stuckopen",
"() => { document.querySelector('.ant-tabs-nav-more')"
".setAttribute('aria-expanded','true'); return 1 }",
"aria-expanded=true"),
("pb-tkbd-nowmore",
"() => { document.querySelector('.ant-tabs-nav-more').remove(); return 1 }",
"找不到「更多」触发器"),
]
def tabkbd_negative(pw):
"""在真实窄屏溢出的那一页上把 TABKBD 跑六遍:原样必须静音且真选中过,五种坏形状必须逐条点名。
返回 [(marker, 必须点名的半句话 | None, offenders 摊平串, 覆盖读数)],交给主循环逐条 verdict。
锚点(430 的 /models 会溢出)读不到溢出时**直接停**:前提变了就别退化成恒真。
"""
out = []
b = pw.chromium.launch()
ctx = b.new_context(viewport={"width": 430, "height": 900})
pg = ctx.new_page()
pg.set_default_timeout(20000)
cdp = ctx.new_cdp_session(pg)
cdp.send("DOM.enable")
cdp.send("Accessibility.enable")
semanticcheck.login(pg)
for marker, inject, expect in ([("<原样>", None, None)]
+ [(m, j, e) for m, j, e in TKBD_DEFECTS]):
pg.goto(BASE + TKBD_ROUTE, wait_until="networkidle")
pg.wait_for_timeout(1600)
if inject:
pg.evaluate(inject)
off, cov = [], []
stat = semanticcheck.tab_kbd_check(pg, cdp, "gateprobe/" + marker, off, cov)
out.append((marker, expect, " | ".join(off), stat))
b.close()
first = out[0][3]
if first["lists"] < 1 or first["picked"] < 1:
raise SystemExit(
"GATEPROBE_FAIL semanticcheck.TABKBD —— 反向验证的前提没了:%s 在 430 档"
"读不到溢出页签(lists=%s picked=%s)。要么这一页的页签变少了/变窄了,"
"要么 rc-tabs 换了溢出实现 → 先换夹具页,别让这条判据悄悄空转。"
% (TKBD_ROUTE, first["lists"], first["picked"]))
return out
def load(mod_name: str):
"""按路径加载闸门模块,直接复用它们的探针 JS,避免同一份判据写两遍。"""
spec = importlib.util.spec_from_file_location(mod_name, HERE / f"{mod_name}.py")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
tagcheck = load("tagcheck")
rhythmcheck = load("rhythmcheck")
gridcheck = load("gridcheck")
btnrowcheck = load("btnrowcheck")
footercheck = load("footercheck")
btnclustercheck = load("btnclustercheck")
tableaudit = load("tableaudit")
semanticcheck = load("semanticcheck")
projectswitchcheck = load("projectswitchcheck")
# 反向验证必须和被测闸门指向**同一个**前端:两个脚本的默认 BASE 都是 :5173
# (与 `nex.config.yaml` 的 `dev_base_url` 同一口径),但这里仍然显式覆盖 —— 各自读 env 的话,
# 只给 gateprobe 传 NEX_BASE 会让 TABKBD 那一段去一个没人服务的地址上找溢出页签,然后抱怨「锚点找不到」。
semanticcheck.BASE, semanticcheck.USER, semanticcheck.PWD = BASE, USER, PWD
FIXTURE = r"""() => {
const old = document.getElementById('nex-gateprobe'); if (old) old.remove();
const host = document.createElement('div');
host.id = 'nex-gateprobe';
host.style.cssText = 'padding:24px;display:flex;flex-direction:column;gap:0';
host.innerHTML = `
<div class="pb-gap" style="display:flex;flex-direction:column;width:400px">
<div style="height:30px"></div>
<div style="height:30px;margin-top:8px"></div>
<div style="height:30px;margin-top:20px"></div>
</div>
<span class="ant-tag pb-tag" style="display:inline-block;width:120px;height:24px;
background:#f6ffed;color:#237804;border:1px solid #b7eb8f">反向验证标签</span>
<div class="pb-rag" style="display:flex;flex-direction:column;align-items:flex-start;width:400px">
<div style="width:400px;height:30px"></div>
<div style="width:150px;height:30px"></div>
<div style="width:250px;height:30px"></div>
</div>
<div class="pb-grid" style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:900px">
<input class="ant-input" style="width:120px" value="甲" />
<input class="ant-input" style="width:300px" value="乙" />
<input class="ant-input" style="width:160px" value="丙" />
</div>
<div class="pg-pin" style="display:flex;flex-direction:column;height:200px;width:400px">
<div style="height:40px"></div>
<div style="height:40px"></div>
<div class="mt-auto" style="height:40px"></div>
</div>
<div class="pg-center" style="display:flex;flex-direction:column;align-items:center;width:400px">
<div style="width:400px;height:30px;align-self:center"></div>
<div style="width:150px;height:30px;align-self:center"></div>
<div style="width:200px;height:30px;align-self:center"></div>
</div>
<div class="pg-measure" style="display:flex;flex-direction:column;width:400px">
<div style="height:30px"></div>
<div style="height:30px;max-width:200px"></div>
<div style="height:30px;max-width:240px"></div>
</div>
<div class="nex-action-group pb-btn" style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:260px">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div>
<!-- 判据① 唯一的豁免(第 17 轮起):竖排等宽里子项本来就在不同水平线,必须放行 -->
<div class="nex-action-group ant-flex-vertical pg-stack"
style="display:flex;flex-direction:column;gap:8px;width:260px">
<button class="ant-btn" style="width:260px;height:32px">甲</button>
<button class="ant-btn" style="width:260px;height:32px">乙</button>
</div>
<!-- 被删掉的那条「<header> 里的组在 <1024 允许分行」不许悄悄回来:
坐在 header 里的横排组被劈成 2+1,一样要响 -->
<header><div class="nex-action-group pb-header"
style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:260px">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div></header>
<div class="nex-chipbar pg-chipbar" style="display:flex;flex-direction:row;flex-wrap:wrap;gap:8px;width:900px">
<span class="nex-chip ant-tag ant-tag-checkable" style="display:inline-block;width:80px;height:24px">甲</span>
<span class="nex-chip ant-tag ant-tag-checkable" style="display:inline-block;width:210px;height:24px">乙乙乙</span>
<span class="nex-chip ant-tag ant-tag-checkable" style="display:inline-block;width:120px;height:24px">丙丙</span>
</div>
<div role="list" class="pb-rail" style="display:flex;flex-direction:row;gap:8px;width:400px;
overflow-x:auto">
<div style="flex:none;width:200px;height:30px">完整视频</div>
<div style="flex:none;width:200px;height:30px">音效</div>
<div style="flex:none;width:200px;height:30px">字幕</div>
<div style="flex:none;width:200px;height:30px">交付包</div>
</div>
<div role="list" class="pg-rail" style="display:grid;width:900px;gap:8px;
grid-template-columns:repeat(auto-fill,minmax(140px,1fr))">
<div style="min-width:0;height:30px">完整视频</div>
<div style="min-width:0;height:30px">音效</div>
<div style="min-width:0;height:30px">字幕</div>
<div style="min-width:0;height:30px">交付包</div>
</div>
<div class="ant-row nex-form-row pb-ctl" style="display:flex;width:700px">
<div class="ant-col" style="width:300px">
<div class="ant-form-item">
<div class="ant-form-item-label" style="height:30px;line-height:30px;padding:0">环境声</div>
<div class="ant-form-item-control"><div class="ant-form-item-control-input"
style="height:32px"><input class="ant-input" style="width:100%" value="底噪"></div></div>
</div>
</div>
<div class="ant-col" style="width:300px">
<label class="ant-checkbox-wrapper" style="display:inline-block;margin-top:0;height:auto">启用字幕</label>
</div>
</div>
<div class="ant-row nex-form-row pg-ctl" style="display:flex;width:700px">
<div class="ant-col" style="width:300px">
<div class="ant-form-item">
<div class="ant-form-item-label" style="height:30px;line-height:30px;padding:0">环境声</div>
<div class="ant-form-item-control"><div class="ant-form-item-control-input"
style="height:32px"><input class="ant-input" style="width:100%" value="底噪"></div></div>
</div>
</div>
<div class="ant-col" style="width:300px">
<label class="ant-checkbox-wrapper" style="display:flex;align-items:center;height:32px;margin-top:30px">启用字幕</label>
</div>
</div>
<div class="nex-taggroup" style="width:220px"><span class="ant-tag pb-spill"
style="white-space:nowrap">反向验证长标签整句散文当只读标签必然捅出容器右缘</span></div>
<div class="nex-taggroup" style="width:220px"><span class="ant-tag nex-tag pg-spill"
><span class="nex-tag-text">合法长标签整句散文当只读标签由 kit 收在容器内</span></span></div>
<div class="ant-card" style="width:320px"><div class="ant-card-head-title">pb-tspill</div>
<div class="ant-table-wrapper"><div class="ant-table-content">
<table style="table-layout:fixed;width:300px"><tbody class="ant-table-tbody"><tr>
<td style="width:300px;padding:8px;white-space:nowrap;text-align:right">
<div style="display:inline-block;width:284px;height:6px;background:#1677ff"></div>
<small class="pb-tspill">100%</small>
</td>
</tr></tbody></table>
</div></div>
</div>
<div class="ant-card" style="width:320px"><div class="ant-card-head-title">pg-tspill</div>
<div class="ant-table-wrapper"><div class="ant-table-content">
<table style="table-layout:fixed;width:300px"><tbody class="ant-table-tbody"><tr>
<td style="width:300px;padding:8px;white-space:nowrap;text-align:right">
<div style="display:inline-block;width:220px;height:6px;background:#1677ff"></div>
<small class="pg-tspill">100%</small>
</td>
</tr></tbody></table>
</div></div>
</div>
<!-- 判据②(btnrowcheck.HEAD):320 的卡头里标题只剩 82px,
「还有一整块可以挪下去」却把标题切成两行 = 必须响 -->
<div class="ant-card nex-panel" style="width:320px"><div class="ant-card-head">
<div class="ant-card-head-wrapper" style="display:flex;flex-wrap:wrap">
<div class="ant-card-head-title" style="flex:1 1 0">
<span>pb-head镜头质检结论汇总清单表</span></div>
<div class="ant-card-extra" style="flex:0 0 auto;width:190px">重新质检 / 导出报告</div>
</div></div>
</div>
<!-- 浮层底部(footercheck):和页头同一个毛病,只是它长在抽屉里。
300 宽 260 内宽里三颗 120 的按钮挤成 2+1 = 必须响 -->
<div class="ant-drawer-footer pb-footer"
style="width:300px;padding:12px 20px;display:flex;flex-wrap:wrap;gap:8px;justify-content:flex-end">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div>
<!-- 裸按钮簇(btnclustercheck):没有 kit 类名、不是浮层底部,前两道按钮闸结构上扫不到。
260px 里三颗 120 的按钮挤成 2+1 = 必须响(证明这把新尺子真的在看 DOM) -->
<div class="pb-cluster" style="width:260px;display:flex;flex-wrap:wrap;gap:8px">
<button class="ant-btn" style="width:120px;height:32px">甲</button>
<button class="ant-btn" style="width:120px;height:32px">乙</button>
<button class="ant-btn" style="width:120px;height:32px">丙</button>
</div>
<!-- 同一簇整组换行、每颗占满内宽(ActionGroup 的竖排档就是这个形状)= 必须放行 -->
<div class="pg-cluster" style="width:260px;display:flex;flex-wrap:wrap;gap:8px">
<button class="ant-btn" style="width:100%;height:32px">甲</button>
<button class="ant-btn" style="width:100%;height:32px">乙</button>
<button class="ant-btn" style="width:100%;height:32px">丙</button>
</div>
<!-- 底部交给 ActionGroup 之后窄屏的样子:整组竖排等宽 = 必须放行 -->
<div class="ant-drawer-footer pg-footer"
style="width:300px;padding:12px 20px;display:flex;flex-direction:column;gap:8px">
<button class="ant-btn" style="width:100%;height:32px">甲</button>
<button class="ant-btn" style="width:100%;height:32px">乙</button>
</div>
<!-- 同一句长标题,右端整块掉到第二行(kit 的 nex-head-stack 就是这个形状):
标题拿到整行,折行是排版 = 必须放行 -->
<div class="ant-card nex-panel" style="width:320px"><div class="ant-card-head">
<div class="ant-card-head-wrapper" style="display:flex;flex-wrap:wrap;row-gap:8px">
<div class="ant-card-head-title" style="flex:1 1 auto">
<span>pg-head模型配置已迁移至独立管理中心请前往模型控制台</span></div>
<div class="ant-card-extra" style="flex:1 1 100%">重新质检 / 导出报告</div>
</div></div>
</div>`;
(document.querySelector('main') || document.body).appendChild(host);
/* 语义热区的夹具必须种在 **body 直下**(第 8.5 轮的教训):semanticcheck 的 HOTSPOT
只审我们自己写的标记,main 是 `.ant-layout-content`、整棵树又裹在 `.ant-app` 里,
夹具种进 main 就会被「这是 antd 的东西」顺手放过——夹具假绿比没夹具更糟。
它同时是这条判据的**视力表**:这一族空转过一次(12 路由 × 3 视口恒 0),
靠的就是这对 fixture 报出来的。 */
const old2 = document.getElementById('nex-gateprobe-sem'); if (old2) old2.remove();
const host2 = document.createElement('div');
host2.id = 'nex-gateprobe-sem';
host2.style.cssText = 'display:flex;flex-direction:column;gap:8px;width:400px';
host2.innerHTML = `
<!-- 名字故意两两不互为前缀:hay 是子串匹配,pb-sem / pb-sem2 那种命名会让
「A 被点名」其实是 B 命中的,夹具就白造了 -->
<!-- ① div + role=button + cursor:pointer,没给 tabindex:鼠标点得动、Tab 到不了 = 必须点名 -->
<div class="pb-sema" role="button" style="cursor:pointer;height:32px;line-height:32px">
反向验证热区</div>
<!-- ② 同一个热区补上 tabindex=0(阶段 2 的修法)= 必须放行 -->
<div class="pg-sema" role="button" tabindex="0"
style="cursor:pointer;height:32px;line-height:32px">补过 tabindex 的热区</div>
<!-- ③ 原生 button = 天生可聚焦,必须放行(证明这条没在乱咬原生标签) -->
<button class="pg-semb" type="button" style="cursor:pointer;height:32px">原生按钮</button>
<!-- ④ 带 data-clickable(阶段 2 的热区约定)却没键盘路径 = 我们食言了,必须点名;
它里面那颗 pointer 图标只报最外层 = 必须放行 -->
<div class="pb-semb" data-clickable style="cursor:pointer;height:32px;line-height:32px">
可点的行<span class="pg-semc" style="cursor:pointer">行里的图标</span></div>
<!-- ⑤ 同样是 data-clickable 热区,但行里坐着一颗真按钮:键盘走得到那颗按钮
= 整行连同行里的图标都必须放行(噪声①/②,别把可点行报成两处) -->
<div class="pg-semd" data-clickable style="cursor:pointer;height:36px;line-height:36px">
有按钮的行<button class="pg-seme" type="button">打开</button></div>
<!-- ⑥ 我们自绘的 role=img(pointer、没 tabindex):HOTSPOT 的承诺是
「鼠标点得着的东西键盘也到得了」,这只对**交互角色**成立;img 只是语义标注,
要求它自己有 Tab 序列是判据越界(第 8.5 轮实测:每主题 5 条纯噪声)。
必须「收进候选、但不进硬档」。 -->
<span class="pg-semf nex-iconmark" role="img" style="cursor:pointer;display:block;height:20px">自绘的图标标注</span>
<!-- ⑦ antd v5 的图标根节点 class="anticon anticon-appstore",**不含 ant- 子串**:
认不出它就把 antd 自己的东西当成我们写的标记(实测每主题 5 条假阳性)。必须整个不收。 -->
<span class="pg-simg anticon anticon-appstore" role="img" style="cursor:pointer;display:block;height:20px">antd 图标</span>
<!-- ⑨ S-2 字形码外泄(2026-11-08 · 阶段 8.5.1):四种形状分开钉。
a) 图标自带 aria-label=英文字形码 + 宿主是**只装了这颗图标的裸 button**
→ 辅助技术名称只能按 contents 算,「upload」就是它全部的名字 = 必须点名;
b) 同一只图标,宿主 button 自己写了 aria-label → 名称被宿主接管 = 必须放行,
但**必须仍然被采集到**(不采集 = 判据瞎,看不出它其实是漏了);
c) 登记表的修法:aria-hidden=true → 连候选都不该进 = 必须不收;
d) 显式给过语义名(「清空搜索」,名字 ≠ 类名后缀)= 图标自己承担语义 = 必须不收。
四种里放错任何一种,这条要么恒绿(a 漏检)要么 78 只装饰图标全变噪声(b/c 误报)。 -->
<button class="pb-glyph" type="button" style="height:28px">
<span role="img" aria-label="upload" class="anticon anticon-upload"
style="display:inline-block;width:14px;height:14px"></span></button>
<button class="pg-glyph" type="button" aria-label="导入脚本" style="height:28px">
<span role="img" aria-label="upload" class="anticon anticon-upload"
style="display:inline-block;width:14px;height:14px"></span></button>
<button class="pg-glyph2" type="button" style="height:28px">导入脚本
<span role="img" aria-hidden="true" class="anticon anticon-upload"
style="display:inline-block;width:14px;height:14px"></span></button>
<button class="pg-glyph3" type="button" style="height:28px">
<span role="img" aria-label="清空搜索" class="anticon anticon-close-circle"
style="display:inline-block;width:14px;height:14px"></span></button>
<!-- ⑩ 页签走位清单(TAB 的输入):我们自己写的 role=tab 必须在册(否则 TAB 永远查不到它),
antd 的 .ant-tabs-tab-btn 必须不在册——它是 rc-tabs 自己的 DOM,
tabindex 归 antd 管(实测每主题 3 条假阳性,根因是自己的类名撞了 SHELL 名单被抢先豁免)。 -->
<div class="pb-semt" role="tab" tabindex="0" style="cursor:pointer;height:28px;line-height:28px">我们的页签</div>
<div class="pg-semt ant-tabs-tab-btn" role="tab" tabindex="0"
style="cursor:pointer;height:28px;line-height:28px">antd 的页签</div>
<!-- ⑪ S-3 根因(阶段 12):antd 中文语言包没生效时**静默**回落 enUS,
只有它家自己写的文案会变英文。作用域靠 ant- 类认,所以夹具必须种进真作用域,
而 marker 类名要打在**被读的那个节点自己身上**(sig() 会剥掉 ant- 类,
打在包裹层上就点不出名)。类名两两不互为前缀:hay 是子串匹配。 -->
<ul class="ant-pagination" style="list-style:none;padding:0;margin:0;display:flex;gap:4px">
<li class="pb-locprev ant-pagination-item-link" title="Previous Page"
style="display:block;width:24px;height:24px">‹</li>
<li class="pg-loczh ant-pagination-item-link" title="上一页"
style="display:block;width:24px;height:24px">‹</li>
</ul>
<div class="ant-empty" style="display:block;width:160px;height:40px">
<span class="pb-locdata ant-empty-description"
style="display:block;width:80px;height:16px">No data</span>
<span class="pg-loctxt ant-empty-description"
style="display:block;width:80px;height:16px">暂无数据</span>
</div>
<!-- 步进器那颗(阶段 18 语义翻转):kit 的改名收口之前它是「在册豁免唯一的真住户」,
豁免表清空之后英文名就是违规;中文那颗是好形状必须放行——两条一起才量得出
「改名生效」与「改名没把中文误判成英文」两个方向。 -->
<div class="ant-input-number" style="display:block;width:80px;height:32px">
<span class="pb-locnum ant-input-number-handler ant-input-number-handler-up"
aria-label="Increase Value" style="display:block;width:16px;height:16px"></span>
<span class="pg-locnumzh ant-input-number-handler ant-input-number-handler-down"
aria-label="增加数值" style="display:block;width:16px;height:16px"></span>
</div>
`;
document.body.appendChild(host2);
return [...host.querySelectorAll('[class]'), ...host2.querySelectorAll('[class]')].length;
}"""
def names(rows, key):
"""把检出结果摊平成「元素标记串」,再用 fixture 的类名点名。
`key` 可以是字段名,也可以是函数:tableaudit 的 PROBE 会把页面上**每一张**表
都返回(不管有没有违规),按 `title` 摊平的话合法 fixture 也会出现在串里,
「必须放行」永远对不上——所以给它一个只摊平违规明细的函数。
"""
# COLLECT 这类探针一次返回一整个 dict(热区/Tab 目标/aria/live/状态各一桶),
# 不是行数组。直接 for r in dict 摊到的是**键名**(字符串),r.get 当场 AttributeError。
if isinstance(rows, dict):
rows = [rows]
if callable(key):
return " | ".join(str(x) for r in rows for x in key(r))
return " | ".join(str(r.get(key, "")) for r in rows)
def run_classaudit(src: pathlib.Path):
"""在临时源码目录上跑一遍 classaudit,只取图标闸的两类点名行。
其余八闸在只有两三个文件的空目录里必然报 BP 噪音,所以这里**不看退出码**,
只核对 `ICONA `(登记表出口形状)与 `ICON `(绕过登记表的外部 import)。
"""
out = subprocess.run(["node", str(CLASSAUDIT), str(src)],
capture_output=True, text=True, timeout=300)
lines = (out.stdout or "").splitlines()
return [ln for ln in lines if ln.startswith("ICONA ")] + [ln for ln in lines if ln.startswith("ICON ")]
def gate2_static():
"""把真登记表**整目录**抄进临时目录,喂 classaudit 跑「好形状 / 坏形状」各一遍。"""
reg = registry_files()
with tempfile.TemporaryDirectory(prefix="nex-gate2-") as td:
root = pathlib.Path(td)
bad_src = dict(reg)
for old, new in BAD_SHAPES:
hit = [n for n, t in bad_src.items() if t.count(old) == 1]
if len(hit) != 1:
raise SystemExit(f"GATEPROBE_FAIL classaudit.GATE2 —— 反向验证的锚点在登记表目录里找不到或不止一处"
f"(命中 {hit}):{old}"
" → 登记表那行改名/删除/挪表时,先同步这里的 fixture,别让这条判据变成空转")
bad_src[hit[0]] = bad_src[hit[0]].replace(old, new, 1)
shapes = {}
for tag, files, extra in (("good", reg, "import { IconUpload } from './components/icons'\n"),
("bad", bad_src, "import { StarOutlined } from '@ant-design/icons'\n")):
d = root / tag
write_registry(d, files)
(d / "Probe.tsx").write_text(extra, encoding="utf8")
shapes[tag] = " || ".join(run_classaudit(d))
return shapes
PROBE_BAD = """\
import { Button } from './components/ui/Button'
import { IconClose, IconDelete, IconMore } from './components/icons'
export const A = () => <Button icon={<IconClose />} onClick={() => {}} />
export const B = () => <Button icon={<IconClose />} aria-label="关闭" onClick={() => {}} />
export const C = () => <Button icon={<IconClose />} title="关闭" onClick={() => {}} />
export const D = () => <Button icon={<IconDelete />} danger>删除</Button>
export const E = () => (
<Button
type="text"
icon={<IconClose />}
aria-label="多行也要认"
/>
)
export const F = () => <IconMore aria-label="more" />
export const G = () => <IconMore aria-label="更多页签" />
export const H = () => <IconMore aria-label="" />
// export const I = () => <Button icon={<IconClose />} />
/* export const J = () => <Button icon={<IconClose />} /> */
export const K = () => <Button icon={on ? <IconClose /> : <IconDelete />} onClick={go} />
export const L = () => <Button icon={on ? <IconClose /> : <IconDelete />} aria-label="切换" onClick={go} />
export const M = () => <Tag closable closeIcon={<IconClose />} />
// ④(阶段 32 · S-2 复扫):图标写在 children 里的图标钮——① 的两条前提都不成立
export const N = () => <button type="button" onClick={go}><IconClose /></button>
export const O = () => <Button onClick={go}>{on ? <IconClose /> : <IconDelete />}</Button>
"""
# ③ 那一支的**好形状**(阶段 23 · S-2 收口):槽位里的图标自带中文名字、三元写法、
# 表达式(认不出就不判)、以及「图标在宿主的 icon 槽里而宿主自己报名」——四种都不许连坐。
# 这一族今天全站只有两处真调用(`Ctlbar.tsx:338` 胶囊 ✕、`Input.tsx:183` 清空搜索),
# 好形状一旦误报,被改写的就是那两句刚补上的中文名字。
PROBE_GOOD = """\
import { Button } from './components/ui/Button'
import { IconChevronLeft, IconClear, IconClose, IconDelete, IconUpload } from './components/icons'
export const P = () => <Tag closable closeIcon={<IconClose aria-label="移除" />} />
export const Q = () => <Tag closable closeIcon={onRemove ? <IconClose aria-label="移除" /> : undefined} />
export const R = () => <Search allowClear={{ clearIcon: <IconClear aria-label="清空搜索" /> }} />
export const S = () => <Button icon={<IconClose />} aria-label="关闭抽屉" />
export const T = () => <Tag closable closeIcon={myIcon} />
// ④ 的好形状(阶段 32):U / V / W 三颗**必须被覆盖率行采到并放行**(children 只有图标、名字写在宿主上),
// X / Y / Z / AA 四颗**必须整个跳过**(children 里出了字或看不出会不会出字)——
// 前者证明这支闸真的在看东西,后者证明它没有宽到把有文字的按钮也拖进来点名。
export const U = () => <Button onClick={go} aria-label="关闭"><IconClose /></Button>
export const V = () => (
<Button
type="text"
onClick={go}
aria-label="多行写名字的图标钮"
>
<IconClose />
</Button>
)
export const W = () => <Button onClick={go} title="上一个"><IconChevronLeft /></Button>
export const X = () => <Button onClick={go}><IconUpload />导入脚本</Button>
export const Y = () => <Button onClick={go}><IconClose /><span>关闭这一层</span></Button>
export const Z = () => <Button onClick={go}>{row.label}</Button>
export const AA = () => <Button onClick={go}>{on ? <IconClose /> : '删除'}</Button>
"""
PROBE_REAL = ["frontend/src/components/ui/Overlay.tsx", "frontend/src/pages/project/Storyboard.tsx"]
def gate2b_static():
"""判据 ㉓(阶段 17 · S-2 复扫):classaudit 第 2 条·附二「图标型控件必须报名」的反向验证。
这条闸量的是「一颗只画图标的按钮 / 链接,有没有对辅助技术报出自己的名字」。
和 ⑰ 一样喂临时目录:静态闸读源文件,页面上种不出反例。
七种坏形状必须逐条点名(少一颗名字 / 名字写成英文字形码 / 名字写成空串 /
closeIcon 槽里那颗没报名 / children 只有图标的 <button> / children 是换图形三元表达式的
<Button>),十二种好形状必须静音——其中「有 children」「多行写 aria-label」「注释里那一颗」
「换图标的三元表达式」四条是这条闸最容易写宽的地方,误报的下场和漏报一样:被关掉。
阶段 23 起这一条多了第三支(classaudit 第 2 条·附二 ③:`closeIcon=` / `clearIcon=`
这类「antd 把 onClick 克隆到图标本体」的槽位),夹具同步:坏形状加 `M`(胶囊 ✕ 不写名字),
好形状另开一份 `PROBE_GOOD`(自带中文名 / 三元 / 表达式 / 宿主报名四种),
它和真页面文件一起写进 good 目录——good 目录必须整片静音。
阶段 32 起这一条还有第四支(classaudit 第 2 条·附二 ④:`<Button …><IconClose /></Button>`
这种把图标写在 children 里的图标钮,① 的「自关闭 + icon 槽」两条前提一条都不成立),
夹具同步:坏形状加 `N`(裸 children 图标)与 `O`(children 是三元换图形),
好形状加 `U`/`V`/`W`(名字写在宿主上:aria-label / 多行 aria-label / title,必须被
`ICNN-COVER` 采到)与 `X`/`Y`/`Z`/`AA`(children 里有裸文字 / 有 `<span>` 包的字 /
是 `{row.label}` / 三元的一个分支是字符串——四种都必须整片跳过)。
另外拿**真页面文件**(Overlay.tsx 的抽屉 ✕、Storyboard.tsx 的 8 颗行内图标钮)
跑一遍要求静音:这一族控件一半活在浮层里(探针点开不到),真文件静音才算
这条闸站在现网代码上量得出对的结果,而不是只在自家夹具里自证。
"""
root_dir = HERE.parents[1] # 仓库根:PROBE_REAL 按 frontend/src/... 取真文件
with tempfile.TemporaryDirectory(prefix="nex-gate2b-") as td:
root = pathlib.Path(td)
shapes = {}
for tag in ("bad", "good"):
d = root / tag
write_registry(d, registry_files())
if tag == "bad":
(d / "Probe.tsx").write_text(PROBE_BAD, encoding="utf8")
else:
(d / "ProbeGood.tsx").write_text(PROBE_GOOD, encoding="utf8")
for rel in PROBE_REAL:
f = d / pathlib.Path(rel).name
f.write_text((root_dir / rel).read_text(encoding="utf8"), encoding="utf8")
out = subprocess.run(["node", str(CLASSAUDIT), str(d)],
capture_output=True, text=True, timeout=300)
lines = (out.stdout or "").splitlines()
# 点名行 + 那行计数都要留下:计数行是「好的一面必须静音」唯一的证据
# (只有点名行时,好形状与「这条闸根本没跑」在输出里长得一模一样)。
shapes[tag] = " || ".join(ln for ln in lines
if ln.startswith("ICNN ") or ln.startswith("ICNN-COVER ")
or "处图标型控件缺自然语言名称" in ln)
return shapes
def split_static():
"""判据 ㉖(阶段 25 · Bundle):classaudit 第 2 条·附三「两级表边界」的反向验证。
这条闸守的是**已实测兑现的首屏收益**(首屏 gzip −4.74 kB / −1.03 %,
`reports/ui_evidence/nex-p25/bundle-landing.log`),而它的两条回退路径都骗得过 tsc:
桶里多一句 `export * from \'./extra\'`、或外壳文件深 import 一次 `icons/extra`
——两种都编译通过、页面照常、产物里 extra 悄悄回到首屏。所以必须在这里种反例。
临时树刻意搭成**两级表**的最小形状(main → App 静态、App → Lazy 动态),
因为这条闸的判定对象就是「静态闭包」:动态边界两侧的结论必须相反,
把 `Lazy.tsx` 改成静态 import 就是 bad-shell 那一腿,夹具里不用另搭一棵树。
四个变体:good(extra 只被动态边界那边引用)/ bad-bucket / bad-shell / bad-dup。
good 一面除了「ICONS 点名行必须为空」还要求计数行里真的写着 `core 1 只 / extra 1 只`
——放行但采不到 = 空转,这条规矩本项目栽过两次(阶段 12 的 GLYPH、阶段 18 的 TABKBD)。
"""
KIT = ("import { createElement, forwardRef } from 'react'\n"
"export function decorative(Glyph: any, alias: string) {\n"
" const Icon = forwardRef<HTMLSpanElement, any>(function IconDecorative(props: any, ref: any) {\n"
" const { \'aria-hidden\': ah, \'aria-label\': al, ...rest } = props\n"
" const named = typeof al === \'string\' && al.trim() !== \'\'\n"
" return createElement(Glyph, { ...rest, ref, \'aria-label\': named ? al : undefined,\n"
" \'aria-hidden\': named ? (ah ?? false) : (ah ?? true) })\n"
" })\n"
" Icon.displayName = alias\n"
" return Icon\n}\n")
CORE = ("import { PlusOutlined } from \'@ant-design/icons\'\nimport { decorative } from \'./_kit\'\n\n"
"export const IconAdd = decorative(PlusOutlined, \'IconAdd\')\n")
EXTRA = ("import { EditOutlined } from \'@ant-design/icons\'\nimport { decorative } from \'./_kit\'\n\n"
"export const IconEdit = decorative(EditOutlined, \'IconEdit\')\n")
SHELL = ("import { IconAdd } from \'./components/icons\'\n"
"export const App = () => <div>{\'{}\'}</div>\n")
SHELL_BAD = ("import { IconAdd } from \'./components/icons\'\n"
"import { IconEdit } from \'./components/icons/extra\'\n"
"export const App = () => <div>{\'{}\'}</div>\n")
LAZY = ("import { IconEdit } from \'./components/icons/extra\'\n"
"export default () => <div>{\'{}\'}</div>\n")
MAIN = ("import { createRoot } from \'react-dom/client\'\nimport { App } from \'./App\'\n"
"const Lazy = lazy(() => import(\'./pages/Lazy\'))\n"
"createRoot(document.getElementById(\'root\')!).render(<App />)\n")
# 第 9 闸(断点越界)在任何临时树里都天然响 5 下:尺子来自真仓库的 @theme 登记表,
# 而五把登记尺子(insp-lg / board / insp-md / insp-sm / agent)在夹具里没有使用者
# ⇒「登记了却 0 个使用者」。那 5 下会把退出码永久占住(good 也恒 EXIT=1),
# 于是「两级表这一族到底进不进 process.exit」在夹具里根本证明不了。
# 本轮补的正是这个洞,所以顺手给夹具补上五把尺子的使用者——全写在同一个文件里,
# 满足 §4 口径 ①「一把尺子只服务一个表面」。这样 good 的 12 族全 0 且 EXIT=0,
# 三种坏形状只有 `两级表` 非 0 且 EXIT=1:退出码从此只由这一族说了算。
BPFIX = ("export const Bp = () => (\n"
" <div className=\"min-insp-lg:w-full min-board:grid min-insp-md:flex \"\n"
" \"min-insp-sm:hidden min-agent:block\" />\n)\n")
with tempfile.TemporaryDirectory(prefix="nex-gate2c-") as td:
root = pathlib.Path(td)
out = {}
for tag in ("good", "bad-bucket", "bad-shell", "bad-dup"):
d = root / tag / "src"
(d / "components" / "icons").mkdir(parents=True)
(d / "pages").mkdir(parents=True)
(d / "components" / "icons" / "_kit.ts").write_text(KIT, encoding="utf8")
(d / "components" / "icons" / "core.ts").write_text(
CORE + ("export const IconEdit = decorative(EditOutlined, \'IconEdit\')\n"
if tag == "bad-dup" else ""), encoding="utf8")
(d / "components" / "icons" / "extra.ts").write_text(EXTRA, encoding="utf8")
(d / "components" / "icons" / "index.ts").write_text(
"export * from \'./core\'\n"
+ ("export * from \'./extra\'\n" if tag == "bad-bucket" else ""), encoding="utf8")
(d / "App.tsx").write_text(SHELL_BAD if tag == "bad-shell" else SHELL, encoding="utf8")
(d / "pages" / "Lazy.tsx").write_text(LAZY, encoding="utf8")
(d / "Bp.tsx").write_text(BPFIX, encoding="utf8")
(d / "main.tsx").write_text(MAIN, encoding="utf8")
proc = subprocess.run(["node", str(CLASSAUDIT), str(d)],
capture_output=True, text=True, timeout=300)
lines = (proc.stdout or "").splitlines()
keep = [ln for ln in lines
if ln.startswith("ICONS ") or ln.startswith("FAMILY ")
or "处两级表边界问题" in ln or "两级表结构不完整" in ln]
# 闸门自己的退出码也进夹具:FAMILY 行是「采到了」的凭据,EXIT 行是「响了」的凭据
out[tag] = " || ".join(keep + [f"EXIT={proc.returncode}"])
return out
def chunkbudget_static():
"""判据 ㉒(阶段 16 · 任务 3):产物预算闸 `chunkbudget.mjs` 的反向验证。
这一条闸吃的是**构建产物**,页面上种不出反例,所以照 `gate2_static` 的姿势喂临时目录。
七种形状,坏的一面必须逐条点名、好的一面必须静音——尤其这两面:
· 「读到 budget 就按 budget 判」与「没读到 budget 必须喊 DEGRADED」是同一把尺子的两面:
只钉后一面,工具可以永远走兜底;只钉前一面,兜底那条路坏了没人知道。
· DEGRADED 那一腿还要拿一颗 1 501 kB 的文件证明**退化没有放宽判定**
(阶段 12 的 GLYPH「放行但采不到 = 空转」是同一类错误,别再犯第三次)。
阶段 24 加了来源 C(项目登记的 `frontend/chunk-budget.json`)之后,这里多钉三件事,
一条都不能少:① C 真被读到并参与判定(`proj` 那腿按 10 kB 点名);
② C 坏了 / 缺键 / 单位读不出 / 显式指定却找不到 ⇒ 一律响,不许冒充「没有预算」悄悄兜底;
③ 显式 `--config` 的优先级没被 C 污染(`degraded` 那腿现在才是真判据:
项目预算文件就在默认路径上,一旦「显式配置没 budget 也往下兜」,DEGRADED 就不见了);
外加真产物必须报出 C 的文件名、且不再挂 DEGRADED(挂账③ 的销账凭据)。
"""
out = {}
def run(*a):
r = subprocess.run(["node", str(CHUNKBUDGET), *[str(x) for x in a]],
capture_output=True, text=True, timeout=120)
return f"exit={r.returncode} " + (r.stdout or "") + (r.stderr or "")
with tempfile.TemporaryDirectory(prefix="nex-chunkbudget-") as td:
root = pathlib.Path(td)
d = root / "dist" / "assets"
d.mkdir(parents=True)
(root / "dist-empty" / "assets").mkdir(parents=True)
hd = root / "dist-huge" / "assets"
hd.mkdir(parents=True)
(d / "ok.js").write_bytes(b"x" * 2_000) # 任何一条预算都该放过它
(d / "big.js").write_bytes(b"y" * 20_000) # 全局 10 kB 时越界,chunk 档 30 kB 时合法
(d / "big.css").write_bytes(b"z" * 4_000) # asset 档 5 kB 时合法
(hd / "huge.js").write_bytes(b"w" * 1_501_000) # 兜底 1 500 kB 之上 1 kB
(root / "cfg-budget.json").write_text('{"output":{"budget":10000}}', encoding="utf8")
(root / "cfg-scoped.json").write_text(
'{"output":{"budget":[{"type":"asset","name":"assets/big*","maximumSize":5000},'
'{"type":"chunk","maximumSize":30000}]}}', encoding="utf8")
(root / "cfg-nobudget.json").write_text('{"output":{"format":"es"}}', encoding="utf8")
(root / "cfg-broken.json").write_text("{ not json", encoding="utf8")
# 来源 C(阶段 24 · 项目自己登记的预算文件)——五种形状各留一份夹具
(root / "proj-good.json").write_text('{"budget":10000}', encoding="utf8")
(root / "proj-broken.json").write_text("{ not json", encoding="utf8")
(root / "proj-empty.json").write_text('{"_what":"没有 budget 键"}', encoding="utf8")
(root / "proj-shape.json").write_text('{"budget":"1500"}', encoding="utf8")
out["good"] = run("--dist", root / "dist", "--config", root / "cfg-scoped.json")
out["bad"] = run("--dist", root / "dist", "--config", root / "cfg-budget.json")
out["degraded"] = run("--dist", root / "dist", "--config", root / "cfg-nobudget.json")
out["degraded-limit"] = run("--dist", root / "dist-huge")
out["broken"] = run("--dist", root / "dist", "--config", root / "cfg-broken.json")
out["nodist"] = run("--dist", root / "nope")
out["empty"] = run("--dist", root / "dist-empty")
out["proj"] = run("--dist", root / "dist", "--budget-file", root / "proj-good.json")
out["proj-broken"] = run("--dist", root / "dist", "--budget-file", root / "proj-broken.json")
out["proj-missing"] = run("--dist", root / "dist", "--budget-file", root / "nope.json")
out["proj-empty"] = run("--dist", root / "dist", "--budget-file", root / "proj-empty.json")
out["proj-shape"] = run("--dist", root / "dist", "--budget-file", root / "proj-shape.json")
out["real"] = run("--dist", REAL_DIST)
return out
def chunkinfo_static():
"""判据 ㉗(阶段 31 · Bundle 结案时翻自己的案):归属尺 `chunkinfo.mjs` §3
「磁盘对账自证」的反向验证。
为什么要有这一条:阶段 31 把 VLQ 解码器修完之后,给归属读数加了一道自证
(某源归属字节 > 磁盘源文件 × 1.5 ⇒ 点名)。它落地当天就把我们把我们骗了——
把带 map 的产物复制到 `/tmp` 再跑,`sources` 里的 `../../node_modules/…`
全部解析失败,对账覆盖率 **0/1177**,而判定行照样打印
「(无)⇒ 本轮归属读数没有「源文件装不下」的伪像」。
**自证空转比没有自证更危险**:它长得像证据。
(规范基准 = .map 所在目录,产物在项目树内时恰好等价,所以同一把尺在
`frontend/dist-sm` 上是 1177/1177、真在看着东西;移到树外就瞎了还在喊安静。)
三种形状,钉的是「自证必须真的在看」:
· `suspect`:一个 12 B 的真源被记了 401 B ⇒ 必须点名、必须挂 SUSPECT;
· `good`:同一个源只被记 9 B ⇒ 必须静音且必须仍说「没有伪像」
(恒红 = 噪音,这条闸的宿命就是被关掉);
· `idle`:源在磁盘上不存在(模拟产物脱离项目树)⇒ 覆盖率 0 %
必须挂 `ATTRIB_VERDICT=IDLE`、必须**闭嘴**——「没有伪像」那一句一个字节都不许出现。
外加退出码契约:默认恒 0(只读尺,nex.config.yaml 写着),
只有显式 `SOURCE_CHECK_STRICT=1` 才把 IDLE / SUSPECT 升级成退出码 1。
"""
out = {}
def run(dist, strict=False):
env = dict(os.environ)
if strict:
env["SOURCE_CHECK_STRICT"] = "1"
r = subprocess.run(["node", str(CHUNKINFO), str(dist)],
capture_output=True, text=True, timeout=180, env=env)
return f"exit={r.returncode} " + (r.stdout or "") + (r.stderr or "")
def dist_fixture(root, name, gen_len, src_len, src_rel):
"""一份最小可用产物:index.html → assets/a.js(一行 gen_len 字节)+ 它的 map。"""
d = root / name
(d / "assets").mkdir(parents=True)
(d / "src").mkdir(parents=True)
(d / "index.html").write_text('<script type="module" src="/assets/a.js"></script>', encoding="utf8")
(d / "assets" / "a.js").write_text("x" * gen_len, encoding="utf8")
(d / "src" / "tiny.js").write_text("y" * src_len, encoding="utf8")
# mappings="AAAA" = 第 1 行 1 段 [gcol 0, sidx 0, src line 0, col 0]
(d / "assets" / "a.js.map").write_text(json.dumps(
{"version": 3, "file": "a.js", "sources": [src_rel], "names": [], "mappings": "AAAA"}),
encoding="utf8")
return d
with tempfile.TemporaryDirectory(prefix="nex-chunkinfo-") as td:
root = pathlib.Path(td)
sus = dist_fixture(root, "dist-suspect", 400, 12, "../src/tiny.js")
good = dist_fixture(root, "dist-good", 8, 12, "../src/tiny.js")
idle = dist_fixture(root, "dist-idle", 400, 12, "../../ghost/tiny-ghost.js")
out["suspect"] = run(sus)
out["suspect-strict"] = run(sus, True)
out["good"] = run(good)
out["good-strict"] = run(good, True)
out["idle"] = run(idle)
out["idle-strict"] = run(idle, True)
out["real"] = run(REAL_DIST_SM if REAL_DIST_SM.exists() else REAL_DIST)
return out
def main() -> int:
fails = []
with sync_playwright() as pw:
b = pw.chromium.launch()
ctx = b.new_context(viewport={"width": 1440, "height": 1600})
pg = ctx.new_page()
pg.set_default_timeout(20000)
pg.goto(BASE + "/login")
pg.wait_for_selector("#login-user")
pg.fill("#login-user", USER)
pg.fill("#login-pass", PWD)
pg.click("button[type=submit]")
pg.wait_for_url(lambda u: "/login" not in u, timeout=20000)
pg.goto(BASE + "/assets")
pg.wait_for_timeout(1400)
n = pg.evaluate(FIXTURE)
pg.wait_for_timeout(300)
print("fixture nodes:", n)
checks = [
("tagcheck", tagcheck.JS, "el", [("pb-tag", True), ("ant-input", False)]),
# 整句散文当只读标签、捅出容器右缘必须响;换成 kit Tag(max-width+ellipsis 自己收窄)必须放行
("tagcheck.SPILL", tagcheck.SPILL, "el",
[("pb-spill", True), ("pg-spill", False)]),
("rhythmcheck.GAP", rhythmcheck.GAP, "el",
[("pb-gap", True), ("pg-pin", False)]),
("rhythmcheck.RAG", rhythmcheck.RAG, "el",
[("pb-rag", True), ("pg-center", False), ("pg-measure", False)]),
("gridcheck", gridcheck.JS, "el",
[("pb-grid", True), ("pg-chipbar", False),
# 流程条横滚必须响;容器自适应 grid 铺开的流程条必须放行
("pb-rail", True), ("pg-rail", False),
# 同行裸复选框贴着标签行(中心差 35px)必须响;
# 让出标签块、坐进 32px 控件行的必须放行(glue ⑥ 的形态)
("pb-ctl", True), ("pg-ctl", False)]),
# 按钮组被劈成 2+1 必须响;栅格那块(三种宽度三种控件的横排)与胶囊流不是它管的
("btnrowcheck", btnrowcheck.JS, "el",
[("pb-btn", True), ("pb-grid", False), ("pg-chipbar", False)]),
# 唯一那条豁免必须放行;旧那条「父级是 header 的组在 <1024 允许分行」
# 第 17 轮删了,这里钉住它不许悄悄复活:header 里的横排组被劈成 2+1 一样要响
("btnrowcheck.exempt", btnrowcheck.JS, "el",
[("pg-stack", False), ("pb-header", True)]),
# 卡头标题被切成两行(行里还剩着一整块没挪走)必须响;
# 右端整块掉到下一行、标题拿到整行的必须放行——判据②的两面
("btnrowcheck.HEAD", btnrowcheck.HEAD, "el",
[("pb-head", True), ("pg-head", False)]),
# 浮层底部(第 17 轮补):抽屉/对话框吸底那几条按钮以前不在任何闸门的路线表里,
# 现在 Overlay.DRAWER_ACTIONS = ActionGroup,底部由 footercheck 开层量。
# 摊平用函数:只看判据算下来真违规的那几条的类名。
("footercheck", footercheck.JS,
(lambda r: [r["cls"]] if r.get("bad") else []),
[("pb-footer", True), ("pg-footer", False)]),
# 裸按钮簇(第 17 轮续):不带任何 kit 类名的一组按钮被劈成 2+1 必须响;
# 整簇换行、每颗占满内宽必须放行——这把尺子的价值全在「不认类名」,
# 没有这对 fixture,它绿了也证明不了自己在看东西。
("btnclustercheck", btnclustercheck.JS,
(lambda r: [r["cls"]] if r.get("bad") else []),
[("pb-cluster", True), ("pg-cluster", False)]),
# 格子里并排内容越出单元格 / 互相压叠必须响,放得下必须放行。
# 摊平用函数:只看 spill 明细里的元素标识,不看那些本来就没违规的表名。
("tableaudit", tableaudit.PROBE,
lambda r: [it["k"] for it in r.get("spill", [])],
[("pb-tspill", True), ("pg-tspill", False)]),
# 键盘可达(第 8.5 轮补):pointer 热区没 tabindex 必须响;
# 补了 tabindex=0 的自定义控件与原生 button 必须放行——
# 前者钉住阶段 2 的修法不许退化,后者证明这条不是「见 div 就咬」。
# 摊平用函数:hotspots 只带 sig,别的判据返回的形状不一样。
("semanticcheck.HOTSPOT", semanticcheck.COLLECT,
(lambda r: [h["sig"] for h in r.get("hotspots", [])]),
[("pb-sema", True), ("pb-semb", True),
("pg-sema", False), ("pg-semb", False),
("pg-semc", False), ("pg-semd", False),
# antd 的图标根节点连候选都不该进:收进来就等于把 antd 的 DOM 当我们的契约
("pg-simg", False)]),
# 同一个判据的**硬档**单独验一遍:软/硬分档写错(role 非空就算硬)时,
# 上面那条看不出差别——它只比候选清单,而 pg-semf 本来就该在候选里。
("semanticcheck.HOTSPOT-hard", semanticcheck.COLLECT,
(lambda r: [h["sig"] for h in r.get("hotspots", []) if h.get("hard")]),
[("pb-sema", True), ("pb-semb", True),
("pg-sema", False), ("pg-semb", False), ("pg-semc", False),
("pg-semd", False), ("pg-semf", False)]),
# TAB 的输入是「自定义角色元素清单」。两头都要钉:
# 我们写的页签漏了 = TAB 永远查不到它(判据瞎);
# antd 自己的页签混进来 = 每次走位都报它找不到(假阳性,实测每主题 3 条)。
("semanticcheck.TABTARGET", semanticcheck.COLLECT,
(lambda r: [t["sig"] for t in r.get("tabTargets", [])]),
[("pb-semt", True), ("pg-semt", False)]),
# S-2(2026-11-08 起常驻):**外泄清单**只收「宿主没有自己的可读名称」那一种。
# b/c/d 三种形状都必须不出现在这里——b 是名称已被宿主接管(AT 念的是人话),
# c/d 连候选都不该进。放错任何一条,这条判据不是恒绿就是 78 只装饰图标全响。
("semanticcheck.GLYPH", semanticcheck.COLLECT,
(lambda r: [g["host"] + " " + g["tok"]
for g in r.get("glyphs", []) if not g["own"]]),
[("pb-glyph", True), ("pg-glyph", False),
("pg-glyph2", False), ("pg-glyph3", False)]),
# 同一条判据的**采集面**:遮蔽那种(b)必须仍然被采到,否则上一条里
# 「pg-glyph 必须放行」是空转——没采到、和采到但判为遮蔽,串里看不出差别。
("semanticcheck.GLYPH-seen", semanticcheck.COLLECT,
(lambda r: [g["host"] for g in r.get("glyphs", [])]),
[("pb-glyph", True), ("pg-glyph", True),
("pg-glyph2", False), ("pg-glyph3", False)]),
# S-3 根因(2026-11-08 · 阶段 12 起常驻):语言包静默回落 enUS。
# 坏形状三条必须逐条点名(分页 title / 空态文字 / 步进器 aria-label),
# 好形状三条必须放行。阶段 18 把豁免表清空后,步进器那颗英文从「放行」
# 翻成「点名」——豁免写宽一格就会把真缺陷一起放过,这条正是那三格之一。
("semanticcheck.LOCALE", semanticcheck.COLLECT,
(lambda r: semanticcheck.locale_offenders(r.get("builtins", []))),
[("pb-locprev", True), ("pb-locdata", True), ("pb-locnum", True),
("pg-loczh", False), ("pg-loctxt", False), ("pg-locnumzh", False)]),
# 同一条判据的**采集面**:六条夹具必须全部仍然被采到。少了这一条,
# 上面那三个「必须放行」在作用域写错时也会全绿(没采到 ≠ 采到了但判为合法)。
("semanticcheck.LOCALE-seen", semanticcheck.COLLECT,
(lambda r: ["%s %s %s" % (b["kind"], b["sig"], b["v"])
for b in r.get("builtins", [])]),
[("pb-locprev", True), ("pb-locdata", True), ("pb-locnum", True),
("pg-loczh", True), ("pg-loctxt", True), ("pg-locnumzh", True)]),
]
def verdict(label, marker, should_fire, hay):
hit = marker in hay
ok = hit == should_fire
print(f"{'OK ' if ok else 'FAIL'} {label:<22} {marker:<26} "
f"{'必须点名' if should_fire else '必须放行'} "
f"→ {'点名了' if hit else '没点名'}")
if not ok:
fails.append(f"{label}/{marker}")
print(" 实际:", hay[:400])
for label, js, key, expectations in checks:
rows = pg.evaluate(js)
hay = names(rows, key)
for marker, should_fire in expectations:
verdict(label, marker, should_fire, hay)
# ── 判据 ⑲ 的**第二腿**(阶段 10 · S-2 收尾):名称表钉的是字符串,
# 而这条判据真正跑在浏览器里(DOM 采集 5b + CDP AX 树两支)。只测字符串那一层
# 等于自反了 §15.12 立下的规矩——「判据写在哪一层,反例就得造在哪一层」:
# 采集 JS 的正则写坏了(比如整条名称匹配不上 `^[a-z][a-z0-9-]{1,24}$`),
# 名称表那条腿照样全绿。所以在真页面(登录后 /assets)上拿**真按钮**改三种形状:
# 原样必须一个字都不点(点了就是页面缺陷或闸门过敏)、
# `aria-label=ellipsis`(登记表在册字形码)两支都必须点名、
# `aria-label=/api/meta`(正文里那种拉丁词,撞中的是 `api`)必须只打印不点名。
# 前提:先摘掉自家夹具——上面那 17 块 `pb-*` 里就有 `pb-glyph`(只装一颗
# `aria-label=upload` 图标的裸按钮),它本来就是这一族缺陷的坏形状,
# 夹具还挂着就量「真页面原样必须静」,等于自己抓自己:阶段 10 第一跑就是这样红的
# (`必须放行 → 点名了 upload`),这条 FAIL 反过来证明第二腿确实在读名称。
# 摘完必须回到 checks 之前的状态没有意义(后面 ⑱/⑰ 各开各的页面与临时目录),
# 所以在这里摘是安全的;摘不到两个 host 就直接停,别让「静」来自空页面。
cdp = ctx.new_cdp_session(pg)
cdp.send("Accessibility.enable")
def whole_hits():
"""把这条判据的两支各跑一遍,返回「被点名的整条名称」拼串(空串 = 全静)。"""
d = pg.evaluate(semanticcheck.COLLECT)
hits = [c["tok"] for c in d.get("nameOnly", [])
if semanticcheck.whole_glyph_name(c["tok"])]
hits += [n["name"] for n in (semanticcheck.ax_names(cdp) or [])
if semanticcheck.whole_glyph_name(n["name"])]
return "|".join(hits)
gone = pg.evaluate("""() => {
let n = 0;
for (const id of ['nex-gateprobe', 'nex-gateprobe-sem']) {
const el = document.getElementById(id);
if (el) { el.remove(); n++; }
}
const left = document.querySelectorAll('[class^="pb-"],[class*=" pb-"]').length;
return { n, left };
}""")
if gone["n"] != 2:
print("FAIL 摘不掉自家夹具:", gone)
fails.append("semanticcheck.GLYPH-whole-live/夹具没摘干净")
b.close()
print("GATEPROBE_FAIL", " ".join(fails))
return 1
print(" 摘掉自家夹具 2 个 → 剩余 pb-* 节点 %d(应为 0)" % gone["left"])
pg.wait_for_timeout(200)
raw = whole_hits()
if raw:
fails.append("semanticcheck.GLYPH-whole-live/真页面原样")
print("FAIL semanticcheck.GLYPH-whole-live 真页面原样 "
"必须放行 → 点名了:", raw[:300])
else:
print("OK semanticcheck.GLYPH-whole-live 真页面原样 "
"必须放行 → 没点名")
for tok, fire in (("ellipsis", True), # 在册字形码:两支都必须点名
("/api/meta", False)): # 正文里那种拉丁词:只能打印,不许点名
pg.evaluate("""(t) => {
const b = [...document.querySelectorAll('button')]
.find(x => x.offsetWidth > 0 && !x.getAttribute('aria-label'));
if (!b) throw new Error('页面上找不到一颗没写过 aria-label 的可见按钮(夹具前提变了)');
b.setAttribute('aria-label', t); window.__gpBtn = b; return 1;
}""", tok)
pg.wait_for_timeout(200)
hits = whole_hits()
# 「点名」= 两支里任何一支给出了整条名称。好形状要求一支都不给(不是「别的那个词被点名」)
ok = bool(hits) == fire
print(f"{'OK ' if ok else 'FAIL'} semanticcheck.GLYPH-whole-live "
f"aria-label={tok:<12} {'必须点名' if fire else '必须放行'} → "
f"{'点名了 ' + hits[:120] if hits else '没点名'}")
if not ok:
fails.append("semanticcheck.GLYPH-whole-live/" + tok)
pg.evaluate("() => { window.__gpBtn.removeAttribute('aria-label'); return 1 }")
b.close()
# ── 判据 ⑱(TABKBD):不吃 div 夹具,直接开一个 430 的真窗口跑六遍
for marker, expect, hay, stat in tabkbd_negative(pw):
if expect is None:
verdict("semanticcheck.TABKBD-good", "TABKBD", False, hay)
print(" 原样跑通:溢出条带 %d 处 · 被裁 %d 颗 · 纯键盘选中成功 %d 颗"
% (stat["lists"], stat["clipped"], stat["picked"]))
else:
verdict("semanticcheck.TABKBD", expect, True, hay)
# ── 判据 ⑰(不吃页面、不触发 HMR):classaudit 第 2 闸的静态反向验证
# 这条闸读的是一份**源文件**,页面上种不出反例,只能喂临时目录:
# 真登记表必须全程静音(否则它就是恒红),三种绕过 decorative() 的写法必须逐条点名
# (否则「upload 导入脚本」这类字形名外泄可以大摇大摆重新进来)。
shapes = gate2_static()
verdict("classaudit.GATE2-bad", "图标走了 export {UploadOutlined}", True, shapes["bad"])
verdict("classaudit.GATE2-bad", "IconUpload 的出口不是", True, shapes["bad"])
verdict("classaudit.GATE2-bad", "IconChevronDown 的出口不是", True, shapes["bad"])
verdict("classaudit.GATE2-bad", "StarOutlined", True, shapes["bad"])
verdict("classaudit.GATE2-good", "ICON", False, shapes["good"])
# ── 判据 ㉓(阶段 17 · S-2 复扫):classaudit 第 2 条·附二「图标型控件必须报名」。
# 与 ⑰ 同一姿势喂临时目录,但钉的是另一族缺陷:不是「图标自己把英文字形名漏出去」,
# 而是「图标被 decorative() 藏起来之后,那颗控件彻底没有名字」——
# 抽屉 / 模态 / 灯箱里的图标钮占这一族的一半,常驻的浏览器探针量不到(浮层没点开)。
# 所以坏形状三条逐条点名、好形状整片静音、真页面文件也必须静音。
shapes2b = gate2b_static()
verdict("classaudit.GATE2B-bad", "<Button> 只画图标却既无 aria-label 也无 title", True, shapes2b["bad"])
verdict("classaudit.GATE2B-bad", 'aria-label="more"', True, shapes2b["bad"])
verdict("classaudit.GATE2B-bad", "aria-label 是空串", True, shapes2b["bad"])
# 好形状不许连坐:有文字的按钮 / aria-label 在下一行的多行写法 / 注释里那一颗 /
# 带名字的三元换图形,四条都不许出现在点名行里。
for marker in ('aria-label="关闭"', 'aria-label="多行也要认"', '>删除</Button>',
'aria-label="切换"', "export const I", "更多页签"):
verdict("classaudit.GATE2B-good", marker, False, shapes2b["bad"])
# ③(阶段 23):`closeIcon={<IconClose />}` 这种「antd 把 onClick 克隆到图标上」的槽位,
# 闸必须用「没写 aria-label」这句话点名(这句话只有 ③ 的空名分支会打,① ② 都打不出)。
verdict("classaudit.GATE2B-bad", "closeIcon= 里的 <IconClose> 没写 aria-label", True, shapes2b["bad"])
for marker in ('closeIcon={<IconClose aria-label="移除" />}', 'aria-label="清空搜索"',
'closeIcon={myIcon}', 'aria-label="关闭抽屉"'):
verdict("classaudit.GATE2B-goodshape", marker, False, shapes2b["bad"])
verdict("classaudit.GATE2B-goodshape", marker, False, shapes2b["good"])
# 标记必须是「ICNN + 两颗空格」这句**点名行前缀**(classaudit 567/568 两行的打印形状)。
# 阶段 32 第一版这里写的是裸 "ICNN",被新增的 `ICNN-COVER` 覆盖率行撞中,
# 于是「真文件必须静音」这条腿在好面上永远红——红的是探针自己,不是页面(§15.12 ㉓)。
verdict("classaudit.GATE2B-real", "ICNN ", False, shapes2b["good"])
verdict("classaudit.GATE2B-real", "处图标型控件缺自然语言名称", True, shapes2b["good"])
# ④(阶段 32 · S-2 复扫):children 只有图标的图标钮。必须用「children 只有图标」这句原话点名——
# 这句话只有 ④ 会打,① ② ③ 打不出来,钉它才证明这第四支在跑(钉「缺自然语言名称」会撞 ① 的计数行)。
for marker in ("<button> 的 children 只有图标却既无 aria-label 也无 title",
"<Button> 的 children 只有图标却既无 aria-label 也无 title"):
verdict("classaudit.GATE2B-bad", marker, True, shapes2b["bad"])
# 采到证明(§15.1 通则:放行但采不到 = 空转;这条闸自己的覆盖率行就是它的采到凭据):
# · 坏面必须**恰好**数到那两颗(2 采到 / 0 具名 / 2 未命名),少一颗就是采集形状又变了;
# · 好面未命名必须 0,且夹具那三颗具名图标钮必须真被数进去(childIcon≥3 且 named≥3)。
# 颗数只钉下限不钉死:good 目录里还抄了 Overlay.tsx / Storyboard.tsx 两份真文件,
# 它们哪天多一颗具名图标钮是正常的,不该把别人的正常改动变成这条闸的红。
cov_bad = re.search(r"ICNN-COVER childIcon=(\d+) named=(\d+) missing=(\d+)", shapes2b["bad"])
cov_good = re.search(r"ICNN-COVER childIcon=(\d+) named=(\d+) missing=(\d+)", shapes2b["good"])
hay_bad = shapes2b["bad"] if cov_bad and cov_bad.groups() == ("2", "0", "2") else ""
verdict("classaudit.GATE2B-cover-bad", "ICNN-COVER childIcon=2 named=0 missing=2", True, hay_bad)
# verdict() 是 `marker in hay` 的字面子串匹配 ⇒ 标记必须写成**输出里真会长出来的那半句话**。
# 阶段 32 第一版把「childIcon>=3 且 named>=3 且 missing=0」这句**口径说明**当成标记,
# 它永远不可能出现在 classaudit 的输出里,于是好面越健康这条腿越必红。
# 现在钉的是覆盖率行本身(实测 `ICNN-COVER childIcon=3 named=3 missing=0`):
# 行在且达到下限 → 点名;行在但没达到下限 → hay 置空,判 FAIL(不是放宽);
# 整行缺失(采集形状又变了)→ 标记退化成「ICNN-COVER 行缺失」,仍在 hay 里找不到 → FAIL。
good_line = cov_good.group(0) if cov_good else "ICNN-COVER 行缺失(④ 没采到任何图标钮)"
hay_good = (shapes2b["good"] if cov_good
and int(cov_good.group(1)) >= 3 and int(cov_good.group(2)) >= 3
and int(cov_good.group(3)) == 0 else "")
verdict("classaudit.GATE2B-cover-good", good_line, True, hay_good)
# ── 判据 ㉖(阶段 25 · Bundle):classaudit 第 2 条·附三「两级表边界」。
# 拆表换来的是实测的首屏收益,而两条回退路径(桶 re-export extra / 外壳深 import extra)
# tsc 与页面都看不出来 ⇒ 这一族的反例只能在源码层喂临时目录。
shapes2c = split_static()
verdict("classaudit.GATE2C-bucket", "桶 re-export 了 ./extra", True, shapes2c["bad-bucket"])
verdict("classaudit.GATE2C-shell", "在**首屏静态闭包**里引用 icons/extra", True, shapes2c["bad-shell"])
verdict("classaudit.GATE2C-dup", "同时在 core.ts 与 extra.ts", True, shapes2c["bad-dup"])
# good 那一面:三条点名都必须没有,但计数行必须真的数到 1 只 / 1 只(采到了才叫放过)。
# ⚠ 标记必须是**违规行原话**,不能截取其中一段裸词:计数行是恒打印的测量值,
# 里面天然写着「首屏静态闭包 N 个模块」,拿「首屏静态闭包」当放行标记必然自己撞自己。
# ㉖ 落地当天真响过一次(GATEPROBE_FAIL classaudit.GATE2C-good/首屏静态闭包,
# 闸门与产物都没错,错在探针的字符串太宽);同一条教训见 ㉔ 的注释。
for marker in ("桶 re-export 了 ./extra", "在**首屏静态闭包**里引用 icons/extra",
"同时在 core.ts 与 extra.ts 里登记"):
verdict("classaudit.GATE2C-good", marker, False, shapes2c["good"])
# ── 退出码接线(本轮补的洞):附三刚落地时只 print、不进 process.exit,
# 真仓库里有人把收益改回去时,日志写着「1 处两级表边界问题」、链子上仍是 CLASSAUDIT=0。
# 现在族的名单与退出码同源(classaudit 末尾的 FAMILIES 表 → FAMILY 行 → 同一个 reduce)。
# ⚠ 只钉 FAMILY 行证明的是「采到了」,不是「响了」。这一版断言刚写下时钉的是
# 「坏形状 EXIT=1」,可那个 1 是被第 9 闸白占住的(夹具里没有断点使用者)——
# 把两级表从退出码里摘掉,断言照样绿,正是这条闸自己要说的那种空转。
# 夹具补上五把登记尺子的使用者之后:good = 12 族全 0 且 EXIT=0、
# 坏形状 = 只有两级表非 0 且 EXIT=1,退出码成了这一族的单变量函数。
for tag in ("good", "bad-bucket", "bad-shell", "bad-dup"):
verdict(f"classaudit.GATE2C-ledger-{tag}", "FAMILY ", True, shapes2c[tag])
verdict("classaudit.GATE2C-good", "两级表=0", True, shapes2c["good"])
verdict("classaudit.GATE2C-good", "断点越界=0", True, shapes2c["good"])
verdict("classaudit.GATE2C-good-exit", "EXIT=0", True, shapes2c["good"])
for tag in ("bad-bucket", "bad-shell", "bad-dup"):
verdict(f"classaudit.GATE2C-{tag}", "两级表=0", False, shapes2c[tag])
for tag in ("bad-bucket", "bad-shell", "bad-dup"):
verdict(f"classaudit.GATE2C-{tag}-exit", "EXIT=1", True, shapes2c[tag])
verdict("classaudit.GATE2C-seen", "core 1 只 / extra 1 只", True, shapes2c["good"])
# 真产物必须静音(恒红 = 噪音),且必须报得出真实的两级表读数
verdict("classaudit.GATE2C-real", "ICONS ", False, shapes2c["good"])
# ── 判据 ㉔(阶段 23 · S-2 收口):`semanticcheck` GLYPH **第四支** `ax_graphic_zh_defect`
# 的反向验证。这一支的输入是两个字符串(AX 算完的整条名称 + 那颗图形的 outerHTML),
# 在页面上种不出一颗「AT 看得见、名字是英文字形码」的真图形——种出来就是恒真,
# 所以照 ⑲ / ⑳ 的姿势直接喂形状表。五坏五好,好形状钉的是这条闸最容易写宽的三个地方:
# · 「名字含汉字」不是「名字撞中字形名单」——`移除` / `清空搜索` 必须是好形状;
# · 「只管 anticon」——素材封面那颗 `<img alt="Chart">` 与自绘的 `.nex-brief-mark`
# 名字里全是英文,那是**内容**不是控件属性,立案就是假阳性(下场是这条闸被关掉);
# · 名称为空的图形归 NAME / C 支,这一支不许重复立案。
# ⚠ 阶段 17 的教训同样适用:标记用行 id(`b-up` / `g-nonanticon`),**不用名称本身**
# ——`up` 既是坏形状的名字,也可能出现在别的名字里,裸子串匹配会自己撞自己。
GLYPH5C = [
("b-up", "up", '<span role="img" aria-label="up" class="anticon anticon-up">'),
("b-down", "down", '<span role="img" aria-label="down" class="anticon anticon-down">'),
("b-left", "left", '<span role="img" aria-label="left" class="anticon anticon-left">'),
("b-right", "right", '<span role="img" aria-label="right" class="anticon anticon-right">'),
("b-closecircle", "close-circle", '<span role="img" aria-label="close-circle" class="anticon anticon-close-circle">'),
("g-zh-remove", "移除", '<span role="img" aria-label="移除" class="anticon anticon-close ant-tag-close-icon">'),
("g-zh-clear", "清空搜索", '<span role="img" aria-label="清空搜索" class="anticon anticon-close-circle">'),
("g-nonanticon", "Chart", '<img alt="Chart" src="/api/meta.png">'),
("g-mark", "PrevPageGlyph", '<span class="nex-brief-mark">'),
("g-empty", "", '<span role="img" aria-label="up" class="anticon anticon-up">'),
]
fired5c = "||".join("%s|%s" % (mid, semanticcheck.ax_graphic_zh_defect(nm, html))
for mid, nm, html in GLYPH5C if semanticcheck.ax_graphic_zh_defect(nm, html))
for mid, _, _ in GLYPH5C:
verdict("semanticcheck.GLYPH-5c", mid, mid.startswith("b-"), fired5c)
# ── 判据 ㉙(阶段 34 · 2026-11-10 · S-2 宿主级收口):`semanticcheck` GLYPH **第五支**
# `nameless_icon_host` 的反向验证。这一支的输入只有「名称已经为空的宿主 outerHTML」,
# 判的是「里面还有没有图标」这一层——在页面上种一颗「AT 看得见、整条名称为空、
# 里面只有图标」的真控件等于自己喂自己(种下去名字就没了/或者恒真),
# 所以照 ㉔ / ⑲ 的姿势直接喂形状表。七坏五好,好形状钉的是这条闸最容易写宽的几处:
# · 真 `<img>` 的 alt 与自绘圆点是**内容**,不是图标控件属性(与 5c 同一把尺子);
# · `<input type=file>` 的名称是浏览器自带文案(Choose File),与图标无关,
# 不在这一支立案;它自己的名字归阶段 35 的 FILE 闸(判据 ㉚)。
# 2026-11-10 之前这条口径写的是「归英文宿主名一族在册豁免」,S-3 修好后
# 真页面上原生英文已经读不到了,豁免的说法随之作废;
# · 纯文字按钮 / 只有 SVG 文本的按钮:名称为空是 NAME 闸的活,不许重复立案。
# 坏形状里 `anticon-loading` 是**加载态**那颗:类名带 anticon 却没有名字,
# 读屏同样什么都念不到 ⇒ 立案是对的,不是假阳性(这条刻意钉成坏形状)。
GLYPH5D = [
("b-upload", '<button class="ant-btn ant-btn-text"><span class="anticon anticon-upload" aria-hidden="true"><svg data-icon="upload"></svg></span></button>'),
("b-eye", '<span role="button" tabindex="0" class="ant-input-password-icon"><span class="anticon anticon-eye-invisible" aria-hidden="true"></span></span>'),
("b-previewclose", '<button class="ant-image-preview-close"><span class="anticon anticon-close" aria-hidden="true"></span></button>'),
("b-selectclear", '<span class="ant-select-clear"><span class="anticon anticon-close-circle" aria-hidden="true"></span></span>'),
("b-stepup", '<span class="ant-input-number-handler-up"><span class="anticon anticon-up"><svg data-icon="up"></svg></span></span>'),
("b-combobox", '<div class="ant-select ant-select-single" role="combobox" tabindex="0"><span class="ant-select-arrow"><span class="anticon anticon-down" aria-hidden="true"></span></span></div>'),
("b-loading", '<button class="ant-btn"><span class="anticon-loading anticon-spin"></span></button>'),
("g-text", '<button class="ant-btn"><span>导入脚本</span></button>'),
("g-fileinput", '<input type="file" class="nex-file-input">'),
("g-cover", '<div class="nex-cover"><img alt="Chart" src="/api/meta.png"></div>'),
("g-dot", '<button class="ant-btn"><i class="nex-dot"></i></button>'),
("g-svgtext", '<button class="ant-btn"><svg viewBox="0 0 16 16"><text>OK</text></svg></button>'),
]
fired5d = "||".join("%s|%s" % (mid, semanticcheck.nameless_icon_host(html))
for mid, html in GLYPH5D if semanticcheck.nameless_icon_host(html))
for mid, _ in GLYPH5D:
verdict("semanticcheck.GLYPH-5d", mid, mid.startswith("b-"), fired5d)
# ── 判据 ㉚(阶段 35 · 2026-11-10 · S-3):`semanticcheck` **FILE** 那一支。
# 症状不是「图标」也不是「antd 语言包回落」,而是**浏览器原生控件文案**渗进
# 辅助技术名称:`<input type=file>` 的 `Choose File` / `No file chosen` 活在影子 DOM 里,
# DOM 侧一条属性都读不到,所以 LOCALE 那把尺子量不到它,GLYPH 那五支也与它无关。
# 页面上种夹具只能种真组件渲染出来的形状(FilePick 一旦改名整族一起改,
# 种不出「只坏一颗」的对照),所以照 ⑲ / ㉙ 的姿势直接喂名称表:
# · 坏形状必须点名:没有 aria-label(原生英文 inevitable)、纯英文 aria-label
# (把原生文案抄进名字里,读屏照样念英文);
# · 好形状必须放行:中文名称、以及「动作 + 选择文件」这种带上下文的长名
# ——按「含汉字」判,不按英文名单判,换宿主语言也不空转。
FILE_NAMES = [
("b-empty", ""),
("b-blank", " "),
("b-native", "Choose File"),
("b-nativefull", "No file chosen"),
("g-zh", "选择文件"),
("g-zh-ctx", "定妆图,选择文件"),
("g-zh-mix", "上传 v2 参考图"),
]
firedFile = "||".join("%s|%s" % (mid, semanticcheck.file_name_defect(nm))
for mid, nm in FILE_NAMES if semanticcheck.file_name_defect(nm))
for mid, _ in FILE_NAMES:
verdict("semanticcheck.FILE", mid, mid.startswith("b-"), firedFile)
# ── 判据 ⑲(semanticcheck.GLYPH 的「整条名称=字形码」那一支 · 阶段 10 · S-2 收尾):
# 这一支的全部逻辑就是一个字符串函数(DOM 侧与 AX 侧共用 `whole_glyph_name`),
# 页面上种不出一颗「名称正好是字形码」的控件——种出来就是恒真(我们自己喂的名字),
# 所以直接喂名称表。两头都要钉:
# · 认不出坏形状 = 这条判据恒绿,`ellipsis` 那种「读屏只念一个英文单词」能重新进来;
# · 把好名称也认成字形码 = 假阳性,下场是这条闸被以噪音为由关掉。
# `/api/meta`(撞中 api)与 `upload 导入脚本`(归 DOM 侧那条管)就是现成的两个陷阱。
WHOLE_IN = ["upload", "down", "ellipsis", "api", " close "]
WHOLE_OUT = ["upload 导入脚本", "导入脚本", "更多页签", "/api/meta", "Esc", "OK", "全部展开", "导出"]
fired = "|".join(n for n in WHOLE_IN + WHOLE_OUT if semanticcheck.whole_glyph_name(n))
for n in WHOLE_IN:
verdict("semanticcheck.GLYPH-whole", n.strip(), True, fired)
for n in WHOLE_OUT:
verdict("semanticcheck.GLYPH-whole-out", n, False, fired)
# ── 判据 ㉒(阶段 16 · 任务 3 · chunkbudget):产物预算闸的静态反向验证。
# 编号说明:⑰ classaudit 第 2 闸、⑲ 整名(含浏览器第二腿)、⑱ TABKBD、⑳ LOCALE 都在上面;
# 这一条不占上面那 18 条页面判据里的任何一格,是**新增的一条判据**,末行计数随之 +1
# (计数式 `len(checks) + 6`:⑰/⑱/⑲静态/⑳/㉑/㉒/㉓/㉔ 里的离线支……
# 简言之 18 条页面 + 6 条离线 = 24,阶段 23 起)。
#
# ⚠ 阶段 17 的教训(判据 ㉒ 第一次跑红就是这个原因,别再犯):`verdict` 是**裸子串匹配**,
# 所以标记必须钉在闸的**结构化字段**上,不能钉在它自己的解释散文里。
# 原来这两腿写的是裸 `DEGRADED`:坏配置那条路(CONFIG-BAD)本应「不许冒充退化」而放行,
# 可闸在 `预算来源` 那行和 die() 提示里各有一句**散文**写着「不冒充 DEGRADED」
# 「不许混成 DEGRADED 用兜底蒙过去」——字面量撞中,好形状被误判成误报,
# 表现是 `chunkbudget.broken DEGRADED 必须放行 → 点名了`。
# 修法是把两腿一起钉到字段前缀 `预算来源 : ` 上(退化 = `预算来源 : DEGRADED —— …`,
# 坏配置 = `预算来源 : 不可信 —— …`),判定语义一条都没放宽,散文想怎么写怎么写。
cb = chunkbudget_static()
verdict("chunkbudget.bad", "OVER assets/big.js", True, cb["bad"]) # 越界必须点名
verdict("chunkbudget.bad", "OVER assets/ok.js", False, cb["bad"]) # 没越界的不许连坐(明细表里它本来就在)
verdict("chunkbudget.good", "OVER", False, cb["good"]) # 作用域 budget 命中时必须放过
verdict("chunkbudget.good", "output.budget = 5000", True, cb["good"]) # 且必须说清上限是从配置读的
verdict("chunkbudget.degraded", "预算来源 : DEGRADED", True, cb["degraded"]) # 没 budget 必须自报退化(钉字段,不钉散文)
verdict("chunkbudget.degraded", "OVER", False, cb["degraded"]) # 兜底之下小文件仍要放过
verdict("chunkbudget.degraded-limit", "OVER assets/huge.js", True, cb["degraded-limit"]) # 退化≠放宽
verdict("chunkbudget.broken", "CONFIG-BAD", True, cb["broken"]) # 配置坏了要响
verdict("chunkbudget.broken", "预算来源 : DEGRADED", False, cb["broken"]) # 且不许冒充「没有 budget」——阶段 17 锚定,见上方 ⚠
verdict("chunkbudget.nodist", "NO-DIST", True, cb["nodist"]) # 没构建等于没量
verdict("chunkbudget.empty", "EMPTY", True, cb["empty"]) # 空产物不许算过
verdict("chunkbudget-real", "OVER", False, cb["real"]) # 真产物必须静音(恒红=噪音)
verdict("chunkbudget-real", "CHUNKBUDGET OK", True, cb["real"])
# ↓ 来源 C(阶段 24):登记文件必须真的被读到、真的参与判定、坏了真的会响
verdict("chunkbudget.proj", "OVER assets/big.js", True, cb["proj"]) # 10 kB 预算下必须越界
verdict("chunkbudget.proj", "proj-good.json · budget = 10000 B=10.00 kB", True, cb["proj"]) # 来源行必须点名登记文件(钉字段)
verdict("chunkbudget.proj", "预算来源 : DEGRADED", False, cb["proj"]) # 读到登记值就不许再挂退化
verdict("chunkbudget.proj-broken", "BUDGET-FILE-BAD", True, cb["proj-broken"]) # 登记文件坏了要响
verdict("chunkbudget.proj-broken", "预算来源 : DEGRADED", False, cb["proj-broken"]) # 不许冒充「没有预算」
verdict("chunkbudget.proj-missing", "BUDGET-FILE-MISSING", True, cb["proj-missing"]) # 显式指定却找不到 = 错,不是退化
verdict("chunkbudget.proj-empty", "BUDGET-FILE-EMPTY", True, cb["proj-empty"]) # 文件在而没 budget 键 = 没有预算,必须响
verdict("chunkbudget.proj-shape", "BUDGET-FILE-SHAPE", True, cb["proj-shape"]) # 原值读不出正数 = 不猜单位,必须响
verdict("chunkbudget-real", "chunk-budget.json · budget", True, cb["real"]) # 真产物走来源 C(挂账③ 销账)
verdict("chunkbudget-real", "预算来源 : DEGRADED", False, cb["real"]) # 且不再退化到脚本常数
# ── 判据 ㉗(阶段 31 · Bundle 结案):归属尺的「磁盘对账自证」必须真的在看东西。
# 全部钉在尺子的机器可读行(`ATTRIB_*`)与判定语上,不钉散文(阶段 17 的教训)。
ci = chunkinfo_static()
verdict("chunkinfo.suspect", "ATTRIB_SUSPECT=1", True, ci["suspect"]) # 12 B 源被记 401 B 必须点名
verdict("chunkinfo.suspect", "ATTRIB_VERDICT=SUSPECT", True, ci["suspect"])
verdict("chunkinfo.suspect", "ATTRIB_COVERAGE=1/1 (100.0%)", True, ci["suspect"]) # 覆盖率本身要能读出来
verdict("chunkinfo.suspect-strict", "exit=1", True, ci["suspect-strict"]) # 显式 strict 才升级退出码
verdict("chunkinfo.good", "ATTRIB_SUSPECT=0", True, ci["good"])
verdict("chunkinfo.good", "没有「源文件装不下」的伪像", True, ci["good"]) # 好形状必须仍敢下结论
verdict("chunkinfo.good", "ATTRIB_VERDICT=SUSPECT", False, ci["good"])
verdict("chunkinfo.good-strict", "exit=0", True, ci["good-strict"])
# ↓ 这一组才是本轮翻案的正主:覆盖率塌了必须自称空转,不许冒充「没有伪像」
verdict("chunkinfo.idle", "ATTRIB_VERDICT=IDLE", True, ci["idle"])
verdict("chunkinfo.idle", "ATTRIB_COVERAGE=0/1", True, ci["idle"])
verdict("chunkinfo.idle", "没有「源文件装不下」的伪像", False, ci["idle"])
verdict("chunkinfo.idle", "本条自证空转", True, ci["idle"])
verdict("chunkinfo.idle-strict", "exit=1", True, ci["idle-strict"])
verdict("chunkinfo.real-idle", "ATTRIB_VERDICT=IDLE", False, ci["real"]) # 真产物不许空转
verdict("chunkinfo.real-idle", "本条自证空转", False, ci["real"])
# ── 判据 ㉘(阶段 33 · 第 14 道常驻探针 `projectswitchcheck`):
# 这条闸门的三条判据全部站在同一个探测器 `matches()` 上——它要退化成长驻 True
# (把上一个项目的残留判成正常)或恒 False(三条判据一起空转,页面怎么改都绿),
# 常驻探针就只剩「跑了一遍」这个外观。探测器是纯函数,喂合成读数即可,
# 不吃页面、不吃数据库,因此两头都能钉死:命中面必须命中、不命中面必须不命中。
ps_ok, ps_line = projectswitchcheck.selftest()
verdict("projectswitchcheck.matches", "SELFTEST OK", True, ps_line)
verdict("projectswitchcheck.matches", "SELFTEST FAIL", False, ps_line)
print(f" 探测器自证 9 例(命中/不命中/骨架/半挂载/整行多余列/空指纹/状态变了)→ {ps_line}")
if fails:
print("GATEPROBE_FAIL", " ".join(fails))
print("→ 闸门本身出问题:不是漏检(豁免写宽了)就是误报(豁免没生效),先修闸门")
return 1
print(f"GATEPROBE_OK {len(checks) + 11}/{len(checks) + 11} 闸门坏了会响、好了不响")
return 0
if __name__ == "__main__":
sys.exit(main())