From 34e72208671ba17b2306b708a52d1da9d48a751b Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 7 Aug 2026 04:42:11 +0000 Subject: [PATCH] =?UTF-8?q?docs(ci):=20=E6=8E=A7=E5=88=B6=E5=AD=97?= =?UTF-8?q?=E8=8A=82=E9=9B=86=E5=90=88=E7=9A=84=E6=9C=80=E5=90=8E=E4=B8=A4?= =?UTF-8?q?=E5=A4=84=E6=95=A3=E6=96=87=E6=89=8B=E6=8A=84=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E9=97=A8=E7=A6=81=E8=84=9A=E6=9C=AC=E5=A4=B4?= =?UTF-8?q?=20(#5681)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cite-the-header 族(#5579 → #5646)收口。同一批扫描字节此前有两类写法:可粘贴的 PCRE 字符类已被 #5646 的 `--self-test` 锁住(与 `IS_SCANNED` 表派生结果逐字节相等, 漂移即红),而散文枚举同一批字节的两处仍是人肉同步 —— 本次把这两处改成引用。 1. `.github/workflows/lint.yml`「Raw control-byte guard」步骤注释:删掉逐字节枚举 (0x00-0x08 / 0x0b / 0x0c / 0x0e-0x1f / 0x7f)与三条危害论证的复述,改为引用 `scripts/check-nul-bytes.mjs` 头部 + 一句话摘要。按分诊口径,CI 注释的读者常只在 网页上看 workflow 文件、不会跳读脚本,所以是「引用 + 一句话摘要」而非纯引用; 步骤名与「作者应写转义而不是字节」这句 actionable 结论原样保留。 2. `scripts/check-nul-bytes.mjs` 头部开篇行:同样删掉逐字节枚举,改为指向下方 `IS_SCANNED` 表(权威声明)与 `scannedCharClass()`(派生而非抄写)。 顺带修正 `CHAR_CLASS_REFERENCES` 台账里描述这两处的措辞 —— 它原本称它们为 「prose ENUMERATIONS」,本次改动后两处都不再枚举,不改则该注释自身失真。 纯注释改动,零行为变更:`git diff` 中每一行改动都是注释行(YAML `#` / JS `//` 与 `*`),步骤的 `run: pnpm check:nul-bytes` 与全部可执行代码行未动。#5646 锁住的 「Equivalently」锚点行与其下的字符类行逐字节未动,`--self-test` 断言数 56 → 56 全绿。 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01BDmDsu2575gDxeMCxXhDE3 --- .github/workflows/lint.yml | 33 ++++++++++----------------------- scripts/check-nul-bytes.mjs | 20 ++++++++++++-------- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 42e74daabb..ad05614c18 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -95,29 +95,16 @@ jobs: run: pnpm check:query-options-erasure # Raw control-byte guard (#3127 / #4890 / #5157 / #5460). Scans every - # tracked TEXT file for a raw ASCII control byte — 0x00-0x08, 0x0b, 0x0c, - # 0x0e-0x1f and 0x7f, i.e. everything except tab/LF/CR. Two distinct - # harms, one gate: - # • A literal U+0000 makes grep/ripgrep treat the whole file as binary and - # silently return ZERO matches — the file drops out of code search and - # out of every grep-based lint, with no error saying so. Nothing else - # catches it: git sniffs only the first 8000 bytes to decide binary-ness, - # and protocol.ts carried its NUL at offset 147230, so it kept diffing as - # ordinary text through review. That blind spot let six files accumulate - # the same defect. - # • The other C0 controls still match in grep but RENDER AS NOTHING, so a - # load-bearing separator reads as an empty string in the diff and in - # review: `keyParts.join('<0x01>')` shows up as `keyParts.join('')`. - # Four tracked source files carried those past the NUL-only gate until - # #5157 widened the scan surface; PR #5140 is the case that found it, - # when a 0x01 sitting 14 bytes from a caught NUL went unfixed. - # • DEL (0x7f) is in the set for the same reason, added by #5460. It is - # not a C0 control — it sits alone past the printable range — so the - # C0-shaped set could not reach it, and two raw specimens survived in - # the CLI's password prompts nine lines below a 0x03 #5157 had just - # escaped, reading as `case ''`. The set is drawn by the accident - # source (a tool materialising an escape into its byte), and that - # source does not pick byte values. + # tracked TEXT file for a raw ASCII control byte and fails on any hit. + # WHICH bytes are in the set and WHY each is rejected are stated and argued + # once, in the gate script's header — `scripts/check-nul-bytes.mjs`. That + # header is authoritative and this comment cites it rather than restating it + # (#5579 established the footing, #5681 applied it here). The one-line + # summary, for whoever is reading this because the step just went red: the + # set is every ASCII control character except tab/LF/CR, drawn by the + # ACCIDENT SOURCE — an editing tool materialising an escape into its byte — + # and not by byte semantics, so "mine is not a NUL" is never a reason to read + # a hit as a false positive. # The command name stays `check:nul-bytes` for continuity — see the script's # header for why. Authors must write the unicode escape instead of the byte. - name: Raw control-byte guard diff --git a/scripts/check-nul-bytes.mjs b/scripts/check-nul-bytes.mjs index b527e8eb16..832a521bdb 100644 --- a/scripts/check-nul-bytes.mjs +++ b/scripts/check-nul-bytes.mjs @@ -3,9 +3,12 @@ // // check-nul-bytes -- rejects raw ASCII control bytes in every tracked TEXT file. // -// Scanned set (#5157, #5460): 0x00-0x08, 0x0b, 0x0c, 0x0e-0x1f and 0x7f -- every -// ASCII control character except the three bytes that ARE ordinary text -// structure: tab (0x09), LF (0x0a), CR (0x0d). Equivalently +// Scanned set (#5157, #5460): every ASCII control character except the three that +// ARE ordinary text structure -- tab, LF, CR. The `IS_SCANNED` table below is the +// authoritative statement of which bytes those are; this line deliberately no +// longer transcribes the list (#5681), and the pasteable class on the next line is +// DERIVED from that table rather than copied (see "The character class is written +// down once" below). Equivalently // `[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]`. // // #5157 drew that set as "C0 minus tab/LF/CR", matching the pattern #4890's own @@ -290,11 +293,12 @@ export function scannedCharClass() { * Those are HISTORICAL RECORDS of one widening each, and one of them states * the pre-DEL set correctly for the change it describes. Forcing them to * equal today's set would falsify the record. - * - The prose ENUMERATIONS of the same bytes -- this header's opening line and - * the `.github/workflows/lint.yml` step comment. Those are sentences, not - * pasteable classes; prose stays on the #5579 footing -- cite this header, - * do not restate it. (Which is why this list names them rather than quoting - * them: a ledger entry that spelled the bytes out would be one more copy.) + * - The prose STATEMENTS of the same set -- this header's opening line and the + * `.github/workflows/lint.yml` step comment. Those are sentences, not + * pasteable classes; prose stays on the #5579 footing -- cite this header, do + * not restate it -- and as of #5681 neither of them enumerates the bytes any + * more. (Which is why this list names them rather than quoting them: a ledger + * entry that spelled the bytes out would be one more copy.) * - The non-ASCII guard `[^\x00-\x7f]` quoted in the isLikelyEmail changeset * and the plugin-auth CHANGELOG: a different regex about input validation, * unrelated to this set.