Repository navigation
Ariadne: each document's host functions are its own when two runtimes share an app - #1305
Merged
Merged
Conversation
… share an app Two AppRuntimes on one cvc::app, both documents loaded before either runs: the first document's export call reached the second document's guest. Each AppRuntime bound its verbs and host functions through a provider on the app (register_action_intrinsics), and every program env on the app ran all of them, the last registered winning. A scripting engine's exports are host functions, so wasm guests, Python's console natives and a python: block's export: all crossed; so did the verbs, quit and the (data-*) verbs, and a third document's has? and requires: saw the others' names. Runtime::add_program_intrinsics: a provider of the Runtime's own, run after the app's in every program env that Runtime builds (an action, a resident, a child, start_process, a module's init:, the has?/requires: probe) and in no other's. Runtime::program_intrinsics() hands them to run_init (a new defaulted `own` parameter) for the document's init: and its children. AppRuntime registers its provider there instead of on the app. The list lives on Runtime::Impl: no new mutable state outside it. Tests, failing first on master: - ScriptEngineTest.TwoDocumentsOnOneAppEachCallTheirOwnExports - WasmEngineTest.TwoDocumentsOnOneAppEachCallTheirOwnGuest - ArixEngine.TwoDocumentsOnOneAppEachRunTheirOwnPython, a ctest entry of its own (arix_engine_two_documents): each case boots an interpreter.
transfix
added a commit
that referenced
this pull request
Nov 16, 2026
# Conflicts: # src/cvc/CMakeLists.txt
transfix
added a commit
that referenced
this pull request
Nov 16, 2026
…#1305, #1310, #1311) #1305 gives each Runtime program-lane providers of its own (add_program_intrinsics), so two documents on one app no longer reach each other's verbs and host functions, and moves AppRuntime's provider there from the app's list. This branch had split that provider in seven, each registered on the app with its kind (S1-Q7). Conflicts in ariadne.h, app_runtime.cpp and ariadne.cpp keep both: - Runtime::add_program_intrinsics takes a kind too (the form without one is host_only, as register_action_intrinsics's), and the Runtime's own list keeps it. AppRuntime adds its seven providers there, each with the kind it had, in the same order. - install_providers runs any list by kind; the Runtime's own run after the app's, by the same rules, wherever an env is built: an action, a resident, a spawned child (finish_context), the names probe, and init: and a module's init: (every kind as it is, on their own thread). - host_only_bindings counts the Runtime's own host_only providers, so one that binds anything pumps the document's group on the host thread, as an app provider does. - add_program_intrinsics marks the placement stale, as a late host verb does. - The own list is read where an env is built, a spawned child's on its pumping worker, so it is under a mutex of its own (own_mutex), copied, and run unlocked; names_mutex no longer guards it. STATE_EXEC_THREADED.md: the Runtime's own providers, AppRuntime's seven among them, and the fourth late-registration path. Built locally (MSVC Release; AB.lock held the box, so the suites were not run here); a test of the own providers by kind follows.
transfix
added a commit
that referenced
this pull request
Nov 17, 2026
AriadneIsolatedDocs.ARuntimesOwnProvidersInstallByKind covers what the #1305 merge (dc4f36d) gave Runtime::add_program_intrinsics: a kind, run by the same rules as the app's providers. In an isolated document's group, forced to move between threads (CVC_EXEC_FORCE_MOVE), an own `any` provider binds on the worker and an own host_proxied one runs only on the frame's thread; the group stays `any`. On a second Runtime of the same app, an own provider with no kind (host_only) that binds a function gives that document's group `host`. Each Runtime's has_function sees only its own providers' names.
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.
Two
AppRuntimes on onecvc::app, both documents loaded before either runs: the first document's export call reached the second document's guest. G6's work onProcExitEndsTheGuestNotTheHost(#1199) found it: documentart's(args)returned documentplain's argc.Cause
Each
AppRuntimebound its verbs and host functions through oneregister_action_intrinsicsprovider on the app. Every program env on that app ran every runtime's provider, in the order they were registered, so the last runtime'swhooverwrote the first's in the first document's own env.A scripting engine's exports are host functions (
ScriptLane::export_function/export_activation→AppRuntime::register_function/register_async_work_function), so every language had the flaw:python:block'sexport:throughpycvc.host_function;register_verb,quit) and the(data-*)verbs, which bound under the other document's prefix.The same leak made a third document's
(has? "who")and itsrequires:see the other documents' exports.The existing tests didn't catch it because they only start a second
AppRuntimeafter the first one is done.Fix
The provider is now the document's own, not the app's:
Runtime::add_program_intrinsics(provider). The provider runs in every program env that Runtime builds, after the app's providers, and in no other Runtime's. That coversmake_action_context(actions, residents, children,start_process), the names probe (has?,requires:), and a mounted module's init:.Runtime::program_intrinsics()plus a new trailingownparameter onrun_init. The document's owninit:, and the children it spawns, get them too.AppRuntime::ensure_intrinsicsregisters onrt_instead of the app.The list lives on
Runtime::Impl, so there are no new mutable statics and nothing goes onto the allowlist. The app'saction_intrinsics_tableis untouched. A gone runtime's provider now goes with it, instead of staying in the app's list with emptied verbs.ActionIntrinsicProvider's alias moves up inariadne.hsoRuntimecan name it.run_init's new parameter is defaulted, so existing callers compile unchanged.Tests (failing first)
Each new test loads two documents on one app that export the same name, and calls each one before the other runs. All three failed on master in this tree before the fix:
ScriptEngineTest.TwoDocumentsOnOneAppEachCallTheirOwnExports(stub engine): a function, an activation, its-asyncform, init: on a reload, and a bare third document'shas?. On master the first document gotui.s2for each, and the third document'shas?answeredyes.WasmEngineTest.TwoDocumentsOnOneAppEachCallTheirOwnGuest: two guests whose(who)answer 1 and 2, called from an action, as a future, and from init:. On master the first document got2.ArixEngine.TwoDocumentsOnOneAppEachRunTheirOwnPython: the console natives on master ran the first document's cell in the second document's namespace (2). Itsexport:half needs pycvc, so the test now gets the build's pycvc paths, and it skips that half where pycvc can't be imported. It is a ctest entry of its own (arix_engine_two_documents, through--gtest_filter), because each case boots an interpreter and a process boots one only once.To check that the fix is that one line: with only
ensure_intrinsics' registration put back on the app, all three fail again, the Pythonexport:half included ((which)answered2).Local results
Windows, MSVC Release, static. The tree has arix with Python (cvcpkg python312), wasmtime, and pycvc core. All of it ran on this change over master 591b8f4. The rebase onto 3976ae2 adds only #1304, which is cvcGL and not in this tree. Head is 98ff1cc.
ctest -R "Wasm|wasm|wasi|Wasi|ScriptEngine|arix|AriadneRequires|ari_python|ari_wasm": 134/134 passed.arix_matplotlib_backendskipped, since this Python has no matplotlib. That run covers:ariadne_wasm_test(48 cases, among themWasmEngineTest16)ariadne_script_engine_test32ariadne_requires_test20arix_engine_testandarix_engine_two_documents(itsexport:half ran, not skipped)ariadne_runtime_test300/300, whole suite, one process.ariadne_host_test59/59.Overlap
#1088 (threaded Stage 1b) rewrites
AppRuntime::ensure_intrinsicsinto providers by kind, still registered on the app, and dropsaction_intrinsics_snapshot. Whichever of the two lands second has to carry the other over: here, that means the per-runtime registration andrun_init'sown. #1276 adds tests beside the onessrc/ari/CMakeLists.txtchanges here.