Skip to content

refactor: centralize parser validation state - #332

Merged
DecimalTurn merged 7 commits into
latestfrom
dev-parser-validation-plan
Oct 22, 2026
Merged

DecimalTurn merged 7 commits into
latestfrom
dev-parser-validation-plan

Conversation

@DecimalTurn

@DecimalTurn DecimalTurn commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Improve parsing approach:

  • Replace parallel parser-validation collections with a PathState metadata tree.
  • Track table-array entry scopes within the path tree, including nested and non-contiguous headers.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 02:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Validation permits shared date-prototype mutation and misses parent-table conflicts that produce raw TypeErrors.

2 open issues
What changed in this PR

This PR centralizes semantic validation during TOML-to-JavaScript conversion in a path metadata tree, replacing parallel collections and table-scope bookkeeping.

Changes:

  • Introduces PathState to track definitions and validation rules.
  • Tracks array-of-tables entries separately for nested and non-contiguous headers.
  • Documents the migration plan, compatibility goals, and acceptance criteria.
File Description
src/​to-js.ts Replaces validation collections with path-based metadata and per-entry scopes.
docs/​PLAN-Parser-Validation-State.md Documents the design, migration steps, and validation requirements.

Review effort: Balanced

Comment thread src/to-js.ts
Comment thread src/to-js.ts Outdated
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Benchmark comparison

This branch measured against latest in one run on the same runner.
Ratios close to 1.0 are within run to run noise.

Fixture Benchmark Results

Time per iteration. Lower is better.

Parse, smol-toml spec example (toml-spec-example.toml)

Library Performance Slowdown Ratio
🥇 smol-toml@1.9.1 (Date) 8.22 µs/iter 1x
🥈 smol-toml@1.9.1 (Temporal) 11.38 µs/iter 1.38x
🥉 @iarna/toml@3.0.0 21.52 µs/iter 2.62x
4 @decimalturn/toml-patch@3.3.1 (Date, current) 31.84 µs/iter 3.87x 1.17
5 @decimalturn/toml-patch@3.3.1 (baseline) 37.28 µs/iter 4.53x
6 @decimalturn/toml-patch@3.3.1 (Temporal, current) 39.31 µs/iter 4.78x

Parse, smol-toml 5MB mixed (5mb-mixed.toml)

Library Performance Slowdown Ratio
🥇 smol-toml@1.9.1 (Date) 74.78 ms/iter 1x
🥈 smol-toml@1.9.1 (Temporal) 194.22 ms/iter 2.60x
🥉 @decimalturn/toml-patch@3.3.1 (Date, current) 327.32 ms/iter 4.38x 1.08
4 @decimalturn/toml-patch@3.3.1 (baseline) 352.49 ms/iter 4.71x
5 @decimalturn/toml-patch@3.3.1 (Temporal, current) 506.52 ms/iter 6.77x
- @iarna/toml@3.0.0 DNF DNF

Parse, iarna spec example v0.4.0 (0A-spec-01-example-v0.4.0.toml)

Library Performance Slowdown Ratio
🥇 smol-toml@1.9.1 (Date) 47.16 µs/iter 1x
🥈 smol-toml@1.9.1 (Temporal) 58.17 µs/iter 1.23x
🥉 @iarna/toml@3.0.0 136.25 µs/iter 2.89x
4 @decimalturn/toml-patch@3.3.1 (Date, current) 181.79 µs/iter 3.85x 1.18
5 @decimalturn/toml-patch@3.3.1 (Temporal, current) 206.51 µs/iter 4.38x
6 @decimalturn/toml-patch@3.3.1 (baseline) 214.23 µs/iter 4.54x

Stringify, smol-toml spec example (toml-spec-example.toml)

Library Performance Slowdown Ratio
🥇 smol-toml@1.9.1 5.53 µs/iter 1x
🥈 @iarna/toml@3.0.0 18.38 µs/iter 3.32x
🥉 @decimalturn/toml-patch@3.3.1 (baseline) 96.43 µs/iter 17.43x
4 @decimalturn/toml-patch@3.3.1 (current) 96.99 µs/iter 17.53x 0.99

Stringify, smol-toml 5MB mixed (5mb-mixed.toml)

Library Performance Slowdown Ratio
🥇 smol-toml@1.9.1 68.90 ms/iter 1x
🥈 @iarna/toml@3.0.0 238.45 ms/iter 3.46x
🥉 @decimalturn/toml-patch@3.3.1 (baseline) 792.50 ms/iter 11.50x
4 @decimalturn/toml-patch@3.3.1 (current) 819.38 ms/iter 11.89x 0.97

Stringify, iarna spec example v0.4.0 (0A-spec-01-example-v0.4.0.toml)

Library Performance Slowdown Ratio
🥇 smol-toml@1.9.1 23.69 µs/iter 1x
🥈 @iarna/toml@3.0.0 81.27 µs/iter 3.43x
🥉 @decimalturn/toml-patch@3.3.1 (baseline) 450.99 µs/iter 19.03x
4 @decimalturn/toml-patch@3.3.1 (current) 468.18 µs/iter 19.76x 0.96

@DecimalTurn
DecimalTurn marked this pull request as ready for review October 22, 2026 06:19
@DecimalTurn
DecimalTurn merged commit 83cc173 into latest Oct 22, 2026
36 checks passed
@DecimalTurn
DecimalTurn deleted the dev-parser-validation-plan branch October 22, 2026 06:28
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.

2 participants