feat(wasi): component directory enumeration under --wasi-fs (SR-39, closes #405) - #409
Merged
Merged
Conversation
…loses #405) After SR-37 (get-directories) and SR-38 (file read), a preview2 component read a file end-to-end but std::fs::read_dir still failed: open-at(dir) then wasi:filesystem/types::[method]descriptor.read-directory hit [Runtime][E07DA] Function not found in exports. Both read-directory and directory-entry-stream.read-directory-entry were unimplemented — no dispatch_core handler and no wasip2_host signature, so the calls fell through. Implemented directory enumeration: - descriptor.read-directory(self) -> result<directory-entry-stream, error-code>: snapshots std::fs::read_dir entries as (descriptor-type, name) with a cursor, keyed by a fresh stream handle (`.`/`..` excluded, matching preview2). - directory-entry-stream.read-directory-entry(self) -> result<option<directory-entry>, error-code> where directory-entry = record { type: descriptor-type, name: string }: returns the next entry (name in a fresh cabi_realloc'd guest buffer via the SR-38 on-demand mechanism, extended to read-directory-entry with a filename-sized buffer) or none at end. - Signatures added to wasip2_host.rs; the record is modelled as Tuple(U8, String) and the enum as U8, which lower_results_to_retptr already lowers correctly (Result -> Option -> Tuple -> {u8 padded to 4, string ptr+len}). Verified end-to-end: kilnd now matches `wasmtime run --dir .::.` for both READ:CANARY and DIR:[...] (single- and multi-entry dirs incl. a subdir). Unit oracle read_directory_enumerates_entries_then_none asserts enumeration + none. Also: added serial_test as a kiln-wasi dev-dependency and marked the 5 new SR-37/38/39 dispatcher tests #[serial_test::serial] — they build a WasiDispatcher that draws the global capability budget, which contends under parallel test runs. A broader pre-existing flakiness in the same suite (unrelated capability tests) is filed separately as SR-40. Trace: SR-39
🔍 Build Diagnostics ReportSummary
🎯 Impact AnalysisIssues in Files You Modified
Cascading Issues (Your Changes Breaking Other Files)
✅ No Issues DetectedPerfect! Your changes don't introduce any new errors or warnings, and don't break any existing code. 📊 Full diagnostic data available in workflow artifacts 🔧 To reproduce locally: # Install cargo-kiln
cargo install --path cargo-kiln
# Analyze your changes
cargo-kiln build --output json --filter-severity error
cargo-kiln check --output json --filter-severity warning |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
avrabe
added a commit
that referenced
this pull request
Jul 10, 2026
…) (#410) Version bump 0.4.0 → 0.4.1. Ships the complete component filesystem read/list fix for WASI Preview2 components under kilnd --wasi --component --wasi-fs: - SR-37 (#406): get-directories returns a guest-usable preopen list. - SR-38 (#407): file read (blocking-read) returns bytes in a guest-owned buffer with offset/EOF tracking. - SR-39 (#409): directory enumeration (read-directory / read-directory-entry). Together these make a preview2 component read and list files under a preopen, matching `wasmtime run --dir`. Closes #405. Trace: SR-39
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
Third and final layer of #405. After SR-37 (get-directories, #406) and SR-38 (file read, #407), a preview2 component could read a file but
std::fs::read_dirstill crashed with[Runtime][E07DA] Function not found in exports:descriptor.read-directoryanddirectory-entry-stream.read-directory-entrywere unimplemented (no handler, no signature).Fix
descriptor.read-directory→result<directory-entry-stream, error-code>: snapshotsstd::fs::read_direntries as(descriptor-type, name)with a cursor, keyed by a fresh stream handle (./..excluded, matching preview2).directory-entry-stream.read-directory-entry→result<option<directory-entry>, error-code>wheredirectory-entry = record { type, name }: returns the next entry (name in a freshcabi_realloc'd guest buffer via SR-38's on-demand mechanism, extended to this call) ornoneat end.wasip2_host.rs; the record is modelled asTuple(U8, String)and the enum asU8, whichlower_results_to_retptralready lowers correctly.Verification
wasmtime run --dir .::.for bothREAD:CANARYandDIR:[…]— single-entry and a multi-entry dir with a subdir (types + ordering match).read_directory_enumerates_entries_then_none(// rivet: verifies SR-39).Also
Added
serial_testas a kiln-wasi dev-dep and marked the 5 SR-37/38/39 dispatcher tests#[serial_test::serial](they draw the global capability budget). A broader pre-existing flakiness in the same suite (unrelated capability tests, confirmed on clean main) is filed as SR-40 — not fixed here.Closes #405.
Trace: SR-39
🤖 Generated with Claude Code