Skip to content

Commit 4e6e763

Browse files
committed
feat: 接入 Erlang 原生语法优先并纠正隐藏错误精度统计
1 parent 865f0ee commit 4e6e763

29 files changed

Lines changed: 1591 additions & 30 deletions

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ jobs:
3939
- name: Verify Linux WASM worker resource boundary
4040
run: |
4141
cargo test -p codeguard-runtime --features wasm-precheck --test process_contract
42-
cargo test -p codeguard-runtime --features wasm-precheck --test wasm_grammar_load --test dart_upstream_corpus
43-
cargo test -p codeguard-cli --features wasm-precheck --test syntax_worker_candidate --test grammar_probe_cli --test grammar_route --test zig_lint_cli --test typescript_syntax_fallback_candidate --test java_syntax_fallback_candidate --test java_native_differential --test kotlin_native_differential --test erlang_native_differential --test check_all_eslint --test hook_execute_cli --test claude_hook_cli --test hook_syntax_tasks --test syntax_task_verify --test zig_native_cli --test task_resolution_service
42+
cargo test -p codeguard-runtime --features wasm-precheck --test wasm_grammar_load --test wasm_recovery_scan --test dart_upstream_corpus
43+
cargo test -p codeguard-cli --features wasm-precheck --test syntax_worker_candidate --test grammar_probe_cli --test grammar_route --test zig_lint_cli --test typescript_syntax_fallback_candidate --test java_syntax_fallback_candidate --test java_native_differential --test kotlin_native_differential --test erlang_native_differential --test erlang_lint_cli --test swift_native_differential --test check_all_eslint --test hook_execute_cli --test claude_hook_cli --test hook_syntax_tasks --test syntax_task_verify --test zig_native_cli --test task_resolution_service
4444
# 32 份 WASM 的批次和单项目回归各自独占候选阶段预算,避免测试进程互相争抢内存与 CPU。
4545
cargo test -p codeguard-cli --features wasm-precheck --test check_all_grammar_candidates -- --test-threads=1
4646

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ cargo build --locked -p codeguard-cli
9494

9595
Version output includes `cli_version`, `target`, and protocol information. Discovery and init preview return observations and unknowns. Dry-run creates neither `AGENTS.md` nor a project data directory. Add Cargo `--offline` only when dependencies are cached.
9696

97+
Source builds now support `codeguard lint erlang FILE --erl-tool /absolute/path/to/erl --timeout 10s --format=json`. OTP 28 scanning/parsing takes priority and catches the pinned WASM's missing-period case; macro/preprocessor inputs stay unresolved. With no explicit tool, the optional WASM candidate remains available and retains its known limit. This single-file forms observation remains incomplete for project delivery; published npm 0.1.4 does not include this new command. See the [native-first evidence](tests/acceptance/erlang-native-first.md).
98+
9799
The workspace requires `std`. The opt-in `wasm-precheck` build feature uses a bounded Rust worker with thirty-two pinned grammar candidates: ArkTS, C, C++, C#, Go, Java, JavaScript, Lua, Luau, Objective-C, Python, Rust, Solidity, TypeScript, TSX, Zig, Nix, Terraform, R, Ruby, PHP, Kotlin, Dart, Erlang, Pascal, CFML, CFQuery, CFScript, COBOL, Scala, Swift and VB.NET. Java and TypeScript/TSX have narrow single-file fallback paths; `lint python` can provide bounded suspected syntax positions when Ruff is unavailable or no project Ruff configuration is declared. Native Ruff results take priority. The published npm `0.1.3` package includes the candidate feature; `0.1.2` did not. No `no_std`, completed project-wide WASM fallback, zero-unsafe, or fastest-runtime claim is made. Runtime OS calls require safety review; a comprehensive security audit is not claimed.
98100

99101
The current source-built CLI's `codeguard grammar status --format=json` reports the coverage gap without loading grammars or running lint: the pinned CodeGraph source has 30 vendored WASM files plus two distinct grammars resolved through its dependency; CodeGuard has thirty-two unqualified asset candidates (ArkTS, C, C++, C#, Go, Java, JavaScript, Lua, Luau, Objective-C, Python, Rust, Solidity, TypeScript, TSX, Zig, Nix, Terraform, R, Ruby, PHP, Kotlin, Dart, Erlang, Pascal, CFML, CFQuery, CFScript, COBOL, Scala, Swift, VB.NET) and zero released syntax capabilities. C, C++, C#, Go, JavaScript, Lua, Luau and Rust are byte-pinned CodeGraph assets that load in the Rust worker but have no language-qualified standalone lint route or release qualification. ArkTS, Nix and Terraform are also pinned Rust-loadable candidates with narrow valid/invalid fixtures and no language-qualified standalone lint route or release qualification; see the [limited acceptance record](tests/acceptance/arkts-nix-terraform-grammar-candidates.md). The two dependency grammars retain their source bytes and use a byte-pinned legacy `dylink` metadata conversion for Rust loading; they have no language-qualified standalone lint route or release qualification. Zig uses a byte-pinned import adaptation so the corrected CodeGraph grammar can load in Rust; it has a narrow `lint zig` native-first candidate route but no release qualification. [Zig's limited acceptance record](tests/acceptance/zig-grammar-candidate.md) distinguishes this from released syntax support. Python has an unqualified CLI fallback path; its report remains incomplete and cannot approve delivery. R, Ruby, PHP and Kotlin have pinned CodeGraph bytes, licenses, measured Rust ABI and narrow worker samples; PHP covers mixed HTML/PHP, and all four remain unqualified. The original CodeGraph Dart WASM cannot be instantiated by Rust, but CodeGuard now pins a reproducible Zig rebuild with the real scanner and a byte-pinned WASI import adaptation. Its narrow Rust and worker fixtures pass, while public lint and release remain unqualified; see the [Dart rebuild record](tests/acceptance/dart-grammar-rebuild-candidate.md). Erlang now has pinned CodeGraph bytes, the upstream 0.19 license, ABI 14 and narrow Rust worker tests; it remains unqualified without native comparison or public lint. See the [Erlang candidate record](tests/acceptance/erlang-grammar-candidate.md). Pascal now has pinned CodeGraph bytes and its original Isopod dependency commit and license; ABI 14 and narrow worker tests pass, but native comparison and public lint remain open. See the [Pascal candidate record](tests/acceptance/pascal-grammar-candidate.md). The remaining CFML/CFQuery/CFScript/COBOL/Scala/Swift/VB.NET assets also load in the Rust worker, bringing the candidate inventory to 32/32 with zero released syntax capabilities. CFQuery misses `SELECT FROM`, VB.NET misparses a valid unindented method, and COBOL has a high load cost; see the [seven-asset acceptance record](tests/acceptance/final-seven-grammar-candidates.md). The separate [coverage inventory](grammars/codegraph-coverage.json) is not an approved asset manifest. COBOL's 16.4 MB asset now fits the bounded 20 MiB loader input, but its cold-load and memory budgets remain unqualified.
@@ -106,13 +108,13 @@ In a source build with `--features wasm-precheck`, `codeguard grammar probe <lan
106108

107109
Source-built `check all` now selects module-local ESLint 10 and a single flat config for discovered JS/TS/TSX files. It prefers `--node-tool`, otherwise resolving Node from PATH. Results appear under `native_results.node_lint`; initialized workspaces synchronize stable tasks and return `next`. Completed native files with matching source bytes skip duplicate WASM; missing configuration, ignored files and native failures retain their reasons and candidate fallback. The native path also works without the WASM feature. This wiring is included in npm 0.1.4 and does not cover pnpm symlink packages, older ESLint versions or every configuration combination. See [aggregate ESLint acceptance](tests/acceptance/check-all-eslint.md).
108110

109-
The same source build now runs a bounded candidate pass from `codeguard check all . --format=json` after existing native checks. Its `syntax_candidates` field in [check feedback 0.35.0](schemas/check-feedback.schema.json) carries bounded known grammar limitations and distinguishes TSX, JavaScript, CFScript and explicitly embedded CFQuery, preserving native blockers and skipped work. Python files covered by a completed Ruff scan of identical source bytes skip duplicate WASM and count under `native_preferred_count`; files without matching native syntax evidence retain candidate prechecks. Four bounded integration fixtures collectively invoked all 32 pinned grammars through this command. Every observation remains unqualified and the command exits 3; 64 files/64 fragments/90 seconds bound the candidate pass. This is not yet a language-qualified native fallback; published npm `0.1.3` includes this candidate route, while the 0.35.0 known-limitation projection is included in 0.1.4. See [acceptance evidence](tests/acceptance/check-all-32-grammar-candidates.md). Narrow 13-case syntax differentials agree for [C11 against Apple Clang 21](tests/acceptance/c-native-differential.md), [Rust 2021 against rustfmt 1.9.0](tests/acceptance/rust-native-differential.md), and [Ruby 2.6.10](tests/acceptance/ruby-native-differential.md); none qualifies native lint. A [Swift 6.4 differential](tests/acceptance/swift-native-differential.md) exposes one native-rejected source that the Swift WASM misses, so Swift remains unqualified.
111+
The same source build now runs a bounded candidate pass from `codeguard check all . --format=json` after existing native checks. Its `syntax_candidates` field in [check feedback 0.35.0](schemas/check-feedback.schema.json) carries bounded known grammar limitations and distinguishes TSX, JavaScript, CFScript and explicitly embedded CFQuery, preserving native blockers and skipped work. Python files covered by a completed Ruff scan of identical source bytes skip duplicate WASM and count under `native_preferred_count`; files without matching native syntax evidence retain candidate prechecks. Four bounded integration fixtures collectively invoked all 32 pinned grammars through this command. Every observation remains unqualified and the command exits 3; 64 files/64 fragments/90 seconds bound the candidate pass. This is not yet a language-qualified native fallback; published npm `0.1.3` includes this candidate route, while the 0.35.0 known-limitation projection is included in 0.1.4. See [acceptance evidence](tests/acceptance/check-all-32-grammar-candidates.md). Narrow 13-case syntax differentials agree for [C11 against Apple Clang 21](tests/acceptance/c-native-differential.md), [Rust 2021 against rustfmt 1.9.0](tests/acceptance/rust-native-differential.md), and [Ruby 2.6.10](tests/acceptance/ruby-native-differential.md); none qualifies native lint. The [Swift 6.4 differential](tests/acceptance/swift-native-differential.md) now separates 12 decidable agreements from one hidden-error case reported as incomplete; Swift remains unqualified.
110112

111113
The source-build acceptance test also runs the 31-file mixed-language fixture as one project: at most two isolated candidate workers run concurrently, subject to `--jobs`, while report order, source rechecks, and the 90-second candidate deadline remain fixed. A local run observed all 32 candidates with no skipped fragments; the Linux WASM integration step for source commit `ff60184` passed the same one-project test; the complete CI run passed. This is still candidate coverage, not qualified lint.
112114

113115
Java now also has a narrow [javac 21 / Java 17 differential](tests/acceptance/java-native-differential.md): 8 valid and 5 invalid syntax samples agree with the pinned WASM. This does not qualify Java lint, other language versions, or project-wide native-first routing.
114116

115-
A [Kotlin 2.4.10 differential](tests/acceptance/kotlin-native-differential.md) found a concrete false negative: `kotlinc` rejects `fun f(x: ) = x` while the pinned WASM emits no recovery. The candidate and delivery remain incomplete; install or run the applicable native checker for confirmation.
117+
The [Kotlin 2.4.10 differential](tests/acceptance/kotlin-native-differential.md) now separates 11 decidable agreements from two hidden-error cases: native-rejected `fun f(x: ) = x` and native-valid `object C { val value = 1 }`. Both are incomplete rather than clean or confirmed violations; run the applicable native checker. Zero diagnostic counts cannot classify incomplete scans.
116118

117119
The source-built Unix CLI also has a narrow Zig route: `codeguard lint zig FILE --zig-tool /absolute/path/to/zig --format=json`. An explicitly supplied tool reporting Zig 0.16.0 and retaining the same byte digest runs native `ast-check` first; its source positions are retained without exposing source snippets. Without an explicit tool, the pinned Zig WASM provides an unqualified observation. Both paths remain incomplete because `ast-check` covers only local AST errors, not full lint, build or tests. See the [Zig feedback schema](schemas/zig-lint-feedback-v0.1.schema.json).
118120

‎README.zh-CN.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Codeguard:发现 -> 选择 -> 原生工具 -> 解释结果
2525
* 部分 check 输出路径支持 SARIF。
2626
```
2727

28+
29+
源码构建现支持 `codeguard lint erlang FILE --erl-tool /absolute/path/to/erl --timeout 10s --format=json`。OTP 28 原生扫描/解析优先,能检出固定 WASM 的缺句点反例;宏与预处理保持未知。未提供显式工具时仍可作可选 WASM 初检并保留已知限制。这只是单文件 forms 观察,不能批准项目交付;已发布 npm 0.1.4 尚不含新命令。见[原生优先证据](tests/acceptance/erlang-native-first.md)。
30+
2831
## 1. 用途与边界
2932

3033
- 识别语言、构建根、声明版本、检查配置和可静态观察的模块关系。
@@ -106,13 +109,13 @@ cargo build --locked -p codeguard-cli
106109

107110
源码构建的 `check all` 现自动按 JS/TS/TSX 源码最近的项目清单选择本地 ESLint 10 和单一 flat config;`--node-tool` 优先,否则查找 PATH 中的 Node。原生结果进入 `native_results.node_lint`,已初始化工作区自动同步稳定任务并返回 `next`。完整且源码摘要匹配的原生文件跳过重复 WASM;缺配置、原生忽略或故障的文件保留原因并继续候选初检。此接线也适用于未启用 WASM 的构建;已包含在 npm 0.1.4,不覆盖 pnpm 链接包、ESLint 旧版或所有配置组合。见[聚合 ESLint 验收](tests/acceptance/check-all-eslint.md)。
108111

109-
同一源码构建现在会在既有原生检查之后,从 `codeguard check all . --format=json` 执行有界候选初检。[检查反馈 0.35.0](schemas/check-feedback.schema.json)中的 `syntax_candidates` 附带有界的已知 grammar 限制,并区分 TSX、JavaScript、CFScript 和明确嵌入的 CFQuery,同时保留原生阻塞与未执行范围。Ruff 已对相同源码完成原生扫描的 Python 文件跳过重复 WASM,并计入 `native_preferred_count`;其余未确认语法能力的文件仍运行候选初检。四个有界集成样例经此入口合计调用了 32 种固定 grammar。观察仍未验收,命令保持退出码 3;候选阶段限 64 文件、64 片段、90 秒。这尚非逐语言验收的原生兜底;已发布 npm `0.1.3` 包含该候选路径,0.35.0 的已知限制投影已包含于 0.1.4;见[验收记录](tests/acceptance/check-all-32-grammar-candidates.md)。[C11 与 Apple Clang 21 差分](tests/acceptance/c-native-differential.md)、[Rust 2021 与 rustfmt 1.9.0 差分](tests/acceptance/rust-native-differential.md)和[Ruby 2.6.10 差分](tests/acceptance/ruby-native-differential.md)各在 13 个窄范围语法样例上一致,但不代表对应语言的原生 lint 已验收。[Swift 6.4 差分](tests/acceptance/swift-native-differential.md)发现一处原生拒绝而 Swift WASM 漏检的源码,因此 Swift 仍未验收。
112+
同一源码构建现在会在既有原生检查之后,从 `codeguard check all . --format=json` 执行有界候选初检。[检查反馈 0.35.0](schemas/check-feedback.schema.json)中的 `syntax_candidates` 附带有界的已知 grammar 限制,并区分 TSX、JavaScript、CFScript 和明确嵌入的 CFQuery,同时保留原生阻塞与未执行范围。Ruff 已对相同源码完成原生扫描的 Python 文件跳过重复 WASM,并计入 `native_preferred_count`;其余未确认语法能力的文件仍运行候选初检。四个有界集成样例经此入口合计调用了 32 种固定 grammar。观察仍未验收,命令保持退出码 3;候选阶段限 64 文件、64 片段、90 秒。这尚非逐语言验收的原生兜底;已发布 npm `0.1.3` 包含该候选路径,0.35.0 的已知限制投影已包含于 0.1.4;见[验收记录](tests/acceptance/check-all-32-grammar-candidates.md)。[C11 与 Apple Clang 21 差分](tests/acceptance/c-native-differential.md)、[Rust 2021 与 rustfmt 1.9.0 差分](tests/acceptance/rust-native-differential.md)和[Ruby 2.6.10 差分](tests/acceptance/ruby-native-differential.md)各在 13 个窄范围语法样例上一致,但不代表对应语言的原生 lint 已验收。[Swift 6.4 差分](tests/acceptance/swift-native-differential.md)现区分 12 例可判定的一致结果与 1 例隐藏错误导致的未完成;Swift 仍未验收。
110113

111114
源码构建的验收测试还把 31 个源码文件作为一个混合语言项目:候选阶段最多同时运行两个隔离 worker,并服从 `--jobs`;报告顺序、源码复读与 90 秒总截止时间不变。本机单次运行观察到全部 32 种候选且无跳过片段;源码提交 `ff60184` 的 Linux WASM 集成步骤已通过同一单项目测试;完整 CI 已通过。这仍是候选覆盖,不是已验收的 lint。
112115

113116
Java 另有一组窄范围的 [javac 21 / Java 17 差分](tests/acceptance/java-native-differential.md):8 份合法、5 份非法语法样例与固定 WASM 一致。这不代表 Java lint、其它语言版本或项目级原生优先路由已验收。
114117

115-
[Kotlin 2.4.10 差分](tests/acceptance/kotlin-native-differential.md)发现具体漏检:`kotlinc` 拒绝 `fun f(x: ) = x`,固定 WASM 却没有恢复节点。候选与交付仍保持未完成,必须由适用原生检查器确认。
118+
[Kotlin 2.4.10 差分](tests/acceptance/kotlin-native-differential.md)现区分 11 例可判定的一致结果与 2 例隐藏错误:原生拒绝的 `fun f(x: ) = x` 和原生合法的 `object C { val value = 1 }` 均为未完成,不能当作通过或已确认违规。零诊断数不能为未完成扫描分类,仍需适用原生检查器确认。
116119

117120
源码构建的 Unix CLI 还提供局部 Zig 入口:`codeguard lint zig FILE --zig-tool /absolute/path/to/zig --format=json`。显式提供且报告 Zig 0.16.0、执行前后字节摘要一致的工具优先运行原生 `ast-check`,仅输出诊断位置,不回显源码;未显式提供工具时,固定 Zig WASM 给出未验收候选观察。两条路径都保持未完成,因为 `ast-check` 仅覆盖局部 AST 错误,不等于完整 lint、构建或测试。见 [Zig 报告 Schema](schemas/zig-lint-feedback-v0.1.schema.json)。
118121

0 commit comments

Comments
 (0)