Skip to content

feat(wasm-runtime): complete host function infrastructure for WASM challenges - #50

Merged
echobt merged 4 commits into
mainfrom
feat/wasm-runtime-infrastructure-gaps-c755vt
Feb 18, 2026
Merged

feat(wasm-runtime): complete host function infrastructure for WASM challenges#50
echobt merged 4 commits into
mainfrom
feat/wasm-runtime-infrastructure-gaps-c755vt

Conversation

@echobt

@echobt echobt commented Feb 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes multiple gaps in the WASM runtime infrastructure so that external challenge modules (e.g. term-challenge) built against platform-challenge-sdk-wasm can be loaded with full feature support — container execution, challenge data loading, correct ABI handling, and proper storage wiring.

Changes

Storage host functions

  • Register storage_delete and storage_propose_write handlers in StorageHostFunctions::register() (previously declared but never linked)
  • Add guest-side extern "C" declarations and wrapper functions in the SDK

ABI & type alignment

  • Fix get_tasks executor to use call_return_i64 and unpack packed ptr|len (was incorrectly calling call_return_i32 + non-existent get_tasks_result_len)
  • Add missing metrics and details fields to executor-side EvaluationOutput (with #[serde(default)] for backward compat)
  • Add task_definition and environment_config to executor-side EvaluationInput
  • Fix bridge score conversion: divide by 10_000.0 instead of 100.0 to match score_f64_scaled

Container execution delegation (platform_container)

  • New container.rs module with container_run host function, ContainerPolicy, ContainerRunRequest/ContainerRunResponse types
  • Executes containers via docker run with configurable image allowlist, memory/CPU limits, network mode, timeout, and per-execution container count cap
  • Registered in runtime.rs linker; guest-side types exported from SDK

Challenge data loading (platform_data)

  • New data.rs module with data_get and data_list host functions, DataPolicy, filesystem-backed DataBackend
  • Allows WASM modules to read challenge-specific data files (task definitions, configs) by key with path traversal protection
  • Registered in runtime.rs linker

Storage backend wiring

  • WasmExecutorConfig now accepts an Arc<dyn StorageBackend> and passes it through to InstanceConfig (replaces NoopStorageBackend)
  • InstanceConfig fields for storage, container, and data state are set explicitly instead of relying on defaults

Arena allocator

  • Add huge-arena feature (16 MiB) to challenge-sdk-wasm for complex challenges with large payloads
  • Properly gate large-arena vs huge-arena vs default with cfg precedence

Host function signature fix

  • Align http_get host registration signature with guest SDK declaration (5 params)

Testing

  • All existing tests pass (cargo test --workspace)
  • New unit tests for container policy, status codes, request serialization, and data backend

The host registered http_get with 3 params (req_ptr, req_len, resp_ptr)
but the guest SDK declares 4 params (req_ptr, req_len, resp_ptr, resp_len).
This mismatch caused WASM instantiation failures with 'incompatible import
type' when a module used http_get.

Added resp_len parameter to both the linker closure and handle_http_get
function. Removed the now-unused DEFAULT_RESPONSE_BUF_SIZE constant.
…and data modules

Add ..Default::default() to three InstanceConfig initializations in
wasm_executor.rs that were missing the container_policy, data_policy,
and data_backend fields introduced by the container and data module
integration.
@coderabbitai

coderabbitai Bot commented Feb 18, 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 1 minutes and 28 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-runtime-infrastructure-gaps-c755vt

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 merged commit ae9b049 into main Feb 18, 2026
21 checks passed
@echobt
echobt deleted the feat/wasm-runtime-infrastructure-gaps-c755vt branch February 18, 2026 10:10
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