Host type checking

SA
17d ago
+773-54

Summary by cubic

Adds a host-type-checking feature to monty-proto so a worker can serve type-checked sessions without linking ty. Instead of checking locally, the worker parks each feed and sends a host-internal WorkerEvent.host_type_check carrying everything the check needs; the host runs ty elsewhere and answers with ClientRequest.host_type_check_result, after which the worker either runs the snippet or ends the turn with the typed diagnostics.

  • New Features
    • monty-wasm-runtime exposes host-type-checking for size-sensitive hosts that build with --no-default-features.
    • monty-type-checking moves ty and its dependencies behind an optional, default-on checker feature so scan_imports is available alone.
  • Both messages are host-internal and never reach a client, so only a host able to answer them may build this way; type-checking wins when both features are enabled.
  • Every host_type_check field is untrusted worker output, so the host must bound the check itself (nesting depth, memory, time); the worker's nesting check and allocator ceiling don't cover it.
  • The wasm component retires on a fatal event, so a worker parked on a HostTypeCheck that a typed export can't answer isn't reused.
  • The new test suite (cargo test -p monty-proto --features host-type-checking --test host_type_checking) plays the answering host, covering stubs, module stubs, dumps, aborts, and protocol violations, and is wired into CI coverage and testcov.