ReviewOS

home-lang/home

fix(yaml): complete Bun block-scalar folding and chomping semantics

#737
Closed glennmichael123 opened this 9 days ago ·
9 days ago

Tracks the remaining YAML block-scalar sub-gap from #66 after #708.

Baseline

Pinned Bun passes yaml-block-scalar-matrix.test.ts 1084/1084. Current Home passes 941 and fails 143. The failures cluster around folded transitions adjacent to more-indented lines and whitespace-only Keep-chomp inputs.

Root cause

Home still carries the old Zig state machine after the explicit-indent and EOF-chomp ports. Bun live Rust additionally:

  • tracks previous/current more-indented content lines so folded breaks are preserved around them;
  • retains leading whitespace-only line counts until chomping;
  • consumes only content_indent spaces per body line so additional spaces remain content;
  • precomputes max(content_indent, parent_indent + 1) for body membership;
  • requires true line start for document markers and treats EOF as valid for isAnyOrEofAt.

Port and verification

The live behavior is translated into packages/runtime/src/parsers/yaml.zig with direct regressions for folded more-indented lines, empty Keep chomping, and explicit-indent whitespace content.

Completed checks:

  • zig ast-check passes.
  • git diff --check passes.
  • A real compile with the Home module graph and binary emission disabled passes semantic type-checking at 544 MB.

Pending check:

  • Run the three native regressions and the full 1084-case matrix from a fresh runtime binary. LLVM and self-hosted code generation both crossed the fixed memory guard; the guard was not raised.
9 days ago

Port landed on main in 3fc137809 (fix(yaml): finish block scalar semantics (#737)).

Permanent regressions cover:

  • folded breaks around more-indented lines;
  • Keep chomping of an empty content line;
  • explicit-indent whitespace content.

Verification completed: zig ast-check, git diff --check, and a full semantic type-check against the Home module graph with emission disabled (544 MB peak). Full code generation was stopped by the unchanged memory guard, including the stripped focused harness, so this issue remains open until a fresh runtime executes the three regressions and yaml-block-scalar-matrix.test.ts.

9 days ago

Completed and verified on current main in bae99f883 (fix(yaml): retain block scalar header indentation), building on the block-scalar port in 3fc137809.

The final port restores two Bun parser invariants: the block-header newline resets line indentation, and a scalar token retains the indentation of its | or > header rather than its deeper content. This correctly terminates empty scalars at collection boundaries and rejects a block header dedented below its parent.

Validation:

  • fresh ReleaseFast build: 46/46 steps succeeded;
  • direct former failures now match pinned Bun: explicit empty key/value, six empty sequence scalars across all chomps, and rejection of a dedented header;
  • unchanged js/bun/yaml/yaml-block-scalar-matrix.test.ts: 1,084 passed, 0 failed;
  • git diff --check passed;
  • no test edits, skips, timeout changes, or parser workarounds were used.

Closing this focused checkpoint as complete. Parent parity tracking continues in #66.

Sign in to comment on this issue.