Skip to content

feat(wasi): component directory enumeration under --wasi-fs (SR-39, closes #405) - #409

Merged
avrabe merged 1 commit into
mainfrom
fix/sr-39-directory-enumeration
Jul 10, 2026
Merged

feat(wasi): component directory enumeration under --wasi-fs (SR-39, closes #405)#409
avrabe merged 1 commit into
mainfrom
fix/sr-39-directory-enumeration

Conversation

@avrabe

@avrabe avrabe commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

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_dir still crashed with [Runtime][E07DA] Function not found in exports: descriptor.read-directory and directory-entry-stream.read-directory-entry were unimplemented (no handler, no signature).

Fix

  • descriptor.read-directoryresult<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-entryresult<option<directory-entry>, error-code> where directory-entry = record { type, name }: returns the next entry (name in a fresh cabi_realloc'd guest buffer via SR-38's on-demand mechanism, extended to this call) 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.

Verification

Also

Added serial_test as 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

…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
@github-actions

Copy link
Copy Markdown

🔍 Build Diagnostics Report

Summary

Metric Base Branch This PR Change
Errors 0 0 0
Warnings 5 5 0

🎯 Impact Analysis

Issues in Files You Modified

  • 0 new errors introduced by your changes
  • 0 new warnings introduced by your changes
  • 0 total errors in modified files
  • 0 total warnings in modified files
  • 0 files you modified

Cascading Issues (Your Changes Breaking Other Files)

  • 0 new errors in unchanged files
  • 0 new warnings in unchanged files
  • 0 unchanged files now affected

Note: "Cascading issues" are errors in files you didn't modify, caused by your changes (e.g., breaking API changes, dependency issues).

✅ No Issues Detected

Perfect! 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

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@avrabe
avrabe merged commit 5b569ca into main Jul 10, 2026
21 checks passed
@avrabe
avrabe deleted the fix/sr-39-directory-enumeration branch July 10, 2026 11:27
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant