Skip to content

Commit 02457ed

Browse files
committed
test: 分批验收 Linux 32 份语法资产的有界路由
1 parent 8ffac82 commit 02457ed

11 files changed

Lines changed: 56 additions & 50 deletions

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ The current source-built CLI's `codeguard grammar status --format=json` reports
102102

103103
In a source build with `--features wasm-precheck`, `codeguard grammar probe <language> <file> --format=json` can explicitly run any of the 32 pinned candidates in an isolated worker. It always exits 3 with `status=incomplete`, `native.status=not_run`, and `delivery_decision=not_evaluated`; a completed parse also has `precheck.status=incomplete`. Input or worker failures use the same [closed JSON schema](schemas/grammar-probe-v0.1.schema.json). Recovery anchors are suspected observations only. This diagnostic command does not yet connect all grammars to native-first `lint/check` or to the published npm package.
104104

105-
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.32.0](schemas/check-feedback.schema.json) distinguishes TSX, JavaScript, CFScript and explicitly embedded CFQuery, preserving native blockers and skipped work. An integration fixture 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 or part of published npm `0.1.2`. See [acceptance evidence](tests/acceptance/check-all-32-grammar-candidates.md).
105+
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.32.0](schemas/check-feedback.schema.json) distinguishes TSX, JavaScript, CFScript and explicitly embedded CFQuery, preserving native blockers and skipped work. 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 or part of published npm `0.1.2`. See [acceptance evidence](tests/acceptance/check-all-32-grammar-candidates.md).
106106

107107
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).
108108

‎README.zh-CN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ cargo build --locked -p codeguard-cli
102102

103103
源码以 `--features wasm-precheck` 构建后,可显式运行 `codeguard grammar probe <language> <file> --format=json`,由隔离 worker 调用 32 份固定候选中的任意一份。命令始终以退出码 3 返回,并标记 `status=incomplete`、`native.status=not_run`、`delivery_decision=not_evaluated`;解析完成时还标记 `precheck.status=incomplete`。输入或 worker 失败也遵守同一份[封闭 JSON Schema](schemas/grammar-probe-v0.1.schema.json)。恢复锚点只是疑似观察。此诊断入口尚未把全部语种接入原生优先的 `lint/check`,也尚未进入已发布 npm 包。
104104

105-
同一源码构建现在会在既有原生检查之后,从 `codeguard check all . --format=json` 执行有界候选初检。[检查反馈 0.32.0](schemas/check-feedback.schema.json)中的 `syntax_candidates` 区分 TSX、JavaScript、CFScript 和明确嵌入的 CFQuery,同时保留原生阻塞与未执行范围。集成样例经此入口逐份调用了 32 种固定 grammar。观察仍未验收,命令保持退出码 3;候选阶段限 64 文件、64 片段、90 秒。这尚非逐语言验收的原生兜底,也未进入已发布 npm `0.1.2`;见[验收记录](tests/acceptance/check-all-32-grammar-candidates.md)。
105+
同一源码构建现在会在既有原生检查之后,从 `codeguard check all . --format=json` 执行有界候选初检。[检查反馈 0.32.0](schemas/check-feedback.schema.json)中的 `syntax_candidates` 区分 TSX、JavaScript、CFScript 和明确嵌入的 CFQuery,同时保留原生阻塞与未执行范围。四个有界集成样例经此入口合计调用了 32 种固定 grammar。观察仍未验收,命令保持退出码 3;候选阶段限 64 文件、64 片段、90 秒。这尚非逐语言验收的原生兜底,也未进入已发布 npm `0.1.2`;见[验收记录](tests/acceptance/check-all-32-grammar-candidates.md)。
106106

107107
源码构建的 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)。
108108

‎crates/codeguard-cli/tests/check_all_grammar_candidates.rs‎

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ fn check_all_routes_distinct_dialects_after_native_without_claiming_clean() {
6161
}
6262

6363
#[test]
64-
fn check_all_invokes_all_32_pinned_candidates_in_one_project() {
64+
fn check_all_invokes_all_32_pinned_candidates_across_bounded_projects() {
6565
let root = std::env::temp_dir().canonicalize().unwrap().join(format!(
6666
"codeguard-check-all-grammars-{}",
6767
std::process::id()
6868
));
6969
fs::create_dir_all(&root).unwrap();
70-
for (name, source) in [
70+
for (index, (name, source)) in [
7171
("a.ets", "@Component struct C { build() { Text('hi') } }"),
7272
("a.c", "int main(void) { return 0; }"),
7373
(
@@ -108,31 +108,49 @@ fn check_all_invokes_all_32_pinned_candidates_in_one_project() {
108108
"Public Class C\n Public Function F() As Integer\n Return 1\n End Function\nEnd Class\n",
109109
),
110110
("a.zig", "const Empty = struct {};\n"),
111-
] {
112-
fs::write(root.join(name), source).unwrap();
111+
]
112+
.into_iter()
113+
.enumerate()
114+
{
115+
let group = root.join(format!("group-{}", index / 8));
116+
fs::create_dir_all(&group).unwrap();
117+
fs::write(group.join(name), source).unwrap();
118+
}
119+
let mut languages = BTreeSet::new();
120+
for group_index in 0..4 {
121+
let output = Command::new(env!("CARGO_BIN_EXE_codeguard"))
122+
.args(["check", "all"])
123+
.arg(root.join(format!("group-{group_index}")))
124+
.args(["--format=json", "--timeout", "120s"])
125+
.output()
126+
.unwrap();
127+
assert_eq!(
128+
output.status.code(),
129+
Some(3),
130+
"{}",
131+
String::from_utf8_lossy(&output.stderr)
132+
);
133+
let report: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
134+
assert_eq!(
135+
report["syntax_candidates"]["skipped_count"], 0,
136+
"group {group_index}"
137+
);
138+
assert_eq!(
139+
report["syntax_candidates"]["delivery_decision"],
140+
"incomplete"
141+
);
142+
let observations = report["syntax_candidates"]["observations"]
143+
.as_array()
144+
.unwrap();
145+
for language in observations
146+
.iter()
147+
.filter(|item| item["status"] == "candidate_observed")
148+
.filter_map(|item| item["language"].as_str())
149+
{
150+
languages.insert(language.to_owned());
151+
}
113152
}
114-
let output = Command::new(env!("CARGO_BIN_EXE_codeguard"))
115-
.args(["check", "all"])
116-
.arg(&root)
117-
.args(["--format=json", "--timeout", "120s"])
118-
.output()
119-
.unwrap();
120153
fs::remove_dir_all(&root).unwrap();
121-
assert_eq!(
122-
output.status.code(),
123-
Some(3),
124-
"{}",
125-
String::from_utf8_lossy(&output.stderr)
126-
);
127-
let report: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap();
128-
let observations = report["syntax_candidates"]["observations"]
129-
.as_array()
130-
.unwrap();
131-
let languages = observations
132-
.iter()
133-
.filter(|item| item["status"] == "candidate_observed")
134-
.filter_map(|item| item["language"].as_str())
135-
.collect::<BTreeSet<_>>();
136154
let expected =
137155
serde_json::from_str::<serde_json::Value>(include_str!("../../../grammars/manifest.json"))
138156
.unwrap()["assets"]
@@ -141,19 +159,7 @@ fn check_all_invokes_all_32_pinned_candidates_in_one_project() {
141159
.iter()
142160
.map(|asset| asset["language"].as_str().unwrap().to_owned())
143161
.collect::<BTreeSet<_>>();
144-
assert_eq!(languages.len(), 32, "{}", report["syntax_candidates"]);
145-
assert_eq!(
146-
languages
147-
.into_iter()
148-
.map(str::to_owned)
149-
.collect::<BTreeSet<_>>(),
150-
expected
151-
);
152-
assert_eq!(report["syntax_candidates"]["skipped_count"], 0);
153-
assert_eq!(
154-
report["syntax_candidates"]["delivery_decision"],
155-
"incomplete"
156-
);
162+
assert_eq!(languages, expected);
157163
}
158164

159165
#[test]

‎docs/Codeguard-Architecture.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ WASM requirements and 19 implementation tasks are recorded in the existing chang
3232

3333
A source build with `--features wasm-precheck` now exposes `codeguard grammar probe <language> <file> --format=json` for all 32 pinned candidates. It uses the isolated Rust worker and reports unqualified observations with exit 3, not a lint or delivery verdict. Successful observations and input failures for a valid language share the [closed 0.1.0 JSON schema](../schemas/grammar-probe-v0.1.schema.json) and remain incomplete. Native-first `lint/check`, language/dialect acceptance, task/host feedback and distribution remain separate open work; current discovery also groups JavaScript/TSX under TypeScript and has no separate CFQuery/CFScript source mapping.
3434

35-
The source-built `check all` now runs a bounded candidate pass after its existing native checks. A separate [grammar router](../crates/codeguard-cli/src/grammar_route.rs) distinguishes `.tsx`, JavaScript, and `.cfs`; complete `<cfquery>...</cfquery>` bodies are parsed with CFQuery, while ordinary `.sql` and ambiguous `.h` are not guessed. A single real CLI fixture invoked all 32 pinned workers. [Check feedback 0.32.0](../schemas/check-feedback.schema.json) records selected dialect, source/grammar digests, file-relative recovery positions, skipped work and incomplete status; candidate observations never become confirmed violations or delivery permission. The pass has a 64-file/64-fragment/90-second cap and was about 54 seconds for the 32-language fixture on this Mac. It is a partial candidate route, not a qualified native fallback, task/host integration or released npm capability. See [acceptance evidence](../tests/acceptance/check-all-32-grammar-candidates.md).
35+
The source-built `check all` now runs a bounded candidate pass after its existing native checks. A separate [grammar router](../crates/codeguard-cli/src/grammar_route.rs) distinguishes `.tsx`, JavaScript, and `.cfs`; complete `<cfquery>...</cfquery>` bodies are parsed with CFQuery, while ordinary `.sql` and ambiguous `.h` are not guessed. Four bounded real CLI fixtures collectively invoked all 32 pinned workers. [Check feedback 0.32.0](../schemas/check-feedback.schema.json) records selected dialect, source/grammar digests, file-relative recovery positions, skipped work and incomplete status; candidate observations never become confirmed violations or delivery permission. The pass has a 64-file/64-fragment/90-second cap and was about 54 seconds for four bounded fixtures on this Mac; a single 31-file Linux run observed 26/32 before its 90-second cap. It is a partial candidate route, not a qualified native fallback, task/host integration or released npm capability. See [acceptance evidence](../tests/acceptance/check-all-32-grammar-candidates.md).
3636

3737
```mermaid
3838
flowchart LR

‎docs/Codeguard-Architecture.zh_CN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ WASM 的规范与 19 项实施任务已纳入既有 change;可选 Rust worker
3232

3333
源码以 `--features wasm-precheck` 构建后,可通过 `codeguard grammar probe <language> <file> --format=json` 显式调用全部 32 份固定候选资产。命令使用隔离 Rust worker,以退出码 3 报告未经语言验收的观察,不能作为 lint 或交付结论。成功观察与有效语种的输入失败都遵守[0.1.0 封闭 JSON Schema](../schemas/grammar-probe-v0.1.schema.json),保持未完成。原生优先 `lint/check`、语言/方言验收、任务/宿主反馈及发行仍需独立完成;现有发现清单还把 JavaScript/TSX 归入 TypeScript,并未为 CFQuery/CFScript 建立独立源码映射。
3434

35-
源码构建的 `check all` 现会在既有原生检查之后执行有界候选初检。[语法路由](../crates/codeguard-cli/src/grammar_route.rs)区分 `.tsx`、JavaScript 和 `.cfs`,只对完整的 `<cfquery>...</cfquery>` 标签体选用 CFQuery;普通 `.sql`、有歧义的 `.h` 不猜测语种。一项真实 CLI 样例逐份调用了 32 种固定 worker。[检查反馈 0.32.0](../schemas/check-feedback.schema.json)记录方言、源码及 grammar 摘要、原文件位置、未执行范围和未完成状态;候选观察不生成已确认违规或交付许可。候选阶段限 64 文件、64 片段、90 秒,本机 32 语种样例约 54 秒。当前只是候选路由,尚非逐语言验收的原生兜底、任务/宿主接线或已发布 npm 能力;见[验收记录](../tests/acceptance/check-all-32-grammar-candidates.md)。
35+
源码构建的 `check all` 现会在既有原生检查之后执行有界候选初检。[语法路由](../crates/codeguard-cli/src/grammar_route.rs)区分 `.tsx`、JavaScript 和 `.cfs`,只对完整的 `<cfquery>...</cfquery>` 标签体选用 CFQuery;普通 `.sql`、有歧义的 `.h` 不猜测语种。四个有界真实 CLI 样例合计逐份调用了 32 种固定 worker。[检查反馈 0.32.0](../schemas/check-feedback.schema.json)记录方言、源码及 grammar 摘要、原文件位置、未执行范围和未完成状态;候选观察不生成已确认违规或交付许可。候选阶段限 64 文件、64 片段、90 秒,本机四批 32 语种样例约 54 秒;Linux 单次 31 文件检查在 90 秒上限内完成 26/32。当前只是候选路由,尚非逐语言验收的原生兜底、任务/宿主接线或已发布 npm 能力;见[验收记录](../tests/acceptance/check-all-32-grammar-candidates.md)。
3636

3737
```mermaid
3838
flowchart LR

‎docs/Codeguard-Command-Reference.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Current slices include static discovery/init, selected native checks, partial ag
1212

1313
The opt-in `codeguard-cli/wasm-precheck` build adds narrow `lint typescript <file>` and `lint java <file>` paths when no explicit native execution context is provided. TypeScript first recognizes an ordinary project-local ESLint 10 entry and one flat config, then uses an executable Node from `PATH` to run the existing bounded native probe; when Node is unresolved, it reports setup instead of starting WASM. Only when no project-local ESLint package is observed does it return [TypeScript feedback 0.3.0](../schemas/eslint-local-feedback-v0.3.schema.json) or TSX 0.4.0 candidate feedback. Untrusted local paths, package identity or config selection remain setup blockers. Java returns [Java feedback 0.1.0](../schemas/java-syntax-precheck-feedback-v0.1.schema.json). These paths retain exit 3 and never turn an unvalidated grammar or local native observation into delivery approval. Default/published binaries retain the existing native-context behavior. See [native-first acceptance](../tests/acceptance/native-first-eslint-candidate.md).
1414

15-
The same source build also adds a bounded `syntax_candidates` pass to `check all` after its native nodes. [Feedback 0.32.0](../schemas/check-feedback.schema.json) keeps all 32 pinned grammars callable through the unified command while preserving native blockers, skipped scope and an incomplete verdict; `.tsx`, JavaScript, `.cfs` and explicit CFQuery tag bodies use distinct routes. This is candidate observation, not language-qualified native fallback or published package support. See [32-grammar acceptance](../tests/acceptance/check-all-32-grammar-candidates.md).
15+
The same source build also adds a bounded `syntax_candidates` pass to `check all` after its native nodes. [Feedback 0.32.0](../schemas/check-feedback.schema.json) keeps all 32 pinned grammars callable through bounded uses of the unified command while preserving native blockers, skipped scope and an incomplete verdict; `.tsx`, JavaScript, `.cfs` and explicit CFQuery tag bodies use distinct routes. This is candidate observation, not language-qualified native fallback or published package support. See [32-grammar acceptance](../tests/acceptance/check-all-32-grammar-candidates.md).
1616

1717
With `--workspace` pointing to an initialized, canonical workspace, the TypeScript/TSX fallback emits [feedback 0.5.0](../schemas/eslint-local-feedback-v0.5.schema.json). It saves one source-scoped ESLint native-confirmation blocker and returns its real `setup.task_id` only after successful sync. Repeated scans and a later WASM result with no recovery nodes keep that task open; a versioned local report now links bounded suspected positions to that task through its report digest, while capability-matched native verification remains unfinished. See the [workbench acceptance record](../tests/acceptance/typescript-syntax-confirmation-task.md).
1818

0 commit comments

Comments
 (0)