Support Windows storage I/O primitives#16
Conversation
|
@coderabbitai[bot] review |
|
✅ Action performedReview finished.
|
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe runtime adds Windows direct I/O, memory mapping, and WAL support, strengthens mapping and page validation, adds portable and Windows integration tests, wires them into CI, and updates documentation and release notes. ChangesCross-platform storage I/O
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant StorageTest
participant MakoRuntime
participant StorageFile
StorageTest->>MakoRuntime: open and write storage data
MakoRuntime->>StorageFile: perform direct I/O
StorageFile-->>MakoRuntime: return operation status
MakoRuntime-->>StorageTest: return read/write results
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@runtime/mako_dio.h`:
- Around line 273-293: Update mako_file_read_exact so it returns an empty string
whenever the read loop completes with total less than count, freeing the
allocated buffer first; only null-terminate and return the buffer after exactly
count bytes have been read, preserving the existing handling for invalid inputs,
allocation failure, and read errors.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 80c2381d-cfcb-4a3d-b959-02d56c9659bf
📒 Files selected for processing (8)
.github/workflows/ci.ymlCHANGELOG.mdREADME.mddocs/BUILTINS.mddocs/STDLIB.mdexamples/ci/windows_direct_io_test.mkoexamples/testing/storage_portable_io_test.mkoruntime/mako_dio.h
| static inline MakoString mako_file_read_exact(int64_t fd, int64_t count) { | ||
| if (fd < 0 || fd > INT_MAX || count <= 0 || (uint64_t)count >= (uint64_t)SIZE_MAX) { | ||
| return mako_str_from_cstr(""); | ||
| } | ||
| char *buf = (char *)malloc((size_t)count + 1); | ||
| if (!buf) return mako_str_from_cstr(""); | ||
| size_t total = 0; | ||
| while (total < (size_t)count) { | ||
| size_t remaining = (size_t)count - total; | ||
| unsigned int chunk = remaining > 0x7ffff000U ? 0x7ffff000U : (unsigned int)remaining; | ||
| int got = _read((int)fd, buf + total, chunk); | ||
| if (got <= 0) break; | ||
| total += (size_t)got; | ||
| } | ||
| if (total == 0) { | ||
| free(buf); | ||
| return mako_str_from_cstr(""); | ||
| } | ||
| buf[total] = 0; | ||
| return (MakoString){buf, total}; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Compare with the POSIX implementation and inspect callers' expectations.
rg -nP -C3 '\bmako_file_read_exact\b'Repository: loreste/mako
Length of output: 150
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Map the target file and nearby symbols first.
ast-grep outline runtime/mako_dio.h --view expanded || true
printf '\n--- file slice ---\n'
sed -n '240,330p' runtime/mako_dio.h
printf '\n--- related reads/searches ---\n'
rg -n -C 3 'mako_file_read_exact|_read\(|read_exact|short-read|EOF' runtime . || trueRepository: loreste/mako
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the header around the function and search for any call sites or docs.
sed -n '1,240p' runtime/mako_dio.h
printf '\n--- targeted search ---\n'
grep -RIn --exclude-dir=.git --exclude='*.min.*' -E '\bmako_file_read_exact\b|read_exact|exact bytes|short read' .Repository: loreste/mako
Length of output: 10403
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the POSIX implementation of mako_file_read_exact and nearby comments.
sed -n '760,815p' runtime/mako_dio.h
printf '\n--- docs contract ---\n'
sed -n '200,220p' docs/STDLIB.md
printf '\n--- builtin docs ---\n'
sed -n '310,330p' docs/BUILTINS.md
printf '\n--- example usage ---\n'
sed -n '1,40p' examples/testing/storage_portable_io_test.mko
printf '\n--- codegen call site ---\n'
sed -n '15090,15115p' src/codegen/mod.rsRepository: loreste/mako
Length of output: 7226
file_read_exact returns partial data on EOF/short reads
This helper returns a non-empty truncated buffer when _read stops early, so it does not actually guarantee count bytes. That contradicts the “exact” contract and can let callers continue on incomplete data; return empty/error on short reads, or rename/document it as best-effort.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@runtime/mako_dio.h` around lines 273 - 293, Update mako_file_read_exact so it
returns an empty string whenever the read loop completes with total less than
count, freeing the allocated buffer first; only null-terminate and return the
buffer after exactly count bytes have been read, preserving the existing
handling for invalid inputs, allocation failure, and read errors.
Adds native Windows support for descriptor I/O, memory maps, and WAL-backed storage primitives. Unbuffered reads and writes use aligned buffers so ordinary Mako strings work while retaining the operating system's size and offset requirements.
Tests: cargo test --bin mako; storage_portable_io_test; windows_direct_io_test.
Upstream main currently has a Windows task-result CI regression covered by #14; any matching crew_fan failure is unrelated to this change.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests