Repository navigation
fix: Resolve bugs with patching of tables split across dotted keys and headers - #340
Conversation
Emit a scalar replacement as a dotted row in the existing explicit parent when dotted siblings already define the intermediate table. This avoids creating a conflicting child header.
When a removal path prefix-matches a dotted key inside a table, also remove document-level headers under that prefix. This prevents array-of-table children from recreating deleted data.
Resolve a prefix-matched InlineItem to its structural container, allowing replacement logic to remove sibling dotted rows before writing the collapsed key.
Record the clean seed sweep and document fuzz5 coverage boundaries.
Add targeted fuzz6 coverage for dotted keys, AOT deletions, and inline-table replacements.
Benchmark comparisonEach workload measured this branch against Parse Benchmark ResultsTime per iteration. Lower is better. Change is throughput vs. reference: + is faster, - is slower. 📖 Parse, smol-toml spec example (toml-spec-example.toml)
📖 Parse, smol-toml 5MB mixed (5mb-mixed.toml)
📖 Parse, iarna spec example v0.4.0 (0A-spec-01-example-v0.4.0.toml)
Stringify Benchmark ResultsTime per iteration. Lower is better. Change is throughput vs. reference: + is faster, - is slower. ✍️ Stringify, smol-toml spec example (toml-spec-example.toml)
✍️ Stringify, smol-toml 5MB mixed (5mb-mixed.toml)
✍️ Stringify, iarna spec example v0.4.0 (0A-spec-01-example-v0.4.0.toml)
🧩 Patch benchmarksFull and lite patching are compared with smol-toml. The smol-toml method parses the document, updates the object, and stringifies it. Timings include each implementation’s complete operation; fixture creation and correctness checks are outside the timed section. Current and base-branch full and lite patch builds are compared in the same run. Edit existing scalar valuesChange several existing root and nested scalar values. 🧩 Edit existing scalar values, representative-document
Edit an unrelated scalar with many top-level AOT scopesChange one root value while each named AOT owns a nested subtable. 🧩 Edit an unrelated scalar with many top-level AOT scopes, aot-scopes-64
🧩 Edit an unrelated scalar with many top-level AOT scopes, aot-scopes-256
🧩 Edit an unrelated scalar with many top-level AOT scopes, aot-scopes-1024
|
There was a problem hiding this comment.
🟡 Changes recommended
The fuzz test can place a root-intended inline assignment inside an array-of-tables entry, causing multi-mutation runs to throw before exercising the intended edits.
1 open issue
What changed in this PR
This PR addresses #335 by improving patch() handling of tables split across dotted keys and headers, aiming to preserve valid TOML and match the updated object.
Changes:
- Fixes structural replacements and descendant deletion while keeping changes scoped to the selected array-of-tables entry.
- Adds regression tests and a targeted structural fuzzer.
- Adds fuzz-runner progress reporting and updates supporting documentation.
| File | Description |
|---|---|
src/patch.ts |
Corrects replacement containers, scoped header cleanup, and dotted-path handling. |
src/__tests__/patch.test.ts |
Adds regressions for split tables, entry isolation, and out-of-order headers. |
src/__tests__/fuzz6.test.ts |
Checks scenario rotation and three targeted round trips. |
src/__tests__/fuzz-patch6.ts |
Generates targeted structural replacement and deletion scenarios. |
scripts/report-dependents.mjs |
Updates comments explaining how to refresh saved dependents HTML. |
scripts/fuzz-run6.ts |
Adds a runner for targeted structural fuzzing. |
scripts/fuzz-run5.ts |
Adds optional progress reporting. |
package.json |
Registers the fuzz6 command. |
docs/Fuzz-Testing.md |
Documents variant 6, coverage boundaries, and sweep results. |
CHANGELOG.md |
Records the patching fixes under Unreleased. |
Review effort: Balanced
…ormation in presence of dotted-keys
Emit root inline-table cases before section headers so multi-mutation seeds retain their document scope.

Closes #335
patch()could produce invalid TOML or retain deleted data when a table's path was split between dotted keys and explicit headers. Nested inline-table paths could also leave conflicting dotted keys behind.This change: