37 lines
3.1 KiB
Markdown
37 lines
3.1 KiB
Markdown
# IO Portable Driver, BufferLease, Mock Backend, and Linux Epoll Driver
|
|
Task ID: S-IO-01, S-IO-02
|
|
Phase: P1
|
|
Status: APPROVED
|
|
Contracts: C-01, C-02, C-03, C-04, C-06
|
|
|
|
## 1. Context and baseline
|
|
VoidLibrary currently has no `IO` module (`src/IO/`, `include/Void/IO/`). Now that `Async` (`M-ASYNC-02`, `M-ASYNC-03`) and `Time` (`M-TIME-02`) are in place, `IO` can expose a dependency-minimal native descriptor/stream layer (`INTERNAL_DEPS Core Functional Time Memory Async`) with zero dependency on `Net`, `Runtime`, `System`, or `Log`.
|
|
|
|
## 2. Deliverables
|
|
- `src/IO/module.cmake` (`INTERNAL_DEPS Core Functional Time Memory Async`).
|
|
- `include/Void/IO/Types.hpp`: `IoErrorCode` (`kIoErrorDomain = 8`), `make_io_error`, `Transfer`, `ComposedTransferError`, `IoLimits`, `BackendPreference`, `BackendOptions`, `DescriptorId`, `DriverTelemetry`, and PMR/quota-tracked `BufferLease`.
|
|
- `include/Void/IO/Driver.hpp`, `include/Void/IO/Stream.hpp`, `src/IO/EpollDriver.cpp`:
|
|
- `Driver` (`create`, `allocate_buffer`, `create_mock_stream`, `mock_controller`, `adopt_fd`, `create_socket_pair`, `poll_once`, `wake`, `request_stop`, `shutdown_and_join`, `telemetry`, `active_backend`).
|
|
- `ByteStream` (`read_some`, `write_some`, `read_some_owned`, `write_some_owned`, `close_and_join`) plus composed `read_exact` / `write_all`.
|
|
- Portable `MockBackend` for deterministic concurrency/stop-race verification and Linux level-triggered `EpollBackend` (no `EPOLLET`, `eventfd` wakeups, `(slot, generation)` tokens).
|
|
- `tests/standalone/IO/IoDriver.cpp` and installed package consumer `tests/package/IOOnly/{CMakeLists.txt,main.cpp}` registered in `tests/package/InstalledComponents.cmake`.
|
|
|
|
## 3. Exact files and interfaces
|
|
- `src/IO/module.cmake`, `src/IO/EpollDriver.cpp`
|
|
- `include/Void/IO/{Types,Driver,Stream}.hpp`
|
|
- `tests/standalone/IO/IoDriver.cpp`
|
|
- `tests/package/IOOnly/{CMakeLists.txt,main.cpp}`, `tests/package/InstalledComponents.cmake`
|
|
|
|
## 4. Edge cases
|
|
- Zero-length `read_some`/`write_some` succeeds immediately (`Transfer{0, false}`) without probing EOF.
|
|
- Same-direction overlapping operation on a stream rejects with `IoErrorCode::busy`; simultaneous `read_some` + `write_some` succeeds.
|
|
- Pre-stopped options or expired injected `MonotonicClock` deadline rejected before backend submission; active ops never resume continuations while backend holds `backend_refs` or borrowed buffers.
|
|
- Linux epoll level-triggered handling handles `EAGAIN`/`EINTR`/short transfers, drains buffered data before `EOF`/`HUP`, ignores stale `(slot, generation)` events after fd reuse, and keeps `EPOLLOUT` disabled when no write is pending.
|
|
|
|
## 5. Acceptance criteria
|
|
- `Io*` tests and `VoidInstalledComponentConsumers` (`IOOnly`) pass under `-DVOID_WARNINGS_AS_ERRORS=ON`, ASan+UBSan, and Debug TSan (`-DVOID_ENABLE_TSAN=ON`).
|
|
|
|
## 6. Verification commands
|
|
```sh
|
|
dev cpp-gcc -c bash -lc 'cmake -S . -B /tmp/void-w4b-io -G Ninja -DVOID_ENABLED_MODULES="IO;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-w4b-io && /tmp/void-w4b-io/tests/VoidTests --filter "Io*" && ctest --test-dir /tmp/void-w4b-io --output-on-failure --timeout 60'
|
|
``` |