Skip to content

feat(wasm-runtime): add exec, time host function modules and type bridge - #18

Merged
echobt merged 6 commits into
mainfrom
feat/wasm-exec-time-host-modules-and-type-bridge
Feb 17, 2026
Merged

feat(wasm-runtime): add exec, time host function modules and type bridge#18
echobt merged 6 commits into
mainfrom
feat/wasm-exec-time-host-modules-and-type-bridge

Conversation

@echobt

@echobt echobt commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

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_exec host function module with exec_command for sandboxed subprocess execution using std::process::Command, controlled by ExecPolicy (allow-lists, timeouts, resource limits)
  • time.rs: platform_time host function module with get_timestamp returning deterministic or real timestamps, controlled by TimePolicy and TimeMode

Type bridge

  • bridge.rs: Conversion functions between challenge-sdk::EvaluationRequest/EvaluationResponse and challenge-sdk-wasm::EvaluationInput/EvaluationOutput, serialized via bincode for the WASM boundary

Integration

  • Registered new host functions in runtime.rs alongside existing network/storage modules, gated by policy configuration
  • Added evaluate_request convenience method to ChallengeInstance for end-to-end evaluation (bridge input → write to WASM memory → call evaluate → read output → bridge back)
  • Added platform-challenge-sdk-wasm and serde_json as dependencies
  • Exported new types and modules from lib.rs

…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
@coderabbitai

coderabbitai Bot commented Feb 17, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@echobt has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 50 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/wasm-exec-time-host-modules-and-type-bridge

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@echobt echobt closed this Feb 17, 2026
@echobt
echobt merged commit 6ba85e5 into main Feb 17, 2026
11 checks passed
@echobt
echobt deleted the feat/wasm-exec-time-host-modules-and-type-bridge branch February 17, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant