Skip to content

psi: delete test-only syntax-trees JSON snapshot mirror - #6309

Merged
Smotto merged 1 commit into
mainfrom
work/psi-delete-syntax-tree-snapshots
Nov 27, 2026
Merged

Smotto merged 1 commit into
mainfrom
work/psi-delete-syntax-tree-snapshots

Conversation

@Smotto

@Smotto Smotto commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

syntax-trees maintained a 2,823-line hand-written inspection/ mirror of every AST struct solely to serialize SyntaxTrees to JSON for a handful of tests and two benchmarks, with zero production callers. This change deletes representations/syntax-trees/inspection/ and rewrites those tests and benchmarks to inspect SyntaxTrees and its record_storage bytes directly, cutting 2,972 lines net and dropping serde, serde_json, and artifacts from syntax-trees (plus serde_json from source-parser dev-dependencies).

Comparing the real syntax tables directly in tests/lexical_handoff.rs also uncovered a trailing-trivia arena leak in transitions/guards.rs:170: a tuple wildcard _ followed by whitespace or a comment failed component.tokens.len() == 1, fell into parse_destructure_pattern_arm, and allocated an unreachable Identifier in expressions.identifier_path_members before returning None. Checking component.take_contextual("_").is_ok_and(|rest| rest.tokens.is_empty()) fixes the leak.

  • representations/syntax-trees: Deleted inspection/ (snapshot.rs, items.rs, expressions_and_types.rs, statements.rs, mathematical.rs) and its self-test tests/unit/snapshot_tests.rs. Removed artifacts, serde, and serde_json dependencies and updated README.md. Rewrote tests/page_roots.rs and tests/unit/forest.rs to assert directly on SyntaxTrees rows.
  • Stage 01 (source-parser) and driver: Replaced SourceSyntax::snapshot_json (gated under test-support) with SourceSyntax::record_bytes backed by record_storage::encode, updated benchmarks/parser_timing.rs and benchmarks/streaming.rs to hash record_storage bytes, updated driver/parse_source_batch/tests.rs to compare SyntaxTrees with assert_eq!, and rewrote the snapshot-using parser tests (lexical_handoff.rs, positional_patterns.rs, operator_grouping.rs, items_and_selections.rs, bindings_and_conformances.rs, mathematical_definitions.rs) to assert directly on SyntaxTrees.
  • Parser bugfix: Fixed wildcard trailing-trivia check in pipeline/01_tokens-to-syntax-trees/src/transitions/guards.rs.

Validation:

  • mbx test -p syntax-trees -p source-parser -p source-syntax (pass)
  • mbx test -p source-compiler --lib parse_source_batch (pass)
  • mbx check -p source-compiler --features test-support --benches (pass)
  • mbx clippy -p syntax-trees -p source-parser --all-targets -- -D warnings (pass)
  • mbx clippy -p source-compiler --no-deps --lib --tests --benches --features test-support -- -D warnings (pass; --no-deps because unrelated psi-provider-selections on main has a pre-existing clippy::needless_lifetimes warning)
  • mbx xtask check-boundary (pass)
  • mbx xtask fmt --check --base origin/main (pass)

Gate: RC-REPOSITORY | removes 2.9k lines of test-only syntax-tree JSON snapshot mirror, drops serde/serde_json/artifacts from syntax-trees, and fixes a trailing-trivia wildcard arena leak in stage 01
Spec: wiki/spec/language/patterns.md, wiki/spec/language/data_and_literals.md, wiki/spec/language/expressions.md
Proof: mbx test -p syntax-trees -p source-parser -p source-syntax; mbx test -p source-compiler --lib parse_source_batch; mbx check -p source-compiler --features test-support --benches; mbx clippy -p syntax-trees -p source-parser --all-targets -- -D warnings; mbx clippy -p source-compiler --no-deps --lib --tests --benches --features test-support -- -D warnings; mbx xtask check-boundary; mbx xtask fmt --check --base origin/main | clean; deleted representations/syntax-trees/tests/unit/snapshot_tests.rs (self-test of deleted SyntaxTreesSnapshot) and rewrote snapshot-based assertions in lexical_handoff.rs, positional_patterns.rs, operator_grouping.rs, items_and_selections.rs, bindings_and_conformances.rs, mathematical_definitions.rs, page_roots.rs, forest.rs, and parse_source_batch/tests.rs to assert directly on SyntaxTrees
Agent: Antigravity | Model: Gemini 4 Neon | Effort: high | Tokens: 13.70M in (12.39M cached), 40.0k out | Steps: 40 | Time: 29m39s | Steers: 0

`syntax-trees` maintained a 2,823-line hand-written `inspection/` mirror of every AST struct solely to serialize `SyntaxTrees` to JSON for a handful of tests and two benchmarks, with zero production callers. This change deletes `representations/syntax-trees/inspection/` and rewrites those tests and benchmarks to inspect `SyntaxTrees` and its `record_storage` bytes directly, cutting 2,972 lines net and dropping `serde`, `serde_json`, and `artifacts` from `syntax-trees` (plus `serde_json` from `source-parser` dev-dependencies).

Comparing the real syntax tables directly in `tests/lexical_handoff.rs` also uncovered a trailing-trivia arena leak in `transitions/guards.rs:170`: a tuple wildcard `_` followed by whitespace or a comment failed `component.tokens.len() == 1`, fell into `parse_destructure_pattern_arm`, and allocated an unreachable `Identifier` in `expressions.identifier_path_members` before returning `None`. Checking `component.take_contextual("_").is_ok_and(|rest| rest.tokens.is_empty())` fixes the leak.

- **`representations/syntax-trees`:** Deleted `inspection/` (`snapshot.rs`, `items.rs`, `expressions_and_types.rs`, `statements.rs`, `mathematical.rs`) and its self-test `tests/unit/snapshot_tests.rs`. Removed `artifacts`, `serde`, and `serde_json` dependencies and updated `README.md`. Rewrote `tests/page_roots.rs` and `tests/unit/forest.rs` to assert directly on `SyntaxTrees` rows.
- **Stage 01 (`source-parser`) and driver:** Replaced `SourceSyntax::snapshot_json` (gated under `test-support`) with `SourceSyntax::record_bytes` backed by `record_storage::encode`, updated `benchmarks/parser_timing.rs` and `benchmarks/streaming.rs` to hash `record_storage` bytes, updated `driver/parse_source_batch/tests.rs` to compare `SyntaxTrees` with `assert_eq!`, and rewrote the snapshot-using parser tests (`lexical_handoff.rs`, `positional_patterns.rs`, `operator_grouping.rs`, `items_and_selections.rs`, `bindings_and_conformances.rs`, `mathematical_definitions.rs`) to assert directly on `SyntaxTrees`.
- **Parser bugfix:** Fixed wildcard trailing-trivia check in `pipeline/01_tokens-to-syntax-trees/src/transitions/guards.rs`.

Validation:
- `mbx test -p syntax-trees -p source-parser -p source-syntax` (pass)
- `mbx test -p source-compiler --lib parse_source_batch` (pass)
- `mbx check -p source-compiler --features test-support --benches` (pass)
- `mbx clippy -p syntax-trees -p source-parser --all-targets -- -D warnings` (pass)
- `mbx clippy -p source-compiler --no-deps --lib --tests --benches --features test-support -- -D warnings` (pass; `--no-deps` because unrelated `psi-provider-selections` on `main` has a pre-existing `clippy::needless_lifetimes` warning)
- `mbx xtask check-boundary` (pass)
- `mbx xtask fmt --check --base origin/main` (pass)

Gate: RC-REPOSITORY | removes 2.9k lines of test-only syntax-tree JSON snapshot mirror, drops serde/serde_json/artifacts from syntax-trees, and fixes a trailing-trivia wildcard arena leak in stage 01
Spec: wiki/spec/language/patterns.md, wiki/spec/language/data_and_literals.md, wiki/spec/language/expressions.md
Proof: mbx test -p syntax-trees -p source-parser -p source-syntax; mbx test -p source-compiler --lib parse_source_batch; mbx check -p source-compiler --features test-support --benches; mbx clippy -p syntax-trees -p source-parser --all-targets -- -D warnings; mbx clippy -p source-compiler --no-deps --lib --tests --benches --features test-support -- -D warnings; mbx xtask check-boundary; mbx xtask fmt --check --base origin/main | clean; deleted representations/syntax-trees/tests/unit/snapshot_tests.rs (self-test of deleted SyntaxTreesSnapshot) and rewrote snapshot-based assertions in lexical_handoff.rs, positional_patterns.rs, operator_grouping.rs, items_and_selections.rs, bindings_and_conformances.rs, mathematical_definitions.rs, page_roots.rs, forest.rs, and parse_source_batch/tests.rs to assert directly on SyntaxTrees
Agent: Antigravity | Model: Gemini 4 Neon | Effort: high | Tokens: 13.70M in (12.39M cached), 40.0k out | Steps: 40 | Time: 29m39s | Steers: 0
@Smotto
Smotto merged commit 421f559 into main Nov 27, 2026
1 check passed
@Smotto
Smotto deleted the work/psi-delete-syntax-tree-snapshots branch November 27, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant