Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ concurrency:
cancel-in-progress: true

jobs:
windows:
name: Windows portability
runs-on: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: toolchain
run: |
rustup toolchain install
rustc --version
- name: fmt
run: cargo fmt --check
- name: clippy
run: cargo clippy --workspace --all-targets --locked -- -D warnings
- name: test
run: cargo test --workspace --locked

check:
# The job's display name is the name of its status check. It is spelled
# out rather than left to default to the job id, so the check is named
Expand Down Expand Up @@ -48,6 +67,8 @@ jobs:
run: cargo test --workspace
- name: build
run: cargo build --release
- name: Pinned grammar regeneration
run: bash scripts/check-grammar-generation.sh
- name: e2e
run: bash tests/e2e.sh
- name: e2e non-vacuity (stub binary must fail the suite)
Expand Down
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ members = [
"crates/pons-rules",
"crates/pons-cli",
]
exclude = ["vendor/tree-sitter-javascript"]

[patch.crates-io]
tree-sitter-javascript = { path = "vendor/tree-sitter-javascript" }
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved

[workspace.package]
edition = "2021"
Expand Down
8 changes: 8 additions & 0 deletions ci/json-ratchet.kyaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
"deferred/rookie-fixtures/localisation-placeholder-drift/positive/case/fra.json",
],
declared_non_canonical: [
{
paths: [
"vendor/tree-sitter-javascript/src/grammar.json",
"vendor/tree-sitter-javascript/src/node-types.json",
"vendor/tree-sitter-javascript/tree-sitter.json",
],
reason: "Pinned upstream tree-sitter metadata and standard generated grammar output, with the required final LF on generated JSON. Preserve upstream metadata and the documented reproducible generation chain; provenance and regeneration are recorded in vendor/tree-sitter-javascript/PATCHES.adoc. I-JSON validity remains enforced; no JCS-canonicality claim is made.",
},
{
paths: [
".github/label-classifier.json",
Expand Down
33 changes: 33 additions & 0 deletions crates/pons-cli/tests/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ fn no_input_is_not_success_even_without_strict_flag() {
let out = t.scan(&["--format", format]);
assert_eq!(out.status.code(), Some(2));
assert!(String::from_utf8_lossy(&out.stdout).contains("no-applicable-input"));
if format == "sarif" {
let report: Value = serde_json::from_slice(&out.stdout).unwrap();
assert_eq!(
report["runs"][0]["invocations"][0]["executionSuccessful"],
false
);
}
}
}
#[test]
Expand Down Expand Up @@ -87,8 +94,34 @@ fn only_parse_errors_are_partial_coverage_not_no_applicable_input() {
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());
let mut frozen = report.clone();
frozen["schema_version"] = "0.4.0".into();
frozen["scanned"]["coverage_status"] = "no-applicable-input".into();
frozen["evidence_contract"]["execution_outcome"] = "no-applicable-input".into();
let counts = frozen["counts"].as_object_mut().unwrap();
counts.remove("actionable");
counts.remove("demoted_speculative");
let validated = pons_core::report::validate::validate(&frozen.to_string());
assert!(
validated.is_ok(),
"frozen parse-only report rejected: {validated:?}"
);
report["scanned"]["coverage_status"] = "no-applicable-input".into();
report["evidence_contract"]["execution_outcome"] = "no-applicable-input".into();
assert!(pons_core::report::validate::validate(&report.to_string()).is_err());
let sarif = t.scan(&["--format", "sarif", "--fail-on-skips"]);
assert_eq!(sarif.status.code(), Some(2));
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
let sarif: Value = serde_json::from_slice(&sarif.stdout).unwrap();
let invocation = &sarif["runs"][0]["invocations"][0];
assert_eq!(invocation["executionSuccessful"], true);
assert_eq!(invocation["properties"]["coverageStatus"], "partial");
assert_eq!(
invocation["toolExecutionNotifications"]
.as_array()
.unwrap()
.len(),
1
);
}

#[test]
Expand Down
7 changes: 3 additions & 4 deletions crates/pons-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ toml.workspace = true
serde = { workspace = true }
serde_json = { workspace = true }
tree-sitter = "=0.27.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"
# The root patch retains 0.25.0 syntax (including `using`) and fixes JSX
# keyword attributes. Provenance: vendor/tree-sitter-javascript/PATCHES.adoc.
tree-sitter-javascript = "=0.25.0"
tree-sitter-python = "=0.25.0"
tree-sitter-rust = "=0.24.2"
tree-sitter-typescript = "=0.23.2"
Expand Down
1 change: 1 addition & 0 deletions crates/pons-core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ mod tests {
}

#[test]
#[cfg(unix)]
fn a_directory_the_walker_could_not_enter_is_reported_alongside_the_findings() {
use std::os::unix::fs::PermissionsExt as _;

Expand Down
2 changes: 1 addition & 1 deletion crates/pons-core/src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Lang {
pub fn parser_version(self) -> &'static str {
match self {
Lang::Python => "0.25.0",
Lang::JavaScript => "0.23.1",
Lang::JavaScript => "0.25.0+jsx-keywords.1",
Lang::TypeScript | Lang::Tsx => "0.23.2",
Lang::Rust => "0.24.2",
Lang::Php => "0.25.1",
Expand Down
7 changes: 3 additions & 4 deletions crates/pons-core/src/report/sarif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ pub fn render(report: &ScanReport) -> anyhow::Result<String> {
// The scan itself completed: per ADR-0005 a skipped subtree is
// a partial result, not an operational failure. Consumers can
// opt into `--fail-on-skips` at the CLI for a hard gate.
execution_successful: report.files_scanned > 0,
execution_successful: report.coverage_status() != "no-applicable-input",
properties: serde_json::json!({"coverageStatus":report.coverage_status(),
"exitCode": report.exit_code,
"inventory":report.inventory, "coverageFailures":report.coverage_failures}),
Expand Down Expand Up @@ -731,9 +731,8 @@ mod tests {
.as_array()
.unwrap()
.is_empty());
report.files_scanned = 0;
let v: serde_json::Value = serde_json::from_str(&render(&report).unwrap()).unwrap();
assert_eq!(v["runs"][0]["invocations"][0]["executionSuccessful"], false);
// Empty input and parse-only scans are exercised through the real CLI
// in tests/coverage.rs, with consistent inventories and file counts.
}
#[test]
fn invocations_remains_present_when_nothing_was_skipped() {
Expand Down
27 changes: 19 additions & 8 deletions crates/pons-core/src/report/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,17 @@ fn validate_value(v: Value) -> Result<String> {
);
}
}
// Preserve the zero-file classification written by frozen 0.4.0 scanners.
// Current writers distinguish unsupported input from supported parse failures.
let status = if analysed == 0
&& failures.is_empty()
&& inventory.iter().all(|entry| {
matches!(
entry.outcome,
Outcome::Unsupported | Outcome::ExcludedByPolicy
)
}) {
&& (version == "0.4.0"
|| (failures.is_empty()
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
&& inventory.iter().all(|entry| {
matches!(
entry.outcome,
Outcome::Unsupported | Outcome::ExcludedByPolicy
)
}))) {
"no-applicable-input"
} else if !skipped.is_empty()
|| !failures.is_empty()
Expand Down Expand Up @@ -231,7 +234,15 @@ fn validate_value(v: Value) -> Result<String> {
let file = location["file"].as_str().context("missing finding file")?;
let relative = crate::evidence::relative_path(file, root);
ensure!(
!std::path::Path::new(&relative).is_absolute()
!std::path::Path::new(&relative).has_root()
&& !std::path::Path::new(&relative)
.components()
.any(|component| {
matches!(
component,
std::path::Component::Prefix(_) | std::path::Component::ParentDir
)
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
})
&& !relative.starts_with("../")
&& relative != "..",
"finding path is not inside the scan root"
Expand Down
5 changes: 5 additions & 0 deletions crates/pons-core/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ pub fn read_with_digest(file: &DiscoveredFile) -> anyhow::Result<(SourceFile, St

#[cfg(test)]
mod tests {
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt as _;

use super::*;
Expand Down Expand Up @@ -421,6 +422,7 @@ mod tests {
/// than a red one. The guard makes that situation *loud*: CI here is
/// `ubuntu-latest` with no container, i.e. non-root, so a failure means
/// something about the environment changed and the coverage went away.
#[cfg(unix)]
fn unreadable_dir(parent: &Path, name: &str) -> PathBuf {
let dir = parent.join(name);
std::fs::create_dir_all(&dir).unwrap();
Expand All @@ -435,11 +437,13 @@ mod tests {
}

/// Undo [`unreadable_dir`] so the temp tree can actually be removed.
#[cfg(unix)]
fn make_readable(dir: &Path) {
let _ = std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o755));
}

#[test]
#[cfg(unix)]
fn an_unreadable_subdirectory_is_skipped_and_the_rest_of_the_tree_still_enumerates() {
let dir = tempfile_dir();
std::fs::write(dir.join("kept.py"), "x = 1\n").unwrap();
Expand Down Expand Up @@ -509,6 +513,7 @@ mod tests {
}

#[test]
#[cfg(unix)]
fn an_unreadable_root_is_an_error_even_though_an_unreadable_subdirectory_is_not() {
let dir = tempfile_dir();
let locked = unreadable_dir(&dir, "root");
Expand Down
35 changes: 35 additions & 0 deletions crates/pons-core/tests/parser_adversarial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,41 @@ fn fixed_seed_parser_mutations() {
}
}
}

#[test]
fn modern_using_declarations_remain_supported() {
for text in [
"using resource = acquire();",
"async function work() { await using resource = acquire(); }",
] {
let source = SourceFile {
path: "resources.js".into(),
lang: Lang::JavaScript,
text: text.into(),
transcoded: false,
};
assert!(
parse::parse(&source).is_ok(),
"rejected modern declaration: {text}"
);
}
}

#[test]
fn jsx_attribute_patch_does_not_relax_javascript_keywords() {
for text in ["const in = 1;", "const view = <C value={const} />;"] {
let source = SourceFile {
path: "invalid-keyword.js".into(),
lang: Lang::JavaScript,
text: text.into(),
transcoded: false,
};
assert!(
parse::parse(&source).is_err(),
"accepted invalid keyword: {text}"
);
}
}
#[test]
fn deep_ast_is_rejected_before_recursive_rules() {
let src = SourceFile {
Expand Down
24 changes: 13 additions & 11 deletions docs/PLAN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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/JSX grammar (T0) | `=0.23.1` (compatibility pin below)
| `tree-sitter-javascript` | JS/JSX grammar (T0) | `=0.25.0`, local JSX identifier patch 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+)
Expand All @@ -379,16 +379,18 @@ truth thereafter.
|===

Compatibility correction, 2026-11-07 (echo-types#362): JavaScript grammar
0.25.0 rejects valid JSX keyword attribute names, including SVG
`<feMergeNode in="SourceGraphic" />`. 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.
0.25.0 rejects valid JSX keyword names, including SVG's
`<feMergeNode in="SourceGraphic" />`. Retain 0.25.0 and its modern `using`
declarations, and patch JSX identifiers to admit the existing reserved-word
terminals in that context. The pinned upstream source and generated parser
ship in `vendor/tree-sitter-javascript`; `PATCHES.adoc` records provenance
and regeneration. There is no source rewriting or TSX fallback, and recovered
error trees remain rejected. Parser receipts name `0.25.0+jsx-keywords.1`.
Parser and CLI regressions cover keyword names, malformed JSX, modern resource
declarations, analysis, coverage and report validation. Supported parse failures
give partial coverage even when no file was analysed. Frozen 0.4.0 reports
retain their historical classification, while SARIF distinguishes a completed
partial scan from an invocation failure.

Resolved 2026-09-14 via `cargo add tree-sitter tree-sitter-python
tree-sitter-javascript tree-sitter-typescript tree-sitter-rust -p pons-core`
Expand Down
34 changes: 24 additions & 10 deletions docs/echo-362-verification.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,43 @@
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.
Its valid SVG keyword attribute `in="SourceGraphic"` fails with upstream
JavaScript grammar 0.25.0. The final repair patches that grammar's JSX
identifier context, retaining modern `using` and `await using` declarations.
An earlier 0.23.1 compatibility pin is superseded because it lost that syntax.
There is no source rewriting, TSX fallback or acceptance of recovered error
trees. `vendor/tree-sitter-javascript/PATCHES.adoc` pins the upstream source,
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
generator, patch and generated output. The 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;
misclassification for current reports; genuine frozen 0.4.0 artifacts retain
their old status semantics. SARIF marks completed parse-only scans as partial
execution with diagnostics. 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 grammar/report repair passed 257 Linux test executions. Windows checks
also exposed Unix-only permission fixtures and a rooted-path validation gap;
those have explicit platform guards and a real Windows regression check.
Final hosted checks are separate from this local evidence.
* The final Windows workspace suite passed 253 test executions, and all-targets
Clippy with warnings denied passed. POSIX permission fixtures remain Unix
checks rather than being claimed as executed on Windows.
* 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.
* New parser controls accept JSX keyword attributes and modern resource
declarations, and reject malformed JSX and keywords in JavaScript positions.
CLI controls check real analysis, partial coverage on parsing failure,
report validity and rejection of a forged no-applicable-input status.
report validity, SARIF status, frozen-reader compatibility and rejection of
a forged current-format no-applicable-input status. The full Echo snapshot
now yields three analysed JavaScript/JSX files, eight heuristic warnings and
21 explicit skips; its overall coverage remains partial.

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.
Expand Down
Loading
Loading