feat(wasm-runtime): add exec, time host function modules and type bridge - #18
Conversation
…idge Extend the WASM host runtime with new host function modules for subprocess execution and timestamp access, a type bridge for WASM boundary serialization, and an end-to-end evaluation convenience method on ChallengeInstance. New modules: - exec.rs: `platform_exec` host function module with `exec_command` that runs sandboxed subprocess execution via std::process::Command. Enforces allow-lists, argument blocking, env var filtering, timeouts, output size limits, and per-instance execution count caps through a configurable ExecPolicy. Includes ExecState for tracking execution counts and ExecHostFunctions registrar. - time.rs: `platform_time` host function module with `get_timestamp` returning either a real system timestamp or a deterministic fixed value, controlled by TimePolicy (with Real and Deterministic modes). Includes TimeState and TimeHostFunctions registrar. - bridge.rs: Type bridge between SDK evaluation types and WASM boundary types. Defines EvalRequest/EvalResponse structs and provides conversion functions (request_to_input, input_to_bytes, bytes_to_output, output_to_response) that serialize via bincode for the WASM memory boundary. Uses EvaluationInput/ EvaluationOutput from platform-challenge-sdk-wasm. Runtime integration (runtime.rs): - RuntimeState now carries ExecState and TimeState alongside NetworkState - InstanceConfig extended with exec_policy and time_policy fields - ExecHostFunctions and TimeHostFunctions registered in the linker during instance creation, gated by policy configuration - Added BridgeError variant to WasmRuntimeError with From impl - ChallengeInstance gains evaluate_request() method for end-to-end evaluation: bridges EvalRequest to WASM input, allocates WASM memory, calls evaluate export, reads output, and bridges back to EvalResponse - Added exec_executions() and reset_exec_state() convenience methods Dependencies (Cargo.toml): - Added platform-challenge-sdk-wasm (path dependency) and serde_json
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ 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 |
…ost-modules-and-type-bridge
…ost-modules-and-type-bridge
Summary
Extends the WASM host runtime with new host function modules (
platform_exec,platform_time) and a type bridge for converting between native SDK types and WASM-boundary types.Changes
New host function modules
exec.rs:platform_exechost function module withexec_commandfor sandboxed subprocess execution usingstd::process::Command, controlled byExecPolicy(allow-lists, timeouts, resource limits)time.rs:platform_timehost function module withget_timestampreturning deterministic or real timestamps, controlled byTimePolicyandTimeModeType bridge
bridge.rs: Conversion functions betweenchallenge-sdk::EvaluationRequest/EvaluationResponseandchallenge-sdk-wasm::EvaluationInput/EvaluationOutput, serialized via bincode for the WASM boundaryIntegration
runtime.rsalongside existing network/storage modules, gated by policy configurationevaluate_requestconvenience method toChallengeInstancefor end-to-end evaluation (bridge input → write to WASM memory → call evaluate → read output → bridge back)platform-challenge-sdk-wasmandserde_jsonas dependencieslib.rs