Repository navigation
stdlib: tmpdir + Process + singleton_methods (Puppet-boot batch round) - #24
Merged
Merged
Conversation
Drive the `require "puppet"` boot further on a from-scratch, CGO=0, pure-Go stdlib, clearing three successive blockers in one round (each re-probed against the puppetlabs/puppet checkout and verified differentially against MRI 4.0.5). Blockers cleared: 1. `LoadError: cannot load such file -- tmpdir` (puppet/file_system/uniquefile.rb). Added the tmpdir standard library (internal/vm/tmpdir.go): Dir.tmpdir (TMPDIR/TMP/TEMP env precedence then /tmp) and Dir.mktmpdir in both the return-value and block forms, with default/String/[prefix, suffix] name handling, an explicit base directory, MRI-shaped "<prefix><YYYYMMDD>-<pid>-<rand> <suffix>" names, collision retry, and recursive cleanup of the directory after the block (even on a non-local exit). Layers onto the existing Dir class; wired through providedFeatures. 2. `NameError: uninitialized constant Process` (puppet/util/monkey_patches.rb: `Process.maxgroups = 1024`). Added a Process module (internal/vm/process.go): identity queries (pid, ppid, uid/euid/gid/egid, groups), clock_gettime with all unit symbols and the CLOCK_REALTIME/CLOCK_MONOTONIC constants, and the maxgroups accessor (read returns the platform cap, assignment accepted-and- ignored, matching MRI so Puppet's rescue works). All via Go's os and time, CGO=0. 3. `NoMethodError: undefined method 'singleton_methods' for Class` (monkey_patches.rb: `Dir.singleton_methods.include?(:exists?)`). Added Object#singleton_methods: class receivers return their class methods (inherited by default, own-only with a false argument); plain objects return their per-object singleton methods; receivers with none return []. After this round `require "puppet"` advances to puppet/ssl/openssl_loader.rb, which `require "openssl"` (followed by `net/https`). That is the next round's target and a large blocker: a crypto module plus a socket layer the runtime does not yet have. Stopping here to bank the batch. Tests: MRI-differential behavioural tests for every new method plus internal seam-injection tests for the unreachable Go branches (tmpdir env precedence, mkdir error/collision/exhaustion paths, the Process.groups failure path, the realtime-clock branch). Full suite green under -race, 100.0% coverage, gofmt + go vet clean. No opcode/bytecode/prelude changes, so the frozen prelude is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The Windows CI lane failed three tmpdir tests that assumed Unix semantics: - TestMakeTmpdirErrors exercised the EACCES mapping by chmod'ing a directory read-only, which is a no-op on Windows (and under root). Replace it with deterministic error injection through a new osMkdir seam so the mapping is covered identically on every platform. - The mktmpdir_base / mktmpdir_block_base Ruby cases hardcoded "/tmp" as the explicit base, which does not exist on Windows. Use Dir.tmpdir as the base instead. No behaviour change; coverage stays at 100.0% across internal packages. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
On Windows os.Getgroups is unavailable and the real call errors, so the Ruby-level `Process.groups` test only exercised the error branch there; the array-building success branch was covered solely by the real call on Unix, leaving the merged coverage at 99.9% on the windows-latest lane. Add a seam-injected success test that builds the group Array deterministically on every platform, restoring the 100% gate. 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
Batch round advancing the
require "puppet"boot on a from-scratch, CGO=0, pure-Go stdlib. Three successive boot blockers cleared in one PR, each re-probed against thepuppetlabs/puppetcheckout and verified differentially against MRI 4.0.5.Blocker chain cleared this round
file_system/uniquefile.rb(require 'tmpdir')LoadError: cannot load such file -- tmpdirDir.tmpdir+Dir.mktmpdirutil/monkey_patches.rb(Process.maxgroups = 1024)NameError: uninitialized constant Processutil/monkey_patches.rb(Dir.singleton_methods.include?(:exists?))NoMethodError: undefined method 'singleton_methods'Object#singleton_methods1. tmpdir (
internal/vm/tmpdir.go)Dir.tmpdir— TMPDIR/TMP/TEMP env precedence,/tmpfallback, skips a non-directory value.Dir.mktmpdir— return-value and block forms; default/String/[prefix, suffix]name handling; explicit base dir; MRI-shaped<prefix><YYYYMMDD>-<pid>-<rand><suffix>names; collision retry; recursive cleanup after the block (even on non-local exit).Dirclass; wired throughprovidedFeatures.2. Process (
internal/vm/process.go)pid,ppid,uid,euid,gid,egid,groups.clock_gettimewith every unit symbol +CLOCK_REALTIME/CLOCK_MONOTONICconstants.maxgroupsaccessor — read returns the platform cap, assignment accepted-and-ignored (matches MRI so Puppet'srescue NotImplementedErrorworks).os/time, CGO=0.3.
Object#singleton_methods(internal/vm/builtins.go)false/nilargument).[].Next blocker (next round)
require "puppet"now advances topuppet/ssl/openssl_loader.rb, which doesrequire 'openssl'thenrequire 'net/https'.LoadError: cannot load such file -- openssl— a large target: a crypto module plus thenet/httpssocket layer the runtime does not yet have. Stopped here to bank the batch rather than start a VM-core/large feature.Verification
Process.groupsfailure, realtime-clock branch).-race; 100.0% coverage;gofmt+go vetclean.GOWORK=off go build ./cmd/rbgosucceeds.🤖 Generated with Claude Code