Repository navigation
feat(capi): add owned Python and TypeScript host calls - #2742
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 31e9bef | Commit Preview URL Branch Preview URL |
Oct 16 2026, 09:23 PM |
chaliy
force-pushed
the
feat/c-runtime-host-functions
branch
from
October 16, 2026 21:22
8997cdb to
31e9bef
Compare
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
C hosts can opt into embedded Python and TypeScript and register one ABI v1 dispatcher for named functions. Each callback receives an owned call handle that can be answered immediately or transferred to an I/O worker. Responses copy bounded JSON into the library; cancellation/deadline revokes the call and rejects late replies.
Callback-enabled handles return BUSY for concurrent blocking operations, and blocking callback reentry is rejected. Existing handles retain their serialization behavior. Runtime registration preserves the selected profile's VM limits. JSON conversion also rejects integer-overflow literals that serde_json would otherwise round into floating-point values.
Why
Complete native C callback parity after the JavaScript SDK (#2740).
Before / After
Before: ABI v1 had no embedded runtime or host-function callback API.
After: the C11 example dispatches Python lookup() and TypeScript await lookup(), producing 42 twice through the actual shared library. Local validation includes 19 existing ABI tests, 10 runtime tests, three shared codec tests, C/C++ header compilation, full pre-PR checks, feature-sliced Rust tests, all-feature Clippy and the parallel benchmark. Tests cover caller-thread affinity, cross-thread replies, eight concurrent instances, idle-handle migration between threads, cancellation/deadline/reuse, calls retained after handle destruction, invalid input, abandonment, reentry and hardened memory limits.
Risk
Medium: additive foreign ownership and callback lifetime contract. Hosts must free each call once, preserve callback/user-data lifetime, avoid destructor races/unwinding, and cooperate with cancellation. Existing symbols and ABI version remain unchanged; no Rust future or allocator ownership crosses the boundary.
Checklist