diff --git a/README.md b/README.md index dbf070ae..194b6b77 100644 --- a/README.md +++ b/README.md @@ -94,9 +94,9 @@ cargo build --locked -p codeguard-cli 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. -The workspace requires `std`. The opt-in `wasm-precheck` build feature uses a bounded Rust worker with eighteen pinned grammar candidates: ArkTS, C, C++, C#, Go, Java, JavaScript, Lua, Luau, Objective-C, Python, Rust, Solidity, TypeScript, TSX, Zig, Nix, and Terraform. 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. It is absent from the published npm `0.1.2` package. 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. +The workspace requires `std`. The opt-in `wasm-precheck` build feature uses a bounded Rust worker with twenty-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, and Kotlin. 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. It is absent from the published npm `0.1.2` package. 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. -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 eighteen unqualified asset candidates (ArkTS, C, C++, C#, Go, Java, JavaScript, Lua, Luau, Objective-C, Python, Rust, Solidity, TypeScript, TSX, Zig, Nix, Terraform) 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 public lint route or release qualification. ArkTS, Nix and Terraform are also pinned Rust-loadable candidates with narrow valid/invalid fixtures and no public 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 public lint route or release qualification. Zig uses a byte-pinned import adaptation so the corrected CodeGraph grammar can load in Rust; it has no public `lint zig` route or release qualification yet. [Zig's limited acceptance record](tests/acceptance/zig-grammar-candidate.md) distinguishes this from released syntax support. Python has a source-build-only, unqualified CLI fallback path; its report remains incomplete and cannot approve delivery. The separate [coverage inventory](grammars/codegraph-coverage.json) is not an approved asset manifest. COBOL's 16.4 MB source asset also exceeds the current Rust loader's 8 MiB limit. +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 twenty-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) 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 public lint route or release qualification. ArkTS, Nix and Terraform are also pinned Rust-loadable candidates with narrow valid/invalid fixtures and no public 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 public lint route or release qualification. Zig uses a byte-pinned import adaptation so the corrected CodeGraph grammar can load in Rust; it has no public `lint zig` route or release qualification yet. [Zig's limited acceptance record](tests/acceptance/zig-grammar-candidate.md) distinguishes this from released syntax support. Python has a source-build-only, 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. Dart remains a gap because its source WASM external scanner import cannot be instantiated by the current Rust worker; see the [limited acceptance record](tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md). The separate [coverage inventory](grammars/codegraph-coverage.json) is not an approved asset manifest. COBOL's 16.4 MB source asset also exceeds the current Rust loader's 8 MiB limit. ### npm installation and one-off use diff --git a/crates/codeguard-adapters/src/grammar_asset_manifest.rs b/crates/codeguard-adapters/src/grammar_asset_manifest.rs index df9b7474..a05b31f7 100644 --- a/crates/codeguard-adapters/src/grammar_asset_manifest.rs +++ b/crates/codeguard-adapters/src/grammar_asset_manifest.rs @@ -22,6 +22,10 @@ const LUAU_COMMIT: &str = "a8914d6c1fc5131f8e1c13f769fa704c9f5eb02f"; const ARKTS_COMMIT: &str = "56f7fc288715befe92c734d603f9e6bc3c65d2a8"; const NIX_COMMIT: &str = "3d0173d903e630b6e14d17f1cf79488791379ded"; const TERRAFORM_COMMIT: &str = "fad991865fee927dd1de5e172fb3f08ac674d914"; +const R_COMMIT: &str = "e9944e9801595ad484f49be492daf0c4c81547ef"; +const RUBY_COMMIT: &str = "71bd32fb7607035768799732addba884a37a6210"; +const PHP_COMMIT: &str = "5b5627faaa290d89eb3d01b9bf47c3bb9e797dea"; +const KOTLIN_COMMIT: &str = "e1a2d5ad1f61f5740677183cd4125bb071cd2f30"; /// 代码来源、许可和每份候选 grammar 的固定身份。 #[derive(Clone, Debug, Deserialize, Eq, PartialEq)] @@ -181,6 +185,22 @@ fn verify_bundled_asset(asset: &GrammarAsset) -> Result<&'static [u8], String> { include_bytes!("../../../grammars/nix/parser.wasm").as_slice(), include_bytes!("../../../grammars/nix/LICENSE").as_slice(), ), + "r" => ( + include_bytes!("../../../grammars/r/parser.wasm").as_slice(), + include_bytes!("../../../grammars/r/LICENSE").as_slice(), + ), + "ruby" => ( + include_bytes!("../../../grammars/ruby/parser.wasm").as_slice(), + include_bytes!("../../../grammars/ruby/LICENSE").as_slice(), + ), + "php" => ( + include_bytes!("../../../grammars/php/parser.wasm").as_slice(), + include_bytes!("../../../grammars/php/LICENSE").as_slice(), + ), + "kotlin" => ( + include_bytes!("../../../grammars/kotlin/parser.wasm").as_slice(), + include_bytes!("../../../grammars/kotlin/LICENSE").as_slice(), + ), "java" => ( include_bytes!("../../../grammars/java/parser.wasm").as_slice(), include_bytes!("../../../grammars/java/LICENSE").as_slice(), @@ -262,7 +282,7 @@ pub fn parse_grammar_asset_manifest(raw: &[u8]) -> Result Result Result ( + "https://github.com/fwcd/tree-sitter-kotlin", + KOTLIN_COMMIT, + "0.3.8", + "kotlin/parser.wasm", + "c80c88867a589a1a0959bcea89de84b7e9684b3693b2cdb2944812458e62ff48", + 4052313, + "kotlin/LICENSE", + "948495f61768f7de26bcc61113d8cd95f50bbc15adb678c28c941c6c8fcd5903", + ), "python" => ( "https://github.com/tree-sitter/tree-sitter-python", PYTHON_COMMIT, @@ -368,6 +402,36 @@ pub fn parse_grammar_asset_manifest(raw: &[u8]) -> Result ( + "https://github.com/tree-sitter/tree-sitter-php", + PHP_COMMIT, + "v0.24.2-full-php", + "php/parser.wasm", + "6545a9a110bc878e26ed329950147e190c83da038bb17e999de646fe6c4d6c82", + 1058082, + "php/LICENSE", + "664764fabf40c0b318e06324a5a12379092a2df25b8cbf2415f71bc0bb352346", + ), + "r" => ( + "https://github.com/r-lib/tree-sitter-r", + R_COMMIT, + "v1.2.0", + "r/parser.wasm", + "2a8f5acd1c53d91e0ec5c01a6830d8ac7f5a7f96f0ac4b3768c016c8e9d07711", + 481163, + "r/LICENSE", + "de2e49529f03d573bc3fa229dc83acfe22c63a5ad1766b289563edfd45b72dea", + ), + "ruby" => ( + "https://github.com/tree-sitter/tree-sitter-ruby", + RUBY_COMMIT, + "v0.23.1", + "ruby/parser.wasm", + "4cb5a4b12870876ca864c1e92fe1f5cd47036b2adc083e9306488af88867dbb4", + 2106097, + "ruby/LICENSE", + "ee006f02a3d856df282e409be2a86e24a65bb573a98b9c28343771141351bb6b", + ), "javascript" => ( "https://github.com/tree-sitter/tree-sitter-javascript", JAVASCRIPT_COMMIT, @@ -525,7 +589,7 @@ pub fn parse_grammar_asset_manifest(raw: &[u8]) -> Result ( @@ -106,10 +106,26 @@ fn bundled_candidates_pin_source_bytes_license_and_abi_without_claiming_support( include_bytes!("../../../grammars/java/parser.wasm").as_slice(), include_bytes!("../../../grammars/java/LICENSE").as_slice(), ), + "kotlin" => ( + include_bytes!("../../../grammars/kotlin/parser.wasm").as_slice(), + include_bytes!("../../../grammars/kotlin/LICENSE").as_slice(), + ), "python" => ( include_bytes!("../../../grammars/python/parser.wasm").as_slice(), include_bytes!("../../../grammars/python/LICENSE").as_slice(), ), + "php" => ( + include_bytes!("../../../grammars/php/parser.wasm").as_slice(), + include_bytes!("../../../grammars/php/LICENSE").as_slice(), + ), + "r" => ( + include_bytes!("../../../grammars/r/parser.wasm").as_slice(), + include_bytes!("../../../grammars/r/LICENSE").as_slice(), + ), + "ruby" => ( + include_bytes!("../../../grammars/ruby/parser.wasm").as_slice(), + include_bytes!("../../../grammars/ruby/LICENSE").as_slice(), + ), "typescript" => ( include_bytes!("../../../grammars/typescript/parser.wasm").as_slice(), include_bytes!("../../../grammars/typescript/LICENSE").as_slice(), diff --git a/crates/codeguard-cli/src/grammar_status_command.rs b/crates/codeguard-cli/src/grammar_status_command.rs index 8be3e785..5c8abc3e 100644 --- a/crates/codeguard-cli/src/grammar_status_command.rs +++ b/crates/codeguard-cli/src/grammar_status_command.rs @@ -136,6 +136,7 @@ fn coverage_report() -> Result { "released":false, "gap":if candidate.is_some_and(|item| item.codeguard_runtime_validation == "rust_loader_incompatible") {"rust_loader_incompatible"} else if asset.bytes.is_some_and(|bytes| bytes > 8 * 1024 * 1024) {"current_loader_size_limit"} + else if asset.language == "dart" && candidate.is_none() {"rust_worker_external_scanner_import"} else if candidate.is_some() {"language_qualification_and_release_pending"} else {"asset_provenance_license_and_loader_validation_pending"}, }) diff --git a/crates/codeguard-cli/tests/grammar_status_cli.rs b/crates/codeguard-cli/tests/grammar_status_cli.rs index ef3aadd1..17aa13bb 100644 --- a/crates/codeguard-cli/tests/grammar_status_cli.rs +++ b/crates/codeguard-cli/tests/grammar_status_cli.rs @@ -12,7 +12,7 @@ fn codegraph_coverage_is_explicit_and_never_claims_parser_or_gate_completion() { assert_eq!(report["report_type"], "grammar_coverage_inventory"); assert_eq!(report["codegraph_grammar_count"], 32); assert_eq!(report["codegraph_vendored_count"], 30); - assert_eq!(report["candidate_count"], 18); + assert_eq!(report["candidate_count"], 22); assert_eq!(report["released_count"], 0); assert_eq!(report["authority"], "source_inventory_only"); assert_eq!(report["parser_capability"], "unverified"); @@ -33,11 +33,15 @@ fn codegraph_coverage_is_explicit_and_never_claims_parser_or_gate_completion() { "go", "java", "javascript", + "kotlin", "lua", "luau", "nix", "objc", + "php", "python", + "r", + "ruby", "rust", "solidity", "terraform", @@ -58,6 +62,9 @@ fn codegraph_coverage_is_explicit_and_never_claims_parser_or_gate_completion() { .unwrap(); assert_eq!(cobol["gap"], "current_loader_size_limit"); assert!(cobol["source_bytes"].as_u64().unwrap() > 8 * 1024 * 1024); + let dart = assets.iter().find(|row| row["language"] == "dart").unwrap(); + assert_eq!(dart["integration_status"], "not_integrated"); + assert_eq!(dart["gap"], "rust_worker_external_scanner_import"); let zig = assets.iter().find(|row| row["language"] == "zig").unwrap(); assert_eq!(zig["gap"], "language_qualification_and_release_pending"); for language in ["objc", "solidity"] { diff --git a/crates/codeguard-cli/tests/syntax_worker_candidate.rs b/crates/codeguard-cli/tests/syntax_worker_candidate.rs index 1cb6f645..1c5a8504 100644 --- a/crates/codeguard-cli/tests/syntax_worker_candidate.rs +++ b/crates/codeguard-cli/tests/syntax_worker_candidate.rs @@ -194,6 +194,33 @@ fn arkts_nix_and_terraform_run_in_worker_without_claiming_clean() { } } +#[test] +fn r_ruby_php_and_kotlin_run_in_worker_without_claiming_clean() { + for (language, path, source) in [ + ("r", "analysis.R", b"x <- 1\n".as_slice()), + ("ruby", "app.rb", b"def f; 1; end\n".as_slice()), + ( + "php", + "index.php", + b"Hi") + .unwrap() + .root_node() + .has_error() + ); +} #[test] fn third_batch_grammars_load_offline_and_parse_basic_fixtures() { diff --git a/docs/Codeguard-Architecture.md b/docs/Codeguard-Architecture.md index 1c8782c3..9539b146 100644 --- a/docs/Codeguard-Architecture.md +++ b/docs/Codeguard-Architecture.md @@ -28,7 +28,7 @@ The existing [OpenSpec change](../openspec/changes/introduce-rust-codeguard-cli/ | [Core aggregation](../crates/codeguard-core/src/aggregate.rs), [delivery gate](../crates/codeguard-core/src/delivery_gate.rs) | Pure result semantics, not trusted public gate availability | | [Acceptance records](../tests/acceptance) | Scoped observations, test method, and residual gaps | -WASM requirements and 19 implementation tasks are recorded in the existing change. An opt-in Rust worker and narrow Java/TypeScript/TSX single-file feedback paths and a Python Ruff-unavailable candidate path now exist. All eighteen candidate grammars remain unqualified; ArkTS, C, C++, C#, Go, JavaScript, Lua, Luau, Nix, Rust, Terraform, Zig, Objective-C and Solidity are pinned Rust-loadable candidates without public lint routes. Project-wide native-first routing, qualified grammar ranges, capability-matched task closure, and host integrations remain incomplete; design examples are not current command output. +WASM requirements and 19 implementation tasks are recorded in the existing change. An opt-in Rust worker and narrow Java/TypeScript/TSX single-file feedback paths and a Python Ruff-unavailable candidate path now exist. All twenty-two candidate grammars remain unqualified; ArkTS, C, C++, C#, Go, JavaScript, Lua, Luau, Nix, Rust, Terraform, Zig, Objective-C, Solidity, R, Ruby, PHP and Kotlin are pinned Rust-loadable candidates without public lint routes. Project-wide native-first routing, qualified grammar ranges, capability-matched task closure, and host integrations remain incomplete; design examples are not current command output. ## 2. Architectural drivers @@ -241,7 +241,9 @@ A completed native violation never selects fallback to obtain a clean result. A Reuse pinned CodeGraph grammar WASM artifacts and applicable upstream licenses, source references, patches and corpus cases. Do not copy CodeGraph's graph extraction or source-blanking heuristics into a syntax verdict. CodeGraph's `src/extraction/grammars.ts` loads language artifacts through `web-tree-sitter`; successful loading there does not prove compatibility with Codeguard's Rust runtime. The local source review on 2026-09-28 found modified grammar artifacts and about 65 MB of grammar files, so a live directory is not a release input. -The read-only `codeguard grammar status` command projects a [pinned CodeGraph coverage inventory](../grammars/codegraph-coverage.json): 30 vendored WASM files and two dependency-provided grammars. CodeGuard currently pins 18 Rust-loadable candidates, including ArkTS, Nix and Terraform; none is qualified for release. Their fixed source, npm-package integrity where applicable, and narrow worker evidence are recorded in the [candidate acceptance](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md). ArkTS, Nix and Terraform have pinned bytes, licenses and narrow Rust worker evidence, but no public lint route or release qualification; see the [limited acceptance record](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md). The corrected Zig source WASM requires a pinned import adaptation to load in Rust; public `lint zig` and language qualification remain open. Python has a narrow source-build-only fallback for unavailable or undeclared Ruff, with native results taking priority and no delivery approval. An initialized single-file scope now syncs one stable native-confirmation task; candidate zero recoveries do not close it. This inventory is deliberately separate from the pinned [candidate asset manifest](../grammars/manifest.json). In particular, the COBOL source file exceeds the current loader's 8 MiB input limit. Inventory rows never trigger loading or count as supported parser capability. +The read-only `codeguard grammar status` command projects a [pinned CodeGraph coverage inventory](../grammars/codegraph-coverage.json): 30 vendored WASM files and two dependency-provided grammars. CodeGuard currently pins 22 Rust-loadable candidates, including ArkTS, Nix and Terraform; none is qualified for release. ArkTS, Nix and Terraform provenance and worker evidence are recorded in the [candidate acceptance](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md). ArkTS, Nix and Terraform have pinned bytes, licenses and narrow Rust worker evidence, but no public lint route or release qualification; see the [limited acceptance record](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md). The corrected Zig source WASM requires a pinned import adaptation to load in Rust; public `lint zig` and language qualification remain open. Python has a narrow source-build-only fallback for unavailable or undeclared Ruff, with native results taking priority and no delivery approval. An initialized single-file scope now syncs one stable native-confirmation task; candidate zero recoveries do not close it. This inventory is deliberately separate from the pinned [candidate asset manifest](../grammars/manifest.json). In particular, the COBOL source file exceeds the current loader's 8 MiB input limit. Inventory rows never trigger loading or count as supported parser capability. + +R, Ruby, PHP and Kotlin now also have pinned CodeGraph bytes, licenses, measured Rust ABI and narrow positive/negative worker samples; the PHP fixture covers mixed HTML/PHP. They remain unqualified candidates. Dart is still a gap because the pinned source WASM imports an external scanner that the current Rust worker cannot instantiate; see the [limited acceptance record](../tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md). ```text grammars/ # proposed release assets, not project state @@ -345,6 +347,7 @@ flowchart LR Coalescing applies only to duplicate fast feedback for the same content snapshot; it cannot swallow new input, failed rechecks or delivery events. Cache identity must cover source and dependency closure, tool, rules, configuration, platform and vulnerability database freshness. Strict gates revalidate full obligations and identities, then recompute or report incomplete when proof is missing. Measure latency percentiles, repeat execution, invalidations, missed findings and false positives per tier before fixing budgets. + ## 9. Persistence and ownership ```text diff --git a/docs/Codeguard-Architecture.zh_CN.md b/docs/Codeguard-Architecture.zh_CN.md index f85533fd..56128b37 100644 --- a/docs/Codeguard-Architecture.zh_CN.md +++ b/docs/Codeguard-Architecture.zh_CN.md @@ -28,7 +28,7 @@ | [核心聚合](../crates/codeguard-core/src/aggregate.rs)、[交付门禁](../crates/codeguard-core/src/delivery_gate.rs) | 纯结果语义,不代表公开可信门禁已可用 | | [验收记录](../tests/acceptance) | 限定范围的观察、测试方法和剩余缺口 | -WASM 的规范与 19 项实施任务已纳入既有 change;可选 Rust worker 与 Java/TypeScript/TSX 局部单文件反馈路径及 Python Ruff 不可用时的候选路径已存在;十八份候选 grammar 都尚未验收;ArkTS、C、C++、C#、Go、JavaScript、Lua、Luau、Nix、Rust、Terraform、Zig、Objective-C、Solidity 仅有固定字节的 Rust 可加载候选资产,尚无公开 lint 路由。项目级原生优先调度、grammar 版本范围验收、任务的能力匹配关闭及宿主接线仍未完成;设计示例不是当前命令输出。 +WASM 的规范与 19 项实施任务已纳入既有 change;可选 Rust worker 与 Java/TypeScript/TSX 局部单文件反馈路径及 Python Ruff 不可用时的候选路径已存在;二十二份候选 grammar 都尚未验收;ArkTS、C、C++、C#、Go、JavaScript、Lua、Luau、Nix、Rust、Terraform、Zig、Objective-C、Solidity、R、Ruby、PHP、Kotlin 仅有固定字节的 Rust 可加载候选资产,尚无公开 lint 路由。项目级原生优先调度、grammar 版本范围验收、任务的能力匹配关闭及宿主接线仍未完成;设计示例不是当前命令输出。 ## 2. 架构驱动 @@ -241,7 +241,9 @@ flowchart TD 复用固定版本的 CodeGraph grammar WASM,以及适用的上游许可证、源码引用、补丁和语料。不能把 CodeGraph 的图提取或源码遮盖启发式直接用于语法判定。CodeGraph 的 `src/extraction/grammars.ts` 通过 `web-tree-sitter` 加载语言资产,在那里可加载不证明兼容 Codeguard 的 Rust 运行时。发行时必须固定不可变的来源与资产清单,不能把正在修改的本地目录直接当作发行输入。 -只读 `codeguard grammar status` 现投影[固定来源覆盖库存](../grammars/codegraph-coverage.json):CodeGraph 随仓 30 份 WASM,依赖提供另两种独立 grammar;CodeGuard 有 C、C++、C#、Go、Java、JavaScript、Lua、Luau、Objective-C、Python、Rust、Solidity、TypeScript、TSX、Zig、ArkTS、Nix、Terraform 十八份资产候选。C、C++、C#、Go、JavaScript、Lua、Luau、Rust 的 CodeGraph 随仓字节及上游标签许可证已固定,可由 Rust worker 解析基础正反例,但尚未进行语言验收或公开 lint 接线。ArkTS、Nix、Terraform 的来源、许可证、字节及 Rust 正反例也已固定,仅为候选,尚无公开 lint 路由或发行验收;见[局部验收](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md)。Objective-C 与 Solidity 来自锁定的 `tree-sitter-wasms@0.1.13`,保留原始字节和许可证,并以固定散列的 `dylink` 元数据转换加载;仍未做语言验收与发行。Zig 新版来源 WASM 的导入经固定哈希适配后由 Rust 加载,但仍无公开 `lint zig` 路由,尚无已验收发行能力。Python 已有源码可选构建中的局部 `lint` 兜底,仅覆盖 Ruff 不可用或项目未声明配置的情形;原生结果优先且不能批准交付。已初始化工作区的单文件范围可同步稳定的原生确认任务;候选零恢复节点不会关闭任务。覆盖库存与[候选资产清单](../grammars/manifest.json)分开,不能凭库存行自动加载或宣称支持。尤其 COBOL 来源资产超过当前加载器 8 MiB 限额。 +只读 `codeguard grammar status` 现投影[固定来源覆盖库存](../grammars/codegraph-coverage.json):CodeGraph 随仓 30 份 WASM,依赖提供另两种独立 grammar;CodeGuard 有 C、C++、C#、Go、Java、JavaScript、Lua、Luau、Objective-C、Python、Rust、Solidity、TypeScript、TSX、Zig、ArkTS、Nix、Terraform、R、Ruby、PHP、Kotlin 二十二份资产候选。C、C++、C#、Go、JavaScript、Lua、Luau、Rust 的 CodeGraph 随仓字节及上游标签许可证已固定,可由 Rust worker 解析基础正反例,但尚未进行语言验收或公开 lint 接线。ArkTS、Nix、Terraform 的来源、许可证、字节及 Rust 正反例也已固定,仅为候选,尚无公开 lint 路由或发行验收;见[局部验收](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md)。Objective-C 与 Solidity 来自锁定的 `tree-sitter-wasms@0.1.13`,保留原始字节和许可证,并以固定散列的 `dylink` 元数据转换加载;仍未做语言验收与发行。Zig 新版来源 WASM 的导入经固定哈希适配后由 Rust 加载,但仍无公开 `lint zig` 路由,尚无已验收发行能力。Python 已有源码可选构建中的局部 `lint` 兜底,仅覆盖 Ruff 不可用或项目未声明配置的情形;原生结果优先且不能批准交付。已初始化工作区的单文件范围可同步稳定的原生确认任务;候选零恢复节点不会关闭任务。覆盖库存与[候选资产清单](../grammars/manifest.json)分开,不能凭库存行自动加载或宣称支持。尤其 COBOL 来源资产超过当前加载器 8 MiB 限额。 + +R、Ruby、PHP、Kotlin 也已固定 CodeGraph 字节、许可证和 Rust 实测 ABI,并通过隔离 worker 的窄范围正反例;PHP 样例覆盖 HTML/PHP 混合内容,仍仅为未验收候选。Dart 来源 WASM 的外部 scanner 导入无法由当前 Rust worker 实例化,仍为缺口;见[局部验收](../tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md)。 ```text grammars/ # 规划中的发行资产,不是项目状态 @@ -345,6 +347,7 @@ flowchart LR 节流只合并同一内容快照的重复快反馈,不吞掉新输入、失败复检或交付事件。缓存至少绑定源码及依赖闭包、工具、规则、配置、平台和漏洞库时效;严格门禁重新核验完整义务与身份,缺证明时重算或标未完成。对每档分别测量耗时分位数、重复执行、缓存失效、漏检和误报,再确定预算;不能仅靠固定延时声称高效。 + ## 9. 持久化与所有权 ```text diff --git a/docs/Codeguard-Technical-Design.md b/docs/Codeguard-Technical-Design.md index 9c886e7b..e7039834 100644 --- a/docs/Codeguard-Technical-Design.md +++ b/docs/Codeguard-Technical-Design.md @@ -14,7 +14,7 @@ The existing [OpenSpec change](../openspec/changes/introduce-rust-codeguard-cli/ Current source is the authority for callable behavior. Target contracts are labelled as such. The product priority is configuration discovery → native results → useful repair guidance. Internal consistency checks support this experience; they are not a demand for users to manually construct execution certificates. -WASM requirements and 19 implementation tasks are recorded in the existing change. Candidate Rust worker and narrow Java/TypeScript/TSX single-file reports and a Python Ruff-unavailable candidate report now exist behind an opt-in feature; all eighteen candidate grammars remain unqualified; ArkTS, C, C++, C#, Go, JavaScript, Lua, Luau, Nix, Rust, Terraform, Zig, Objective-C and Solidity are only Rust-loadable candidates. Project-wide native-first routing, qualified grammar ranges, and host integrations remain incomplete. Design examples are not current command output. +WASM requirements and 19 implementation tasks are recorded in the existing change. Candidate Rust worker and narrow Java/TypeScript/TSX single-file reports and a Python Ruff-unavailable candidate report now exist behind an opt-in feature; all twenty-two candidate grammars remain unqualified; ArkTS, C, C++, C#, Go, JavaScript, Lua, Luau, Nix, Rust, Terraform, Zig, Objective-C, Solidity, R, Ruby, PHP and Kotlin are only Rust-loadable candidates. Project-wide native-first routing, qualified grammar ranges, and host integrations remain incomplete. Design examples are not current command output. ## 2. Technology choices and trade-offs @@ -191,7 +191,9 @@ The opt-in CLI build first checks for a local ESLint 10 package and a single ord Import only pinned WASM bytes with upstream license, commit/patch provenance, SHA-256, ABI, tested runtime and language/dialect ranges, corpus reference and known gaps. Verify each copied CodeGraph artifact in the selected Rust Tree-sitter runtime; do not copy TypeScript extraction logic or assume CodeGraph support equals syntax acceptance. A release manifest belongs to distribution assets, not writable `.codeguard/` project state. -Use `codeguard grammar status --format=json` to query the separate source coverage inventory. It reports 32 distinct CodeGraph grammar assets, eighteen CodeGuard asset candidates (ArkTS, C, C++, C#, Go, Java, JavaScript, Lua, Luau, Objective-C, Python, Rust, Solidity, TypeScript, TSX, Zig, Nix and Terraform), and zero released capabilities without running a parser. Python has a narrow source-build-only `lint` fallback for unavailable or undeclared Ruff, never a clean or delivery result. A bound, single-file result uses [feedback 0.15.0](../schemas/python-lint-feedback-v0.15.schema.json) and persists a [0.1.0 confirmation observation](../schemas/python-syntax-confirmation-observation-v0.1.schema.json) through the existing work sync. The task identity binds workspace and source scope; current-source SHA-256 and pinned grammar are checked before import. Native capability-matched closure remains open. C, C++, C#, Go, JavaScript, Lua, Luau and Rust have pinned vendored bytes and narrow Rust worker smoke tests, but no public lint route or language qualification. ArkTS, Nix and Terraform have pinned bytes, licenses and narrow Rust worker evidence, but no public lint route or release qualification; see the [limited acceptance record](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md). The two dependency-provided assets now have pinned original and adapted bytes plus license references, but are still unqualified candidates without public lint routes. COBOL exceeds the current 8 MiB loader limit. +Use `codeguard grammar status --format=json` to query the separate source coverage inventory. It reports 32 distinct CodeGraph grammar assets, twenty-two CodeGuard asset candidates (ArkTS, C, C++, C#, Go, Java, JavaScript, Lua, Luau, Objective-C, Python, Rust, Solidity, TypeScript, TSX, Zig, Nix, Terraform, R, Ruby, PHP and Kotlin), and zero released capabilities without running a parser. Python has a narrow source-build-only `lint` fallback for unavailable or undeclared Ruff, never a clean or delivery result. A bound, single-file result uses [feedback 0.15.0](../schemas/python-lint-feedback-v0.15.schema.json) and persists a [0.1.0 confirmation observation](../schemas/python-syntax-confirmation-observation-v0.1.schema.json) through the existing work sync. The task identity binds workspace and source scope; current-source SHA-256 and pinned grammar are checked before import. Native capability-matched closure remains open. C, C++, C#, Go, JavaScript, Lua, Luau and Rust have pinned vendored bytes and narrow Rust worker smoke tests, but no public lint route or language qualification. ArkTS, Nix and Terraform have pinned bytes, licenses and narrow Rust worker evidence, but no public lint route or release qualification; see the [limited acceptance record](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md). The two dependency-provided assets now have pinned original and adapted bytes plus license references, but are still unqualified candidates without public lint routes. COBOL exceeds the current 8 MiB loader limit. + +R, Ruby, PHP and Kotlin now also have pinned CodeGraph bytes, licenses, measured Rust ABI and narrow positive/negative worker samples; the PHP fixture covers mixed HTML/PHP. They remain unqualified candidates. Dart is still a gap because the pinned source WASM imports an external scanner that the current Rust worker cannot instantiate; see the [limited acceptance record](../tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md). Use a parent-controlled parser worker with a total deadline, per-file input bound, memory/process limit and capped diagnostics. Lazy-load selected grammars, parse without general network/filesystem imports, and terminate a stuck worker without losing native results from other modules. Host-specific enforcement and Rust MSRV compatibility must be tested; numeric production budgets remain measurement-driven rather than invented promises. @@ -199,6 +201,7 @@ The opt-in Rust CLI now has a private [candidate worker](../crates/codeguard-cli Cache by source content, dialect/language profile, grammar bytes, parser runtime, query/rule version and relevant scope/configuration identity. Cancellation, partial output and unresolved coverage cannot produce a reusable clean result. Artifact replacement invalidates affected caches and dispositions. Roll back a language pack by its verified manifest; retain historical observations and never infer resolution from cache deletion. + ## 6. Static detection portfolio The [28-family registry](../crates/codeguard-core/src/capability_dimensions.rs) prevents distinct checks from being collapsed into one generic lint result. diff --git a/docs/Codeguard-Technical-Design.zh_CN.md b/docs/Codeguard-Technical-Design.zh_CN.md index 44406747..feffda67 100644 --- a/docs/Codeguard-Technical-Design.zh_CN.md +++ b/docs/Codeguard-Technical-Design.zh_CN.md @@ -14,7 +14,7 @@ 可调用行为以当前源码为准,目标契约明确标注。产品优先级是配置发现 → 原生结果 → 有用的修复指引。内部一致性校验为这个体验服务,不要求用户手工构造执行证明。 -WASM 的规范与 19 项实施任务已纳入既有 change;可选特性下的 Rust worker 与 Java/TypeScript/TSX 局部单文件候选报告及 Python Ruff 不可用时的候选报告已存在;十八份候选 grammar 均未验收;ArkTS、C、C++、C#、Go、JavaScript、Lua、Luau、Nix、Rust、Terraform、Zig、Objective-C、Solidity 仅有固定字节的 Rust 可加载候选资产,尚无公开 lint 路由。项目级原生优先调度、grammar 版本范围验收与宿主接线仍未完成。设计示例不是当前命令输出。 +WASM 的规范与 19 项实施任务已纳入既有 change;可选特性下的 Rust worker 与 Java/TypeScript/TSX 局部单文件候选报告及 Python Ruff 不可用时的候选报告已存在;二十二份候选 grammar 均未验收;ArkTS、C、C++、C#、Go、JavaScript、Lua、Luau、Nix、Rust、Terraform、Zig、Objective-C、Solidity、R、Ruby、PHP、Kotlin 仅有固定字节的 Rust 可加载候选资产,尚无公开 lint 路由。项目级原生优先调度、grammar 版本范围验收与宿主接线仍未完成。设计示例不是当前命令输出。 ## 2. 技术选型与权衡 @@ -191,7 +191,9 @@ flowchart LR 只引入固定 WASM 字节及上游许可证、提交/补丁来源、SHA-256、ABI、已验证运行时和语言/方言范围、语料引用与已知缺口。逐个验证 CodeGraph 资产与选定 Rust Tree-sitter 运行时兼容,不能复制 TypeScript 提取逻辑或把 CodeGraph 支持等同语法验收。发行清单属于分发资产,不属于可写的 `.codeguard/` 项目状态。 -可用 `codeguard grammar status --format=json` 查询独立的来源覆盖库存。它只读报告 CodeGraph 32 种独立 grammar、CodeGuard 十八份资产候选(ArkTS、C、C++、C#、Go、Java、JavaScript、Lua、Luau、Objective-C、Python、Rust、Solidity、TypeScript、TSX、Zig、Nix、Terraform)和零项已发行能力,不运行解析器;Python 已有源码可选构建中的局部 `lint` 兜底,结果不能视为通过。已绑定工作区的单文件反馈使用 [0.15.0 协议](../schemas/python-lint-feedback-v0.15.schema.json),并通过现有 work sync 保存 [0.1.0 确认观察](../schemas/python-syntax-confirmation-observation-v0.1.schema.json)。任务身份绑定工作区和源码范围;导入前核对当前源码 SHA-256 与固定 grammar。能力匹配的原生关闭仍未完成。C、C++、C#、Go、JavaScript、Lua、Luau、Rust 的随仓字节和上游许可证已固定,完成窄范围 Rust worker 解析验证,尚无公开 lint 路由或语言验收。ArkTS、Nix、Terraform 的来源、许可证、字节及 Rust 正反例也已固定,仅为候选,尚无公开 lint 路由或发行验收;见[局部验收](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md)。依赖提供的 Objective-C 与 Solidity 已固定原始和适配后字节、许可证及依赖包完整性,但仍未验收语言版本或公开 lint 路由;COBOL 超过现有加载器的 8 MiB 限额。 +可用 `codeguard grammar status --format=json` 查询独立的来源覆盖库存。它只读报告 CodeGraph 32 种独立 grammar、CodeGuard 二十二份资产候选(ArkTS、C、C++、C#、Go、Java、JavaScript、Lua、Luau、Objective-C、Python、Rust、Solidity、TypeScript、TSX、Zig、Nix、Terraform、R、Ruby、PHP、Kotlin)和零项已发行能力,不运行解析器;Python 已有源码可选构建中的局部 `lint` 兜底,结果不能视为通过。已绑定工作区的单文件反馈使用 [0.15.0 协议](../schemas/python-lint-feedback-v0.15.schema.json),并通过现有 work sync 保存 [0.1.0 确认观察](../schemas/python-syntax-confirmation-observation-v0.1.schema.json)。任务身份绑定工作区和源码范围;导入前核对当前源码 SHA-256 与固定 grammar。能力匹配的原生关闭仍未完成。C、C++、C#、Go、JavaScript、Lua、Luau、Rust 的随仓字节和上游许可证已固定,完成窄范围 Rust worker 解析验证,尚无公开 lint 路由或语言验收。ArkTS、Nix、Terraform 的来源、许可证、字节及 Rust 正反例也已固定,仅为候选,尚无公开 lint 路由或发行验收;见[局部验收](../tests/acceptance/arkts-nix-terraform-grammar-candidates.md)。依赖提供的 Objective-C 与 Solidity 已固定原始和适配后字节、许可证及依赖包完整性,但仍未验收语言版本或公开 lint 路由;COBOL 超过现有加载器的 8 MiB 限额。 + +R、Ruby、PHP、Kotlin 也已固定 CodeGraph 字节、许可证和 Rust 实测 ABI,并通过隔离 worker 的窄范围正反例;PHP 样例覆盖 HTML/PHP 混合内容,仍仅为未验收候选。Dart 来源 WASM 的外部 scanner 导入无法由当前 Rust worker 实例化,仍为缺口;见[局部验收](../tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md)。 由父进程控制解析工作进程,设置总截止时间、单文件输入上限、内存/进程限制及诊断数量上限。按需加载 grammar,不提供通用网络/文件系统导入;终止卡住的进程时保留其它模块的原生结果。宿主约束执行和 Rust MSRV 兼容性须测试,生产数值预算须经测量后确定,不编造性能承诺。 @@ -199,6 +201,7 @@ flowchart LR 缓存键包含源码内容、方言/语言画像、grammar 字节、解析运行时、查询/规则版本及相关范围/配置身份。取消、局部输出和未解析覆盖不能产生可复用的干净结果。资产替换使相关缓存和处置失效。按验证过的清单回滚语言包,保留历史观察,不根据删除缓存推断问题已解决。 + ## 6. 静态检测能力目录 [28 个检测族](../crates/codeguard-core/src/capability_dimensions.rs)避免将不同检查压成笼统 lint 结果。 diff --git a/grammars/kotlin/LICENSE b/grammars/kotlin/LICENSE new file mode 100644 index 00000000..77775637 --- /dev/null +++ b/grammars/kotlin/LICENSE @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2019 fwcd + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/grammars/kotlin/parser.wasm b/grammars/kotlin/parser.wasm new file mode 100644 index 00000000..8188ae26 Binary files /dev/null and b/grammars/kotlin/parser.wasm differ diff --git a/grammars/manifest.json b/grammars/manifest.json index 90b77101..e5d5b28d 100644 --- a/grammars/manifest.json +++ b/grammars/manifest.json @@ -366,6 +366,78 @@ "language_versions": [], "known_limitations": ["Rust loader and narrow fixtures passed; Terraform language versions, dialect corpus, native differential, isolation and release remain unqualified"], "release_status": "candidate_unvalidated" + }, + { + "language": "r", + "dialect": "r", + "grammar_repository": "https://github.com/r-lib/tree-sitter-r", + "grammar_commit": "e9944e9801595ad484f49be492daf0c4c81547ef", + "grammar_version": "v1.2.0", + "path": "r/parser.wasm", + "sha256": "2a8f5acd1c53d91e0ec5c01a6830d8ac7f5a7f96f0ac4b3768c016c8e9d07711", + "bytes": 481163, + "license": "r/LICENSE", + "license_sha256": "de2e49529f03d573bc3fa229dc83acfe22c63a5ad1766b289563edfd45b72dea", + "abi_version": 14, + "codegraph_runtime": "web-tree-sitter 0.25.3", + "codeguard_runtime_validation": "rust_loader_smoke_passed", + "language_versions": [], + "known_limitations": ["Rust loader and narrow fixtures passed; R language versions, dialect corpus, native differential, isolation and release remain unqualified"], + "release_status": "candidate_unvalidated" + }, + { + "language": "ruby", + "dialect": "ruby", + "grammar_repository": "https://github.com/tree-sitter/tree-sitter-ruby", + "grammar_commit": "71bd32fb7607035768799732addba884a37a6210", + "grammar_version": "v0.23.1", + "path": "ruby/parser.wasm", + "sha256": "4cb5a4b12870876ca864c1e92fe1f5cd47036b2adc083e9306488af88867dbb4", + "bytes": 2106097, + "license": "ruby/LICENSE", + "license_sha256": "ee006f02a3d856df282e409be2a86e24a65bb573a98b9c28343771141351bb6b", + "abi_version": 14, + "codegraph_runtime": "web-tree-sitter 0.25.3", + "codeguard_runtime_validation": "rust_loader_smoke_passed", + "language_versions": [], + "known_limitations": ["Rust loader and narrow fixtures passed; Ruby language versions, dialect corpus, native differential, isolation and release remain unqualified"], + "release_status": "candidate_unvalidated" + }, + { + "language": "php", + "dialect": "php", + "grammar_repository": "https://github.com/tree-sitter/tree-sitter-php", + "grammar_commit": "5b5627faaa290d89eb3d01b9bf47c3bb9e797dea", + "grammar_version": "v0.24.2-full-php", + "path": "php/parser.wasm", + "sha256": "6545a9a110bc878e26ed329950147e190c83da038bb17e999de646fe6c4d6c82", + "bytes": 1058082, + "license": "php/LICENSE", + "license_sha256": "664764fabf40c0b318e06324a5a12379092a2df25b8cbf2415f71bc0bb352346", + "abi_version": 15, + "codegraph_runtime": "web-tree-sitter 0.25.3", + "codeguard_runtime_validation": "rust_loader_smoke_passed", + "language_versions": [], + "known_limitations": ["Full PHP grammar Rust loader and narrow mixed HTML/PHP fixture passed; broader PHP versions, native differential, isolation hardening and release remain unqualified"], + "release_status": "candidate_unvalidated" + }, + { + "language": "kotlin", + "dialect": "kotlin", + "grammar_repository": "https://github.com/fwcd/tree-sitter-kotlin", + "grammar_commit": "e1a2d5ad1f61f5740677183cd4125bb071cd2f30", + "grammar_version": "0.3.8", + "path": "kotlin/parser.wasm", + "sha256": "c80c88867a589a1a0959bcea89de84b7e9684b3693b2cdb2944812458e62ff48", + "bytes": 4052313, + "license": "kotlin/LICENSE", + "license_sha256": "948495f61768f7de26bcc61113d8cd95f50bbc15adb678c28c941c6c8fcd5903", + "abi_version": 14, + "codegraph_runtime": "web-tree-sitter 0.25.3", + "codeguard_runtime_validation": "rust_loader_smoke_passed", + "language_versions": [], + "known_limitations": ["Rust loader and narrow fixtures passed; Kotlin language versions, dialect corpus, native differential, isolation and release remain unqualified"], + "release_status": "candidate_unvalidated" } ], "dependency_package_integrity": "tree-sitter-wasms@0.1.13 sha512-wT+cR6DwaIz80/vho3AvSF0N4txuNx/5bcRKoXouOfClpxh/qqrF4URNLQXbbt8MaAxeksZcZd1j8gcGjc+QxQ==", diff --git a/grammars/php/LICENSE b/grammars/php/LICENSE new file mode 100644 index 00000000..513857dd --- /dev/null +++ b/grammars/php/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2017 Josh Vera, GitHub +Copyright (c) 2019 Max Brunsfeld, Amaan Qureshi, Christian Frøystad, Caleb White + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/grammars/php/parser.wasm b/grammars/php/parser.wasm new file mode 100644 index 00000000..ca947d8b Binary files /dev/null and b/grammars/php/parser.wasm differ diff --git a/grammars/r/LICENSE b/grammars/r/LICENSE new file mode 100644 index 00000000..04e174fb --- /dev/null +++ b/grammars/r/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 tree-sitter-r authors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/grammars/r/parser.wasm b/grammars/r/parser.wasm new file mode 100644 index 00000000..3b1f3005 Binary files /dev/null and b/grammars/r/parser.wasm differ diff --git a/grammars/ruby/LICENSE b/grammars/ruby/LICENSE new file mode 100644 index 00000000..2a79f435 --- /dev/null +++ b/grammars/ruby/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2016 Rob Rix + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/grammars/ruby/parser.wasm b/grammars/ruby/parser.wasm new file mode 100644 index 00000000..a0ee0a85 Binary files /dev/null and b/grammars/ruby/parser.wasm differ diff --git a/openspec/changes/introduce-rust-codeguard-cli/tasks.md b/openspec/changes/introduce-rust-codeguard-cli/tasks.md index 6c6eea25..a6c8a2c1 100644 --- a/openspec/changes/introduce-rust-codeguard-cli/tasks.md +++ b/openspec/changes/introduce-rust-codeguard-cli/tasks.md @@ -1050,4 +1050,6 @@ TDD缺自动同步先RED。相关普通:build9、work sync15、next6,共30 14.19 性能子项进展:候选 worker 已改为仅校验所选固定 grammar 及相关许可证,避免每次单文件初检遍历全部 WASM;全量库存命令保持完整校验。选择接口先 RED 后通过 15 语种身份一致性测试,单次调试构建启动观察见[局部验收](../../../tests/acceptance/syntax-worker-selected-asset.md)。这不是正式性能评测;该阶段仍为 15/32 候选和 0 份发行验收。 -14.19 后续增量:ArkTS、Nix、Terraform 三份 CodeGraph 随仓 WASM 已固定上游提交、许可证、字节和真实 ABI;ArkTS/Terraform 预编译 npm 包另固定完整性并核对包内字节。Rust 离线加载、窄范围正反例及隔离 worker 候选状态通过,见[局部验收](../../../tests/acceptance/arkts-nix-terraform-grammar-candidates.md)。目前 18/32 候选、14 份未入候选、已发行验收 0;公开原生优先 lint 路由和逐语言精度验收仍缺,14.1 与 14.19 保持未完成。 +14.19 后续增量:ArkTS、Nix、Terraform 三份 CodeGraph 随仓 WASM 已固定上游提交、许可证、字节和真实 ABI;ArkTS/Terraform 预编译 npm 包另固定完整性并核对包内字节。Rust 离线加载、窄范围正反例及隔离 worker 候选状态通过,见[局部验收](../../../tests/acceptance/arkts-nix-terraform-grammar-candidates.md)。该阶段 18/32 候选、14 份未入候选、已发行验收 0;公开原生优先 lint 路由和逐语言精度验收仍缺,14.1 与 14.19 保持未完成。 + +14.19 再后续增量:R、Ruby、PHP、Kotlin 四份 CodeGraph 随仓 WASM 已固定上游提交、许可证、字节、Rust 实测 ABI,经窄范围正反例和隔离 worker 验证;PHP 正例包括 HTML/PHP 混合源码。累计 22/32 候选、10 份未入候选、已发行验收仍为 0。Dart 来源 WASM 的外部 scanner 导入使当前 Rust worker 无法实例化,`grammar status` 显示具体缺口;不得以空 scanner 代替语法功能。见[本批局部验收](../../../tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md)。公开原生优先路由、逐语言精度验收和发布仍缺,14.1、14.19 保持未完成。 diff --git a/tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md b/tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md new file mode 100644 index 00000000..82632804 --- /dev/null +++ b/tests/acceptance/r-ruby-php-kotlin-grammar-candidates.md @@ -0,0 +1,20 @@ +# R、Ruby、PHP、Kotlin grammar 候选局部验收 + +日期:2026-09-29。固定 CodeGraph 来源:`1072f82ce24db3d133258d30165cef6b74d108b2`。四份随仓 WASM 与[来源库存](../../grammars/codegraph-coverage.json)逐字节一致,许可证和上游版本固定在[候选资产清单](../../grammars/manifest.json)。 + +| 语种 | 固定上游来源 | WASM SHA-256 | 许可证 SHA-256 | Rust 实测 ABI | +| --- | --- | --- | --- | --- | +| R | `r-lib/tree-sitter-r@e9944e9801595ad484f49be492daf0c4c81547ef`,`v1.2.0` | `2a8f5acd1c53d91e0ec5c01a6830d8ac7f5a7f96f0ac4b3768c016c8e9d07711` | `de2e49529f03d573bc3fa229dc83acfe22c63a5ad1766b289563edfd45b72dea` | 14 | +| Ruby | `tree-sitter/tree-sitter-ruby@71bd32fb7607035768799732addba884a37a6210`,`v0.23.1` | `4cb5a4b12870876ca864c1e92fe1f5cd47036b2adc083e9306488af88867dbb4` | `ee006f02a3d856df282e409be2a86e24a65bb573a98b9c28343771141351bb6b` | 14 | +| PHP | `tree-sitter/tree-sitter-php@5b5627faaa290d89eb3d01b9bf47c3bb9e797dea`,`v0.24.2-full-php` | `6545a9a110bc878e26ed329950147e190c83da038bb17e999de646fe6c4d6c82` | `664764fabf40c0b318e06324a5a12379092a2df25b8cbf2415f71bc0bb352346` | 15 | +| Kotlin | `fwcd/tree-sitter-kotlin@e1a2d5ad1f61f5740677183cd4125bb071cd2f30`,`0.3.8` | `c80c88867a589a1a0959bcea89de84b7e9684b3693b2cdb2944812458e62ff48` | `948495f61768f7de26bcc61113d8cd95f50bbc15adb678c28c941c6c8fcd5903` | 14 | + +四份 grammar 经 Rust `WasmStore` 离线加载,基础合法样例无恢复错误、损坏样例出现恢复错误;PHP 的合法样例还覆盖 HTML 与 PHP 混合内容,核对使用的是完整 PHP grammar。隔离 worker 将这些样例标为 `incomplete`、`grammar_qualified=false`。测试先将清单期望由 18 改为 22 而失败,随后加入固定资产和校验逻辑后通过。 + +Dart 仍未接入。CodeGraph 固定来源中的 Dart WASM 旧 `dylink` 元数据可作有界转换,但 Rust `WasmStore` 随后拒绝实例化,错误为 `invalid import 'tree_sitter_dart_external_scanner_create'`。外部 scanner 是语法的一部分,不能用空实现让测试假通过。`grammar status` 将其标为 `rust_worker_external_scanner_import`;需要固定可再分发的重建资产或等效、经语料验证的 scanner 适配,再重新做 ABI 与解析验收。 + +实际源码构建的 `codeguard grammar status --format=json` 返回退出码 3:32 种来源 grammar、30 份随仓 WASM、22 份候选、0 项已发行;Dart 为 `not_integrated`,`parser_capability=unverified`、`gate_effect=none`、`delivery_decision=not_evaluated`。 + +本次 `cargo test --locked --workspace --all-features` 退出 0:182 组、1142 通过、0 失败、106 忽略;忽略的原生工具用例不算验收。全目标 Clippy、fmt、OpenSpec strict、Draft 2020-12 清单 schema 及 `git diff --check` 均通过。 + +尚缺:逐语言版本/方言语料、原生工具对照、公开原生优先 lint 路由、任务及宿主反馈、资源预算和发行包实装。四份只是候选,不等于已发行语法检查能力。