From 083939c16dd7c75701eec1f710bf2d4ce3299b47 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Sat, 7 Nov 2026 11:06:50 +0000 Subject: [PATCH] Restore valid JSX analysis and report all-parse-error coverage honestly --- Cargo.lock | 4 +- crates/pons-cli/tests/coverage.rs | 46 ++++++++++++++++++++ crates/pons-core/Cargo.toml | 5 ++- crates/pons-core/src/engine.rs | 10 ++++- crates/pons-core/src/lang.rs | 3 +- crates/pons-core/src/report/validate.rs | 9 +++- crates/pons-core/tests/parser_adversarial.rs | 31 +++++++++++++ docs/PLAN.adoc | 14 +++++- docs/echo-362-verification.adoc | 46 ++++++++++++++++++++ 9 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 docs/echo-362-verification.adoc diff --git a/Cargo.lock b/Cargo.lock index d2fbec77..b028c488 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -996,9 +996,9 @@ dependencies = [ [[package]] name = "tree-sitter-javascript" -version = "0.25.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68204f2abc0627a90bdf06e605f5c470aa26fdcb2081ea553a04bdad756693f5" +checksum = "bf40bf599e0416c16c125c3cec10ee5ddc7d1bb8b0c60fa5c4de249ad34dc1b1" dependencies = [ "cc", "tree-sitter-language", diff --git a/crates/pons-cli/tests/coverage.rs b/crates/pons-cli/tests/coverage.rs index 0d884df7..4b31fa0a 100644 --- a/crates/pons-cli/tests/coverage.rs +++ b/crates/pons-cli/tests/coverage.rs @@ -75,6 +75,52 @@ fn inventory_accounts_for_supported_unsupported_excluded_and_parse_error() { } assert_eq!(v["scanned"]["coverage_status"], "partial"); } + +#[test] +fn only_parse_errors_are_partial_coverage_not_no_applicable_input() { + let t = Temp::new(); + fs::write(t.0.join("invalid.jsx"), "const view = ;").unwrap(); + let out = t.scan(&["--format", "json", "--fail-on-skips"]); + assert_eq!(out.status.code(), Some(2)); + let mut report: Value = serde_json::from_slice(&out.stdout).unwrap(); + assert_eq!(report["scanned"]["files"], 0); + assert_eq!(report["scanned"]["coverage_status"], "partial"); + assert_eq!(report["scanned"]["inventory"][0]["outcome"], "parse-error"); + assert!(pons_core::report::validate::validate(&report.to_string()).is_ok()); + report["scanned"]["coverage_status"] = "no-applicable-input".into(); + assert!(pons_core::report::validate::validate(&report.to_string()).is_err()); +} + +#[test] +fn jsx_keyword_attributes_reach_analysis_and_validate() { + let t = Temp::new(); + fs::write( + t.0.join("filter.jsx"), + r#"const view = ;"#, + ) + .unwrap(); + let out = t.scan(&[ + "--format", + "json", + "--fail-on-skips", + "--require-language", + "javascript", + ]); + assert_eq!( + out.status.code(), + Some(0), + "{}", + String::from_utf8_lossy(&out.stderr) + ); + let report: Value = serde_json::from_slice(&out.stdout).unwrap(); + assert_eq!(report["scanned"]["files"], 1); + assert_eq!( + report["scanned"]["coverage_status"], + "complete-within-policy" + ); + assert!(report["scanned"]["skipped"].as_array().unwrap().is_empty()); + assert!(pons_core::report::validate::validate(&report.to_string()).is_ok()); +} #[test] fn absent_required_language_cannot_be_suppressed() { let t = Temp::new(); diff --git a/crates/pons-core/Cargo.toml b/crates/pons-core/Cargo.toml index e4638b9b..54b573a1 100644 --- a/crates/pons-core/Cargo.toml +++ b/crates/pons-core/Cargo.toml @@ -14,7 +14,10 @@ toml.workspace = true serde = { workspace = true } serde_json = { workspace = true } tree-sitter = "=0.27.0" -tree-sitter-javascript = "=0.25.0" +# 0.25.0 rejects legal JSX keyword attributes such as SVG's `in`. +# Keep the compatible grammar until upstream fixes that regression; the +# parser_adversarial corpus protects both keyword attributes and rejection. +tree-sitter-javascript = "=0.23.1" tree-sitter-python = "=0.25.0" tree-sitter-rust = "=0.24.2" tree-sitter-typescript = "=0.23.2" diff --git a/crates/pons-core/src/engine.rs b/crates/pons-core/src/engine.rs index f49364b4..eb058875 100644 --- a/crates/pons-core/src/engine.rs +++ b/crates/pons-core/src/engine.rs @@ -129,7 +129,15 @@ pub struct ScanReport { impl ScanReport { pub fn coverage_status(&self) -> &'static str { - if self.files_scanned == 0 { + if self.files_scanned == 0 + && self.coverage_failures.is_empty() + && self.inventory.iter().all(|entry| { + matches!( + entry.outcome, + Outcome::Unsupported | Outcome::ExcludedByPolicy + ) + }) + { "no-applicable-input" } else if !self.skipped.is_empty() || !self.coverage_failures.is_empty() diff --git a/crates/pons-core/src/lang.rs b/crates/pons-core/src/lang.rs index 1b745cfe..dd1e5ea4 100644 --- a/crates/pons-core/src/lang.rs +++ b/crates/pons-core/src/lang.rs @@ -45,7 +45,8 @@ impl Lang { pub fn parser_version(self) -> &'static str { match self { - Lang::Python | Lang::JavaScript => "0.25.0", + Lang::Python => "0.25.0", + Lang::JavaScript => "0.23.1", Lang::TypeScript | Lang::Tsx => "0.23.2", Lang::Rust => "0.24.2", Lang::Php => "0.25.1", diff --git a/crates/pons-core/src/report/validate.rs b/crates/pons-core/src/report/validate.rs index 2c6063f9..096f5cfe 100644 --- a/crates/pons-core/src/report/validate.rs +++ b/crates/pons-core/src/report/validate.rs @@ -158,7 +158,14 @@ fn validate_value(v: Value) -> Result { ); } } - let status = if analysed == 0 { + let status = if analysed == 0 + && failures.is_empty() + && inventory.iter().all(|entry| { + matches!( + entry.outcome, + Outcome::Unsupported | Outcome::ExcludedByPolicy + ) + }) { "no-applicable-input" } else if !skipped.is_empty() || !failures.is_empty() diff --git a/crates/pons-core/tests/parser_adversarial.rs b/crates/pons-core/tests/parser_adversarial.rs index a0f5f834..7a1ff737 100644 --- a/crates/pons-core/tests/parser_adversarial.rs +++ b/crates/pons-core/tests/parser_adversarial.rs @@ -1,6 +1,37 @@ // SPDX-License-Identifier: MPL-2.0 //! Deterministic bounded mutation smoke corpus, not a claim of exhaustive fuzzing. use pons_core::{lang::Lang, parse, source::SourceFile}; + +#[test] +fn jsx_keyword_attributes_are_valid_javascript() { + // Reduced from echo-types' warrant debugger. `in` is an SVG attribute, + // not JavaScript's binary operator. The 0.25.0 grammar rejects it. + for text in [ + r#"const view = ;"#, + r#"const view = ;"#, + ] { + let source = SourceFile { + path: "keyword-attributes.jsx".into(), + lang: Lang::JavaScript, + text: text.into(), + transcoded: false, + }; + let tree = parse::parse(&source).expect("legal JSX keyword attributes must parse"); + assert!(!tree.root_node().has_error()); + } +} + +#[test] +fn malformed_jsx_is_not_accepted_as_a_parser_fallback() { + let source = SourceFile { + path: "invalid.jsx".into(), + lang: Lang::JavaScript, + text: r#"const view = ;"#.into(), + transcoded: false, + }; + assert!(parse::parse(&source).is_err()); +} + #[test] fn fixed_seed_parser_mutations() { let mut seed = 0x504f4e53u64; diff --git a/docs/PLAN.adoc b/docs/PLAN.adoc index c77ad3b3..a21deea8 100644 --- a/docs/PLAN.adoc +++ b/docs/PLAN.adoc @@ -368,7 +368,7 @@ truth thereafter. | crate | purpose | pin (fill at M0) | `tree-sitter` | core parsing/query API | `=0.27.0` | `tree-sitter-python` | Python grammar (T0 + T1 + T2) | `=0.25.0` -| `tree-sitter-javascript` | JS grammar (T0) | `=0.25.0` +| `tree-sitter-javascript` | JS/JSX grammar (T0) | `=0.23.1` (compatibility pin below) | `tree-sitter-typescript` | TS + TSX grammars (T0) | `=0.23.2` | `tree-sitter-rust` | Rust grammar (T0) | `=0.24.2` | `serde` / `serde_json` | JSON + SARIF serialisation | `=1.0.229` / `=1.0.151` (M1+) @@ -378,6 +378,18 @@ truth thereafter. | `ignore` / `walkdir` | file discovery + `.ponsignore` | `=0.4.33` (ignore, direct); `walkdir` `2.5.0` pulled in transitively, not a direct dependency |=== +Compatibility correction, 2026-11-07 (echo-types#362): JavaScript grammar +0.25.0 rejects valid JSX keyword attribute names, including SVG +``. Pin 0.23.1, whose JavaScript/JSX +grammar accepts that syntax, and retain the separate TypeScript/TSX mapping. +The source is not rewritten and recovered error trees are still rejected. +Parser and CLI regressions check valid keyword attributes, malformed JSX, +real analysis and report validation. Revisit newer grammar releases only +when these and the complete existing corpus pass; support for syntax unique +to a newer grammar is not claimed by this compatibility pin. Parser receipts +record the actual selected version. A supported source that fails parsing +has partial coverage even when no file was analysed; it is not no-applicable-input. + Resolved 2026-09-14 via `cargo add tree-sitter tree-sitter-python tree-sitter-javascript tree-sitter-typescript tree-sitter-rust -p pons-core` against the real workspace; confirmed no duplicate `tree-sitter` core-version diff --git a/docs/echo-362-verification.adoc b/docs/echo-362-verification.adoc new file mode 100644 index 00000000..41fcff01 --- /dev/null +++ b/docs/echo-362-verification.adoc @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: CC-BY-SA-4.0 += Echo Types scanner follow-up — 7 November 2026 + +== Scope and correction + +The baseline is PONS `b9ab55c6973514a731c7659a2fbee21b5037b1ef`. +The source reproducer is echo-types `ebde9ac4e1a9f115b441c642c82aced1316c5983`, +`docs/echo-types/prototypes/warrant_debugger_prototype.jsx`. +Its valid SVG keyword attribute `in="SourceGraphic"` fails with JavaScript +grammar 0.25.0. The compatible 0.23.1 grammar parses that file without source +rewriting or accepting recovered syntax-error trees. This is a deliberate +compatibility pin, not a claim of support for newer grammar-only syntax. +The shared tree-sitter core and TypeScript/TSX grammar remain unchanged. + +When every supported source fails parsing, the report now says `partial`, +not `no-applicable-input`. Report validation independently rejects the old +misclassification. Unsupported Agda inputs remain explicitly unsupported; +this repair does not add an Agda analyser or constitute browser execution. + +== Executed local evidence + +Rust 1.99.1 on a case-sensitive Linux filesystem: + +* `cargo test --workspace --locked`: 255 test executions passed. +* `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed. +* The exact JSX source above: one file analysed, zero findings, zero skips, + complete-within-policy for that single-file invocation, exit 0, with + `--no-speculative --fail-on error --fail-on-skips --require-language javascript`. +* New parser controls accept JSX keyword attributes and reject malformed JSX. + CLI controls check real analysis, partial coverage on parsing failure, + report validity and rejection of a forged no-applicable-input status. + +Hosted CI and review results are recorded by the change's pull request; +these local results are not a claim that those checks already completed. + +== Formal verification plan and trust boundary + +Creusot with Pearlite contracts: `OPEN`, not run for this repair. +Verus: `OPEN`, not run for this repair. The Rust regressions above are tests, +not formal proofs of parser correctness or the coverage classification. +Pearlite is Creusot's specification language, not a third verifier. + +The third-party grammar's JavaScript/JSX semantics remain a dependency +assumption (`ASSUMED`), with its exact version and lockfile checksum pinned. +No third-party code or licence was rewritten. A future grammar update must +pass these regressions and the complete existing suite before adoption.