Skip to content

门禁: 完成 ZCE-7 注释治理、D26–D28 归档与借口注释静态检查 - #19

Merged
KyoMio merged 3 commits into
mainfrom
chore/zce7-comment-governance
Nov 28, 2026
Merged

KyoMio merged 3 commits into
mainfrom
chore/zce7-comment-governance

Conversation

@KyoMio

@KyoMio KyoMio commented Nov 28, 2026

Copy link
Copy Markdown
Owner

目标与背景

完成 ZCE-7 注释治理,清理 lib/ 与 dsh-plugin/src/ 中旧项目对比(coder-mcp-bridge / 非版权 zcode-acp)、内部评审流水号与源码 权宜 注释,保留 Apache-2.0 版权声明与协议字段映射注记。

主要改动

  • docs/decisions.md 新增 D26–D28 归档运行期、闲时配额与 DSH/观察面板边界;更新 docs/RULES.md 第 4 节。
  • scripts/check-boundaries.mjs 新增词法级借口注释检查(检查 5)与 test/check-boundaries.test.mjs(4 条回归单测)。
  • 清理 lib/(45 文件)与 dsh-plugin/src/(15 文件)注释并重建 dsh-plugin/lib/(29 文件);TypeScript 6.0.3 removeComments: true 验证 60/60 源文件零非注释 AST 差异。

验证

  • npm test:900/900 通过,sync-doc-version --check 通过,5 项 check-boundaries 全部通过。
  • npm run verify:7 个目标文件 checkJs 零错误。
  • cd dsh-plugin && npm run verify && npm run build && node --test test:112/112 通过,只读 Neon 复验 PASS。

清理 lib/ 与 dsh-plugin/src/ 中过渡期旧项目对比、内部评审流水号与源码 权宜 注释,避免过时注解误导维护;将真实协议、运行期、闲时配额与 DSH 面板边界取舍统一归档至 docs/decisions.md(D26–D28)并更新 docs/RULES.md;在 scripts/check-boundaries.mjs 增加词法级借口注释检查(检查 5)与回归单测 test/check-boundaries.test.mjs,把规范沉淀为提交门禁;同步重建 dsh-plugin/lib/。全量业务代码去注释 AST 零变化。
The static excuse-comment check scanned TSX pages as plain JavaScript:
an apostrophe in JSX text opened a phantom string that swallowed the rest
of the file (real comments in later braces were missed), and // inside a
bare URL in JSX text was read as a comment opener (legal copy failed the
gate). Both directions were stable repros, no timing involved.

The lexer now tracks jsxtext/jsxtag regions: apostrophes and URLs in JSX
text are copy, only comments inside {} code regions are extracted. Tag
detection is heuristic (whitespace/bracket/keyword-preceded '<' followed
by a letter or '>') — generics like useState<string> and comparisons stay
code. Element depth is balanced across open/close/self-close so trailing
code after a closed element is scanned as code again.

Regression: auditor's eight positive/negative cases all pass (mismatches=0);
two repo test cases added (JSX copy with bare TODO URL exits 0, real TODO
comment inside braces exits 1); existing four gate cases stay green.
The R1 lexer only popped a jsxtext layer when the global element depth
returned to zero, so nested elements never released their inner text
state: everything after a nested close was scanned as JSX copy and real
comments went unreported (nested elements, nested fragments, conditional
children, and the production panel with a trailing TODO all slipped
through — exit 0 where the gate should have failed). Root cause of the
missed pops: the '/' of a closing tag was also consumed by the self-close
handler, double-decrementing the depth in the original design.

Closing tags now open in a dedicated jsxclosetag mode: each close pops
exactly its own text layer and restores the parent state — parent JSX
text when nested, the surrounding code expression at the outermost
close. Self-closing tags still open no text layer and leave the parent
untouched.

Regression: auditor's 12 edge cases all pass (mismatches=0, panel copy
now hits line 267), the original 8 positive/negative cases stay green,
two nested-JSX cases added to the repo gate tests (6->7); full npm test
903/903.
@KyoMio
KyoMio merged commit f31ebd5 into main Nov 28, 2026
3 checks passed
@KyoMio
KyoMio deleted the chore/zce7-comment-governance branch November 28, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant