Skip to content

file/dir: File.lutime, File.utime nil times, Dir.chroot (core/file +7, core/dir +3) - #601

Merged
tannevaled merged 2 commits into
mainfrom
wave21/filedir
Sep 8, 2026
Merged

tannevaled merged 2 commits into
mainfrom
wave21/filedir

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

Wave-21 core/file + core/dir conformance. 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 (ruby 4.0.5 arm64-darwin25).

suite before after Δ
core/file 495 502 +7
core/dir 264 267 +3

Methods

  • 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 a new lutimesFn
    POSIX seam (unsupported stub on windows/wasm; the spec is platform_is_not :windows). 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.

  • File.utime — a nil atime/mtime now means the current time
    (timeArgUnixOrNow), matching file.c utime_internal leaving the timespec
    NULL (UTIME_NOW). Fixes "uses the current times if two nil values are
    passed". core/file utime 5/6 → 6/6.

  • Dir.chroot(path) — chroot(2) via a new chrootFn seam, returns 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, chroot, rb_sys_fail_path, INT2FIX(0)).
    core/dir chroot 0/3 → 3/3.

Whitebox _test.go drives every new branch (arity guards, each errno mapping
via swapped seams, real utimensat/chroot success) for 100% coverage on
POSIX; the OS-specific real-syscall paths are guarded by runtime.GOOS.

Deliberately NOT done (with reasons, for the parallel agents)

  • File.mkfifo is 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 from
    two Ruby threads, and rbgo's blocking File.open (io.go) deadlocks the
    scheduler
    on the FIFO open(2) handshake, hanging the whole spec file and
    losing its ~55 passing examples. io agent: once File.open on a FIFO no
    longer blocks the interpreter (non-blocking open / real thread concurrency),
    File.mkfifo can 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 word
    special/test +()[]{}/hello_world.erb. This creates a phantom top-level
    +()[]{} directory in the shared Dir fixtures, poisoning ~15-20 core/dir
    examples (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 shim
    artifact, not a gap.
    The shim's SPEC_TMP_BASE = "/tmp/..." is not
    pre-resolved, and both MRI and rbgo resolve /tmp → /private/tmp. Verified:
    File.realpath("/tmp/x") returns /private/tmp/x on both. rbgo already
    matches MRI byte-for-byte here.

  • 2 remaining File.lutime examples assert File::Stat#atime, which returns
    ModTime (Go's portable stat exposes only ModTime, and the real st_atime
    field is named Atim on linux vs Atimespec on darwin — unreachable from the
    single shared !windows && !wasm build file this scope may edit).

  • io.go territory (noted, not touched): File#atime/#ctime/#mtime/#birthtime/ #lstat/#stat/#flock (instance), File#truncate, File#chmod RangeError/to_int,
    File.new/File.open modes & fd, File#path alias of #to_path,
    File.directory?/File.size #to_io. Path-encoding crashes in
    File.basename/File.dirname are 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 ✓
  • 100% coverage on the new POSIX branches ✓

Do NOT merge. FLOOR untouched.

🤖 Generated with Claude Code

tannevaled and others added 2 commits September 8, 2026 20:36
…, 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
tannevaled merged commit e3d569d into main Sep 8, 2026
7 checks passed
@tannevaled
tannevaled deleted the wave21/filedir branch September 8, 2026 21:23
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant