ReviewOS

home-lang/home

Implement Bun patch makeDiff and apply internals

#679
Closed chris opened this 9 days ago ·
9 days ago

Goal

Port Bun patch-generation and patch-application behavior used by the unchanged test/js/bun/patch/patch.test.ts suite.

This is a focused child of #202 and contributes to #66.

Current evidence

With Bun source pin 4982b91e3702094330f3be3883354c52b8c01323 and Home 34873c58c, direct native execution observes 8 passing tests and 13 failures, then exits with status 138 instead of producing a normal runner summary.

Working coverage includes the edge case, invalid-argument handling, and patch parsing. Missing or incorrect behavior includes:

  • empty diff generation
  • file creation and deletion
  • file and directory rename application
  • mode changes
  • simple and multi-line insertions/deletions
  • multi-hunk application
  • overlong destination-path error behavior
  • clean termination after the matrix

One diagnostic shows makeDiff() returning the global object where an empty string is expected, indicating that the bun:internal-for-testing binding/return contract also needs correction.

Acceptance criteria

  • Run the vendored upstream file unchanged through Home native test execution.
  • All upstream assertions pass with a normal exit and summary.
  • Do not replace the file with TODO/skip, alter fixtures, reduce assertions, or shell out to Bun.
  • Remove its rewriteNativeTodoCorpus branch only after the exact suite is green.
  • Add focused native and corpus-gate regression coverage.
9 days ago

Strict unchanged-suite probe recorded from Home 34873c58c: 8 observed passes, 13 failures, then process status 138. The whole-file TODO rewrite remains in place until these native contracts pass; no source/test weakening was applied.

9 days ago

Completed on main in ab08189.

Home now exposes the real patchInternals.makeDiff JSC host function instead of the no-op stub, using Zig 0.17 process execution with Bun-compatible isolated Git environment and output handling. This batch also ports mutation-safe diff path normalization, catchable ENAMETOOLONG behavior for oversized rename targets, safe truncated ---/+++ header parsing, and correct UTF-8 source ownership during parse.

Validation used the exact untouched fixture from Bun 4982b91. The complete patch matrix passed twice consecutively: 23 pass, 0 fail, 0 TODO, 0 unsupported. Generated deletion headers were verified as normalized a/... and b/... paths, with no temp-directory leakage. The copied fixture remains byte-identical to Bun. ReleaseFast/JSC install build and Zig source checks passed.

Sign in to comment on this issue.