fix: IO::File handle tracking and timestamps in _io_file_mock_open#392
Draft
Koan-Bot wants to merge 1 commit into
Draft
fix: IO::File handle tracking and timestamps in _io_file_mock_open#392Koan-Bot wants to merge 1 commit into
Koan-Bot wants to merge 1 commit into
Conversation
…_open
Two bugs found via deep audit:
1. _io_file_mock_open stored file handles in $mock->{'fh'} (singular)
while __open/__sysopen use $mock->{'fhs'} (array). This meant:
- Multiple IO::File handles to same file overwrote each other
- CLOSE didn't clean up (it only removes from 'fhs')
- Handle-based operations (truncate, etc.) couldn't find IO::File handles
2. _io_file_mock_open was missing POSIX timestamp updates that __open has:
- New file creation: atime/mtime/ctime not set
- Truncation of existing file: mtime/ctime not updated
- Parent directory mtime not updated on file creation
New test file with 18 assertions covering handle tracking, cleanup,
multiple handles, write+reopen, and both timestamp scenarios.
Co-Authored-By: Claude Opus 4.6 <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.
What
Fix two bugs in
_io_file_mock_open(the IO::File->open() code path) found during deep audit.Why
_io_file_mock_opendiverged from__open/__sysopenin two ways:Handle tracking: Stored handles in
$mock->{'fh'}(singular) instead of the{'fhs'}array that__open/__sysopenuse. This meant multiple IO::File handles to the same file overwrote each other's tracking, CLOSE didn't clean up properly, and handle-based operations liketruncate($fh, N)couldn't resolve IO::File handles.Missing timestamps: Didn't update POSIX timestamps on file creation (atime/mtime/ctime) or truncation (mtime/ctime), and didn't update parent directory mtime. The
__openpath has had this logic since PR fix: set realistic nlink and unique inode defaults #259.How
_io_file_mock_opento use{'fhs'}array pattern matching__open/__sysopen$was_newtracking and timestamp update logic mirroring__openTesting
New
t/io_file_handle_tracking.twith 18 assertions:fhsarray (not singularfh)fhsFull test suite passes locally.
🤖 Generated with Claude Code
Quality Report
Changes: 3 files changed, 161 insertions(+), 4 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline