Skip to content

🚀 [Feature]: YAML streams can now be normalized safely#42

Closed
Marius Storhaug (MariusStorhaug) wants to merge 6 commits into
implement-yaml-file-iofrom
format-yaml
Closed

🚀 [Feature]: YAML streams can now be normalized safely#42
Marius Storhaug (MariusStorhaug) wants to merge 6 commits into
implement-yaml-file-iofrom
format-yaml

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 25, 2026

Copy link
Copy Markdown
Member

YAML streams can now be normalized into deterministic YAML without losing documents, tags, anchors, aliases, recursive graphs, complex keys, scalar content, or mapping order.

New: Deterministic YAML stream formatting

Format-Yaml accepts complete YAML text or line-oriented pipeline input, removes comments and presentation differences, emits every document with an explicit --- marker, and produces LF-only output without a final newline. -Indent selects 2 through 9 spaces, while the parser safety controls match ConvertFrom-Yaml.

Get-Content -Path '.\config.yaml' | Format-Yaml -Indent 4

Formatting is byte-idempotent at the same options, including multi-document streams, effective tags, aliases, recursive YAML graphs, and complex keys.

Review fixes

  • MaxTagLength now budgets the decoded effective tag identity rather than presentation wrappers or percent-encoded token length. Local, verbatim, and expanded-handle tags remain idempotent at exact custom and default boundaries, while worst-case presentation scanning and cumulative tag storage stay bounded.
  • Formatter representation events now include every scalar's resolved effective tag, including implicit string, boolean, integer, float, and null tags. Explicit and non-specific tag state remains distinct, while scalar presentation style remains non-semantic.

Technical Details

  • Formatting parses with the repository-owned YAML parser and emits directly from representation nodes rather than projecting through PowerShell objects.
  • Standard tags use canonical shorthand, other effective tags use verbatim form, and anchors are renamed deterministically while preserving alias identity.
  • The formatter corpus surface passes 400 inputs: all 306 loadable valid inputs reparse with identical canonical representation events and exact second-format bytes, while all 94 invalid inputs remain rejected. The two valid duplicate-key policy cases are not applicable.
  • Full local source Pester passed 321 tests with 6 skips; full tests against the generated module passed 323 tests with 4 skips. Source and generated-module parser and PSScriptAnalyzer checks passed.
  • Process-PSModule run 30144414180 passed on exact head b9c1ab1, completing 45 jobs successfully with 5 expected skips. It covered source and built-module Pester, PSScriptAnalyzer, formatter and conformance suites on Windows, Linux, and macOS under PowerShell 7.6.3, plus module, documentation, and site builds. Hosted tests totaled 1,441 passed, 0 failed, and 35 skipped out of 1,476.
  • Implementation plan progress: every task in Add deterministic YAML stream formatting #5 is complete. The pull request remains draft for review.
Related issues

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Apply tag limits to decoded effective identities while bounding worst-case percent-encoded presentation and cumulative storage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve every formatter scalar tag canonically while retaining explicit and non-specific tag state and ignoring presentation style.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MariusStorhaug

Copy link
Copy Markdown
Member Author

Superseded by #47 (release/v1.0.0 consolidation PR). Closing this stacked layer as part of release cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant