Repository navigation
file/dir: File.lutime, File.utime nil times, Dir.chroot (core/file +7, core/dir +3) - #601
Merged
Merged
Conversation
…, core/dir +3)
Add three offline-fixable MRI-4.0.x methods, each read from the ruby/ruby
v3_4_0 C source and measured byte-for-byte against MRI Ruby 4.0.5.
File.lutime(atime, mtime, *paths) — sets each path's access/modification
time WITHOUT following a final symlink, returning the path count. Backed by
utimensat(AT_FDCWD, path, ts, AT_SYMLINK_NOFOLLOW) through the new lutimesFn
POSIX seam (unsupported stub on windows/wasm). Ref: file.c utime_internal /
utime_internal_i, which passes follow=TRUE -> AT_SYMLINK_NOFOLLOW and returns
LONG2FIX(argc). core/file lutime 0/8 -> 6/8 (the 2 remaining check
File::Stat#atime, which Go's portable stat cannot report per-platform from a
shared build file).
File.utime — a nil atime/mtime now means the current time (timeArgUnixOrNow),
matching file.c utime_internal leaving the timespec NULL (UTIME_NOW). Fixes
the "uses the current times if two nil values are passed" example. core/file
utime 5/6 -> 6/6.
Dir.chroot(path) — chroot(2) via the new chrootFn seam, returning 0; a
non-privileged process fails with Errno::EPERM, and raiseChrootErr maps the
errno (EPERM/ENOENT/ENOTDIR) — each a SystemCallError. Ref: dir.c
dir_s_chroot (check_dirname, rb_sys_fail_path, INT2FIX(0)). core/dir chroot
0/3 -> 3/3.
File.mkfifo is deliberately NOT added: a correct syscall.Mkfifo is trivial and
MRI-verified, but registering it hangs open_spec ("on a FIFO" opens both ends
from two Ruby threads and rbgo's blocking File.open deadlocks the scheduler on
the FIFO open(2) handshake), losing that file's ~55 passing examples. It needs
a non-blocking File.open / thread-concurrency fix in io.go first.
Whitebox tests drive every new branch (arity guards, errno mappings via
swapped seams, real utimensat/chroot success) for 100% coverage on POSIX; the
OS-specific real-syscall paths are guarded by runtime.GOOS.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…thods) File.lutime and Dir.chroot are registered only under the unix build tag, so on Windows the methods are absent (NoMethodError) and TestFileLutime's arity/error assertions and all of TestDirChroot failed the windows lane. Skip both on Windows; the 100% coverage gate runs on the POSIX lanes, so coverage is intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Sep 8, 2026
…602) Wave-21 merged three bibliography-first conformance PRs: - #600 core/io: IO::Buffer transfer/locked/and!/or!/xor!/not!/for/resize/valid?, IO#advise validated no-op — +59. - #601 core/file+dir: File.lutime, File.utime nil (UTIME_NOW), Dir.chroot — +10. - #599 core/kernel: Kernel#loop StopIteration rescue + infinite Enumerator, Kernel#fail alias of raise — +7. Measured total on merged main: 19993 passing. Local measure at TIMEOUT=25; CI runs TIMEOUT=60 so its total is >= this floor. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wave-21 core/file + core/dir conformance. Three offline-fixable MRI-4.0.x
methods, each read from the ruby/ruby
v3_4_0C source and measuredbyte-for-byte against MRI Ruby 4.0.5 (
ruby 4.0.5 arm64-darwin25).Methods
File.lutime(atime, mtime, *paths)— sets each path's access/modificationtime without following a final symlink, returning the path count. Backed by
utimensat(AT_FDCWD, path, ts, AT_SYMLINK_NOFOLLOW)through a newlutimesFnPOSIX seam (unsupported stub on windows/wasm; the spec is
platform_is_not :windows). Ref:file.cutime_internal/utime_internal_i, which passesfollow=TRUE→AT_SYMLINK_NOFOLLOWand returnsLONG2FIX(argc).core/file lutime 0/8 → 6/8.
File.utime— anilatime/mtime now means the current time(
timeArgUnixOrNow), matchingfile.cutime_internalleaving the timespecNULL (
UTIME_NOW). Fixes "uses the current times if two nil values arepassed". core/file utime 5/6 → 6/6.
Dir.chroot(path)—chroot(2)via a newchrootFnseam, returns 0; anon-privileged process fails with
Errno::EPERM, andraiseChrootErrmapsthe errno (EPERM/ENOENT/ENOTDIR — each a
SystemCallError). Ref:dir.cdir_s_chroot(check_dirname,chroot,rb_sys_fail_path,INT2FIX(0)).core/dir chroot 0/3 → 3/3.
Whitebox
_test.godrives every new branch (arity guards, each errno mappingvia swapped seams, real
utimensat/chrootsuccess) for 100% coverage onPOSIX; the OS-specific real-syscall paths are guarded by
runtime.GOOS.Deliberately NOT done (with reasons, for the parallel agents)
File.mkfifois ready and MRI-verified (syscall.Mkfifo, default 0666 &~umask, returns 0) but is left unregistered: enabling it regresses
core/file.
open_spec's "on a FIFO" example opens both ends of the FIFO fromtwo Ruby threads, and rbgo's blocking
File.open(io.go) deadlocks thescheduler on the FIFO
open(2)handshake, hanging the whole spec file andlosing its ~55 passing examples. io agent: once
File.openon a FIFO nolonger blocks the interpreter (non-blocking open / real thread concurrency),
File.mkfifocan be added for +7 (mkfifo) +1 (pipe) with no regression.%w[...]escaped-space lexer bug (biggest remaining core/dir lever).%w[special/test\ +()[]{}/hello_world.erb]tokenizes to two words in rbgo(
special/test\,+()[]{}/hello_world.erb) vs MRI's single wordspecial/test +()[]{}/hello_world.erb. This creates a phantom top-level+()[]{}directory in the shared Dir fixtures, poisoning ~15-20 core/direxamples (entries/children/each/each_child/foreach/read + glob
*/**).Out of file/dir scope — it's a lexer fix.
realpath / realdirpath / chdir / pwd "
/private/tmp" failures are a shimartifact, not a gap. The shim's
SPEC_TMP_BASE = "/tmp/..."is notpre-resolved, and both MRI and rbgo resolve
/tmp→/private/tmp. Verified:File.realpath("/tmp/x")returns/private/tmp/xon both. rbgo alreadymatches MRI byte-for-byte here.
2 remaining
File.lutimeexamples assertFile::Stat#atime, which returnsModTime(Go's portable stat exposes only ModTime, and the realst_atimefield is named
Atimon linux vsAtimespecon darwin — unreachable from thesingle shared
!windows && !wasmbuild file this scope may edit).io.go territory (noted, not touched):
File#atime/#ctime/#mtime/#birthtime/ #lstat/#stat/#flock(instance),File#truncate,File#chmodRangeError/to_int,File.new/File.openmodes & fd,File#pathalias of#to_path,File.directory?/File.size#to_io. Path-encoding crashes inFile.basename/File.dirnameare in the encode layer.CI gates (all green locally)
go build ./...✓ ; darwin/linux/windows/wasip1 cross-builds ✓GOWORK=off go test ./...✓ (8 packages ok, 0 failures)gofmt -l internal/vm/empty ✓Do NOT merge. FLOOR untouched.
🤖 Generated with Claude Code