Repository navigation
Description
Context
Third dependency-ordered foundation for #13 and #14. It depends on #15 and #16 and establishes the first real bulk-data/authority boundary: quota-accounted opaque blobs and one exact native output-file capability. #14 needs this to persist a screenshot without passing PNG bytes or a filesystem path through Wasm.
Depends on
- feat(wasm): prove a streamed kernal-api Rust sketch runtime with zccache and extension2 cores #13 selects one private runtime/binding implementation and owns streaming/backpressure policy.
- feat(wasm): establish threaded sketch build, import validation, and lifecycle substrate #15 provides validated threaded execution and lifecycle containment.
- feat(wasm): add generated async kernel ABI and generation-safe resources #16 provides the generated async ABI, capability scoping, resource identity, cancellation, and cleanup model.
Extend that one ABI and resource registry only. Do not add a direct helper, side channel, second serialization mechanism, or native copy of sketch logic.
Proposal
Implement facade-owned generated-ABI semantics equivalent to:
async fn blob_write_chunk(blob: WritableBlob, bytes: &[u8]) -> Result<WriteProgress, BlobError>;
async fn blob_read_chunk(blob: ReadableBlob, max_bytes: u32) -> Result<ReadChunk, BlobError>;
async fn blob_close(blob: BlobHandle) -> Result<(), BlobError>;
async fn write_blob_to_output(blob: ReadableBlob, output: OutputFile) -> Result<(), OutputWriteError>;Final generated names may differ, but the model is fixed: blobs are opaque host resources rather than Vec<u8> ABI values; transfers are bounded chunks; output is an exact native capability rather than a guest path; final output is atomically committed only after success.
The embedding CLI/host canonicalizes and authorizes one exact output destination before guest instantiation. The guest receives only a scoped OutputFile handle. write_blob_to_output writes a sibling temporary file, flushes/closes it, then atomically replaces the authorized final path. Failure/cancellation/trap/teardown removes the temporary file and leaves no partial final output. If atomic replacement is unavailable, return a typed failure instead of silently degrading.
Backpressure and quota contract
kernal-api owns backpressure. Enforce configurable maximum chunk size, live blobs, per-blob bytes, per-sketch blob bytes, pending reads/writes, and in-flight transfer bytes.
- Reads are pull-based: no additional bytes until a bounded request.
- Writes await downstream capacity, not an unbounded queue.
- Fast production stops at capacity and resumes after capacity release.
- Pending I/O is cancellable.
- Close, cancellation, trap, guest-thread exit, and teardown release permits/buffers exactly once.
- Blob/output handles remain generation-safe and cross-instance use fails deterministically.
Future native image capture may internally materialize a platform result, but must create a bounded quota-accounted blob. PNG/image bytes never cross the Wasm ABI as one serialized value.
Invariants
- Types/errors are facade-owned semantic types; no Tokio, Wasmtime, fp-bindgen/WIT, descriptor, native file, Tauri, WebKitGTK, WebView2, WKImage, or platform image types are public.
default = []must not resolve or compile engine, generator, GUI, capture, or image-encoder dependencies.- Existing private atomic-replace support may be used internally but raw paths/implementation types are not guest API.
- Do not add a speculative generic storage trait or separate public data crate.
- Future non-Tauri producers/consumers use this same opaque-resource protocol.
Non-goals
- Tauri/window navigation/page-load/screenshot capture.
- Arbitrary file read/write, directory authority, filesystem sandbox, or ambient WASI filesystem support.
read_to_end, full-image serialization, JavaScript bridge, WebDriver, OS-desktop capture, compression, or archive APIs.
Acceptance criteria
- RED: checked-in tests prove current guest/host code has no opaque blob or exact output-file capability and would require raw bytes or a raw path.
- RED: regression tests reject whole-value payload exchange, ambient filesystem imports, raw guest paths, and cross-instance output handles.
- GREEN: a guest transfers at least 64 MiB through the real generated ABI in bounded chunks without total-length guest or ABI allocation.
- GREEN: instrumentation proves peak outstanding bytes stay within configured per-transfer/per-sketch budgets independent of total length.
- GREEN: fast-producer/slow-consumer testing proves capacity-awaited writes stop at the configured limit and resume after consumption.
- GREEN: pull reads produce nothing until the consumer asks for a bounded chunk.
- GREEN: cancellation while reads/writes are pending wakes both sides, releases capacity, and returns typed errors.
- GREEN: stale, double-closed, forged, and cross-instance blob/output handles fail deterministically.
- GREEN: close, cancellation, trap, thread exit, timeout, and teardown return blob/buffer/permit/pending-operation counters to zero.
- GREEN: host grants one exact output destination; guest writes only through
OutputFileand has no raw path or directory authority. - GREEN: successful bounded blob output is byte-identical at the authorized path through sibling-temp-file flush/close/atomic replacement.
- GREEN: injected write/flush/rename/cancellation/teardown failures leave no partial final file and remove the temporary file.
- GREEN: default-feature checks remain free of sketch, GUI, capture, and image-encoder dependency resolution.
- GREEN: focused format/lint/build/test commands are documented through Soldr.
Platform matrix and deliverables
Compile on Linux, macOS, and Windows x86-64/ARM64. Run output atomicity/cleanup tests natively on each operating-system family and report target, quotas, total transfer, peak accounted bytes, commit result, and temporary-file cleanup result. Platform replacement differences require facade-owned tests and typed errors, not best effort.
Deliver opaque blob/output ABI support, quota/backpressure instrumentation, native output grant/atomic commit implementation, large-transfer/slow-consumer/cancellation/handle/cleanup tests, focused Soldr documentation, and a short future-producer/consumer contract.
Decisions
- This is P1 because feat(wasm): drive a Tauri screenshot task through the async kernal API #14 cannot safely write a screenshot without it.
- Exact-output authority is deliberately narrower than filesystem authority.
- Large transfer and atomicity proofs land before GUI capture so the screenshot path cannot weaken backpressure or output integrity.
Related issues
- feat(wasm): prove a streamed kernal-api Rust sketch runtime with zccache and extension2 cores #13 owns the runtime, streaming/backpressure, and capability contract.
- feat(wasm): establish threaded sketch build, import validation, and lifecycle substrate #15 establishes threaded module validation/lifecycle.
- feat(wasm): add generated async kernel ABI and generation-safe resources #16 establishes the generated async resource ABI.
- feat(wasm): drive a Tauri screenshot task through the async kernal API #14 will capture a viewport into an opaque blob then commit it through this exact output capability.
Activity
zackees commentedon Sep 14, 2026
Completed by PR #153 (merge fddd176). Bounded opaque blobs, exact-output authority, 64 MiB real guest transfer, quota/backpressure/cancellation/cleanup coverage, and native artifact proof lanes landed. Run 34801708129 passed every archive and screenshot artifact lane across Linux/macOS/Windows x86-64 and ARM64.