Repository navigation
No singletons: libcvc's process-wide state per app, per object or gone [4.0, breaking] - #1203
Merged
Merged
Conversation
…t out libcvc keeps no process-wide state in code it controls. The scan blocked new statics, but a change could add the new symbol's line to the allowlist, and changes did: the list went on growing. - ratchet.py (new) fails a change whose allowlist has a line its base's does not; a moved or renamed object counts as new. It runs in the clang-format (changed lines) job, which needs only git and is a required check. - scan.py leaves third-party libraries' own statics out and counts them (THIRD_PARTY): Boost's, VTK's per-file Schwarz counters, libigl's, Eigen's, pocketfft's, the standard library's. Vendored code built into libcvc (SDF, cvc-mesher) stays scanned. - allowlist.txt drops those 289 lines. The 510 left are libcvc's own objects still to move (cvc 358, cvcGL 102, pycvc 32, cvc-cli 9, pycvc_gl 7, cvc_physics_jolt 2); the list only shrinks, to empty. - The scan's message, README and the roadmap say so. Tests: test_scan.py covers the third-party patterns (and that ours still count) and the ratchet (deletions pass, an added or moved line fails, the command's exit codes).
libcvc keeps no process-wide state in code we control. This removes 49 of Ariadne's allowlist lines (cvc 358 -> 309) without touching the registries' API. Bugs fixed: - WebSocket handles were process-wide: one app's documents could send to, read or close another app's connection by handle, and the cap was shared. The table is the app's (app.slot). - The section epoch was the process's; each app has its own (section_epoch(app)). - The building-library cache, open-url's rate limit and the Runtime owner ids are the app's. - Room-lane message ids are per sender under a random tag, as room-call ids are; the helper is shared (conference/message_ids.h). Constants built at first use are constexpr, built where used, or held by their owner: the repeat token, the special-form set, the key-name and capability-token tables (static constexpr), world_rules' word lists and fallbacks (new fallback_avatar / fallback_controller members), OIDC's kReply and options_dict, the placeholder RNG, the script engine's parsed bodies, tvision's palettes, ftxui's TERM check. API: section_epoch(app); capability_tokens() by value; lane_offer_message / lane_answer_message take the sender's serial. Tests: multi_app_integration_test (new): six apps' workloads give the same transcript alone, at once on threads and in reverse order, and differ from each other. StockWorldsMatchTheirTwins writes both apps with one epoch (it relied on the shared one).
… own Ariadne's document registries were process-wide: what one app registered, every app's documents saw. They are each app's own now (app.slot), and the loader checks a document against the app it loads for. Allowlist -19 lines (cvc 309 -> 290). - Widget types: register_widget_type / register_known_widget_type / has_widget_type take the app; the backends' register_widget(app, ...) declares a native widget to that app; register_status_dot_widget takes the app. - .ari blocks: register_ari_block / has_ari_block take the app; register_world_block / register_server_block / register_relay_block register per app (their process-wide once-flags are gone). - Data decoders: register_data_decoder / has_data_decoder / data_decoders take the app; every app starts with the built-ins. DataStore::of keeps the store in the app's slot. - Script engines: register / unregister / find / has_script_engine take the app. AppRuntime::use_script_engine registers the engine on its app, so ari's, arigl's and ariadne_python's engines no longer register process-wide. HostFacts::app answers the language tokens; capability_hint takes the app. - The loader: load_string(app, yaml), load_file(app, path); its context carries the app into imports and mounts. Tests: ariadne_registries_test adds two-apps (both orders), built-ins per app and threads cases; multi_app_integration_test's workload adds the registries; the script-engine and requires tests check another app sees nothing. Tests that registered and then loaded use one app; parse-only tests use a file-local fresh_load. Two scene-world tests had passed only because an earlier test registered the world: block for the process; their helpers now register it on their own app.
…s per app - The media player factory and the play policy are the app's: register_player_factory / have_player_factory / make_player / set_play_policy / play_policy / may_play_here and register_browser_player take the app, as does cvcMedia's register_ariadne_player. ari and arigl set up media for each app they make (setup_media) instead of once for the process. - The stream registry is the app's slot. It was a process-wide map keyed by app* that was never freed, so a new app at a reused address got the dead app's tokens and channel pointers. - Runtime::app() returns the app a runtime's document runs on. Allowlist -7 lines (cvc 290 -> 283). Tests: ariadne_media_test's FakeFactory registers on its test's app (made first); new APlayerFactoryIsItsAppsOwn, and ThePolicyAndTheTimeLine checks another app's policy; stream_test's AnAppsRegistryGoesWithIt; cvcmedia_player checks another app has no player; multi_app_integration_test's workload adds media and streams (every app opens a stream of the same name).
arisrvx reads its server document before it attaches Python, and a
server document never calls use_script_engine, so after script engines
became each app's own the relay's app had none: requires: python failed
("this host does not provide what the document requires: python"), and
the room-call tests that run such a document failed with it.
python::Engine::register_on(app) registers the engine on an app;
arisrvx calls it as soon as its app exists, and attach() does it for a
server host's app.
… per app Each app has its own URI resolver now. Allowlist -22 lines (cvc 283 -> 261); Ariadne keeps only host_signals' two (a signal handler's state is a process resource, Joe 2026-11-12). - uri.h: resolve / resolve_async / resolve_to_file / store, the handler, store-handler and async-handler registries, and the read and store byte caps take the app (an app slot). The built-in file reader takes the cap; the Windows temp-name token and counter are per call. - state:// resolves against the app it is registered on (register_state_uri_handler(app)): before, the last app to register answered every app's state:// reads. sync_resolver_caps_from_state takes the app. - HTTP: the options provider is the app's; register_http_uri_handler and the cached handler register on an app; the cache's single-flight map is the app's (two apps fetching one URL coalesced, and only the leader's cache was written). - enable_net / disable_net / net_host_status / net_host_access and enable_oidc / disable_oidc / pump_oidc / oidc_busy are per app. - Callers: the loader (its context's app), data loads (a local scheme resolves under with_app; the network wait holds no app), media (fetch_bytes(app, ...), PlayerSource::app set by make_player), the fetch verb, the relay session's credential source, the scene and cvcGL source resolvers, state_io (save_state / restore_state take the app), the hosts and examples (register_cvc_uri_handler(app, ...)). Tests: ariadne_registries_test adds URI handlers and caps per app (both orders), state:// reading each app's own tree, the net host per app, and apps on threads; multi_app_integration_test's workload adds URIs. The loader and runtime tests' guards that only undid process-wide registrations are gone; their tests use one app for registering and loading.
…riadne # Conflicts: # tools/singleton_scan/allowlist.txt
#1159 (O7c) kept the last source sea_surface found in a thread_local, so the velocity a fluid field reads after a cell's height at the same point and time did not invert the sideways move again. A thread_local that keeps state between calls is a static cache, which libcvc's no-singletons rule forbids (VOLROVER-LIBRARY-PORTS-ROADMAP.md 1.3, tools/singleton_scan). #1159's release-grpc job, where the scan runs, was cancelled, so the scan never judged it; the next PR that merges master would fail that lane on it. The memo now belongs to the caller: - sea_surface::source_memo, and height() / velocity() overloads that take one. The plain reads share nothing. - fluid_surface::height_with / velocity_with and a surface_memo the caller owns; the defaults ignore it. ocean_surface passes it to the sea. - field_set::apply keeps one memo per cell, for the cell's height and its velocity at the same clipped centre. The memo is keyed on the point, the time and the digest as before, so every value is unchanged.
…ing per app src/cvc/state (except state_exec) and state_object<T> keep no process-wide state. What each static held moves onto the app (app::slot) or into the object that uses it. Moved: - state::on_startup: the process-wide _startup/_appStartup registries, their mutex and id counter become the app's own hooks (slot cvc.state.startup-hooks). on_startup(app &, f) runs f once for that app, when its root is made, or at once if it was made already; a startup_connection names the hooks weakly, so it may outlive the app. The built-in __system.start default (and, with USING_XMLRPC, the __system.xmlrpc monitor) run from state::instance() itself instead of file-scope static registrars. - state_cluster_shard::default_for(app &): the default-shard map keyed by app address (never pruned, so a new app at a dead one's address could inherit its shard) becomes a per-app cell (cvc.state.default-shard). A shard keeps the cell it installed itself in, so uninstalling never touches the app. send_message's process-wide id counter becomes a per-shard random tag plus a count, so a shard made again under the same node id repeats no id (a peer's bus would drop it). - state_compression_registry::shared(app &): the process-wide registry is the app's own (cvc.state.compression-registry); shards and the session's hydrator use their app's. - state_sync_adapter: the thread_local suppression depth, shared by every adapter in the process, becomes the app's (cvc.state.sync-suppression): the threads applying a remote mutation to the app, or in a suppression_scope on it. A remote apply on one app no longer hides a local change to another app made on the same thread (an inproc fan-out, or a slot the apply sets off). - register_volume_geometry_codecs(app &, registry): decoded volumes and geometries were made on a thread_local app (one hidden app per thread, gone at thread exit while the decoded object may live on); they are now the registering app's (the shard's). - state_object<T>::_useThreading (a per-type static flag, in cvc, volren, volslice and cvcGL instantiations) becomes the app's default (set_state_object_threading(app &, bool), state_object_threading(app &); cvc.state.object-threading); setInstanceThreading still overrides it per object. setUseThreading/getUseThreading are gone. cvcGL and volren only use setInstanceThreading, so they are unchanged. - state_json_reader: the thread_local write-pin stack is the reader's own member. - state_delta_codec: the CRC-32 table is constexpr (read-only data). - state_transport_ws: the CVC_WS_BROADCAST_DEBUG flag is read each broadcast (about once a second) instead of cached in a function-local static. - grpc_dns_resolver.h (Windows only, not in the scan): the once_flag goes; setting GRPC_DNS_RESOLVER again when it is already set is harmless. - state_device_key / state_identity: hex digit tables are constexpr arrays. Tests (several apps each: two apps in both orders, apps on threads at once, a later app made after another is gone starts clean): - state_test: on_startup per app (runs once, at once after the root, disconnect, apps on threads, a handle outliving its app); state_object threading per app (replaces the per-template-type test) and on threads; the threading tests no longer restore a global. - state_send_message_test: default shard per app, on threads, and message ids that survive a shard made again under the same node id. - state_sync_adapter_test: suppression per app (and shared by an app's adapters), a remote apply on one app not hiding another app's change, apps on threads. - state_compression_registry_test: each app has its own registry, on threads. - state_volume_codec_test: decoded objects belong to the registering app, on threads. - state_deep_tree_test: json readers of several apps interleaved on one thread and on threads. - multi_app_integration_test: the state_layer workload part (default shard and message, compression codecs, state_object threading default, startup callback, decoded volume). Allowlist: 32 lines removed (cvc 23, cvcGL 9).
…object or gone libcvc keeps no process-wide state in code we control (P0a). This moves the state_exec objects that collide between apps onto the app or into the object that owns them, and removes 77 lines from tools/singleton_scan/allowlist.txt. Header statics (every target that includes types.h or task.h): - nil_value, true_value and false_value were inline const value_t objects, one per process: they are functions now, nil_value() etc., returning a new value_t (value_t is not a literal type, so it can't be constexpr). Every use in the tree is updated; the two sites that took &nil_value use a local. - task.h's thread_local trampoline slot (trampoline_next()::h) is gone: sync_wait() owns its slot (a local) and every promise of the chain it drives points at it (promise_type::trampoline_, passed on as a task is awaited). A nested sync_wait has a slot of its own; a coroutine with no slot transfers symmetrically, as MSVC always did. Per app (app.slot<T>()): - frozen_builtins() is frozen_builtins(cvc::app &): the frozen default environment an app's exec_groups and pooled pycvc Execs extend, built once per app. A group with no app freezes a default environment of its own. - exec_group's creation count (pool_link().seq), its live-group map and its single-manager note were process-wide maps keyed by app address (an app at a reused address could inherit another's count or miss its note): each app keeps its own. live_groups() takes cvc::app &. A group with no app has seq 0. - The threaded-host flag (g_threaded_host) is the app's: detail::note_threaded_host(cvc::app &) / threaded_host_noted(cvc::app &). pycvc no longer sets a process-wide flag at import; it notes each app it makes (make_app) or runs an Exec on, before that app's lock manager is made. So importing pycvc no longer turns every later app's lock manager shared. Per object: - A scheduler's serial (the foreign-future check) and a cycle registry's id are 64 random bits each (never 0), not drawn from a library-wide counter. - An async_host's reply channels are "<name>.async#<host tag>-<n>": the host's random tag and its own count, not a process-wide sequence. - CVC_EXEC_VERIFY is read as each scheduler is made (scheduler_base::verifies_pump_owner()); no_process() is a member. - The closure-body cache (t_shared_bodies) lives in the cycle registry its closures are tracked in (a group's, or the thread's own), so two groups never share a body list, and the registry id that keyed it is not needed. - The intrinsics' chain-pin scratch stack is the intrinsics_context's (pin_scratch), not a thread_local; a data job's deferred write uses a local. - The lock manager owns the CVC_EXEC_FUZZ state (seed, hits, the yield stream: lock_manager::set_fuzz_seed / fuzz_seed / fuzz_hits, read from the environment as each manager is made) and the test hooks (lock_manager::set_test_hooks / test_hooks). The process-wide seed, hit and thread counters, the thread_local PRNG and the global hook pointer are gone. - math.random with no group stream bound draws from its stdlib_registry's own stream (under a mutex), not a thread_local engine. Gone or made constant: - stdlib_registry::standard() (a process-wide registry) and shared_scope() (a process-wide frozen scope) are removed; stdlib_registry::make_scope() builds a new frozen scope, and make_default_environment() links one of its own. - print takes stdout's own C library lock (flockfile / _lock_file) around its one write, instead of a leaked process-wide mutex. - stackless_evaluator::all_special_forms() returns a new std::set from a constexpr table; is_special_form(name) answers without building it (Ariadne's two callers use it). - kSso, kFreshBuckets, kBucketFormulaHolds, has_cpu_clock and the env flag CVC_STATE_EXEC_CHECK are computed where used, kept in their owner (the scope pool), or constexpr; detail::bucket_formula_holds() is checked by a test. API changes (4.0): nil_value() / true_value() / false_value(); frozen_builtins(cvc::app &); stdlib_registry::make_scope() replaces shared_scope(), standard() is gone (pycvc too); all_special_forms() returns by value, is_special_form() added; detail::live_groups(cvc::app &); detail::note_threaded_host(cvc::app &), threaded_host_noted(cvc::app &); detail::new_scheduler_serial(), pump_owner_verification(), scheduler_base::verifies_pump_owner(); lock_manager::set_fuzz_seed, fuzz_seed, fuzz_hits, fuzz(), set_test_hooks, test_hooks; lock_port takes the fuzz state; detail::lock_fuzz_point(lock_fuzz *, where), lock_fuzz_seed_from_environment(); the process-wide set_lock_fuzz_seed, lock_fuzz_seed, lock_fuzz_hits, set_lock_test_hooks and lock_test_hooks_get are gone; intrinsics_context::pin_scratch; detail::bucket_formula_holds(). Tests: multi_app_integration_test's workload gains state_exec(): each app runs a DSL program on its exec scheduler that defines a function and an exception class of its own, raises through a call and catches it, then runs a group of the app (its seq, its pid, the app's frozen builtins, the app's threaded-host note); the transcripts match alone, at once on threads and in reverse order. New: ExecGroup.CreationOrderAndLiveCountArePerApp (two apps in both orders, apps on threads, a later app counts from 1), SchedulerSerialTest .EachSchedulerDrawsItsOwn, StdlibSharedScopeTest.EachAppHasItsOwnFrozenBuiltins and EachDefaultEnvironmentLinksItsOwnScope, LockFuzz.TheSeedIsTheManagers, StateExecTypesTest.ConstantsAreNewValues and LookupBucketFormulaHolds; AppLockManager.AutoIsSharedForAThreadedHost runs in process now (two apps, both orders, a later app) instead of in a death-test child; the frozen-builtins tests check one scope per app and another app's differs. The lock suites install fuzz seeds and hooks on their managers. Allowlist lines removed (77): cvc 53 (state_exec sources 45, <header> 8), cvc-cli 6, cvcGL 6, pycvc 6, pycvc_gl 6.
…ument The evaluator hands detail::lock_wait_call the lock-enter token of the one %lock-wait call it applies (the wait native it builds captures it), instead of arming it in a thread_local (t_lock_enter): a program's own %lock-wait call has none, as before (LW-2). lock_enter_scope and lock_enter_token_get() are gone. One more allowlist line removed (cvc: t_lock_enter). Also: an exec_group keeps a pointer to its app's counts, so its destructor looks nothing up; the integration workload's error message is built with str-concat (str takes one argument).
…ounters per app libcvc keeps no process-wide state. This moves the core libraries' share of it onto cvc::app (slots) or into the objects that do the work, and deletes 53 allowlist lines (cvc 51, cvc-cli 2). cvc::net, per app: - The HTTP client (set_http_client) is the app's: send, start, http_starts_async and set_http_client take the app. http_client(app) hands out the app's client, and send(HttpClient &, req[, policy]) sends through it, for work on a thread that may outlive the app (ariadne/data.cpp's download takes it with the app and sends holding none). - The URL opener and notice, the page hooks and --no-browser (browser.cpp) are the app's: browser_available, set_browser_disabled, open_url, set_url_opener, set_url_notice, url_notice and every page:: call take the app. - Their users follow: ariadne's net_intrinsics (host_get and host_get_start take the app), net_host, oidc_host (oidc_flows(app); a session uses its app), uri_http, uri_http_cache, media, data; ari and arigl set their own app's notice. - Bug fixed: enable_oidc's --no-browser and a test's opener or fake client were process-wide, so one app's set or reset changed every other app's. volren: the resident device cache (raycast.cu's volume_cache::instance()) is the app's: raycast_cuda_cache_of(app), shared by the app's raycasters and freed with the app; raycast_cuda(cache, req); the cache controls are its methods. The content-generation counter it validates against is the app's too. cvc-cli: main makes the command's app (cvc_app()'s static is gone); each command takes it. core and the rest: - Counters: launch_pool_task's and the sliced chunks' reply channels count per app; launch_lane_task's per lane, with a random tag per lane (async_lane::next_task_key); exec_pool's call stamps per pool; the process-wide worker-pump total is gone (a pool's stats().worker_pumps remain), and the pool serial t_failed was keyed by is a per-pool life token (owner-equal weak_ptr), so a reused thread id or pool address still reads nothing stale. - CVC_EXEC_THREADS and CVC_SLICED_THREADING are read where they are used (once per pool or task), not cached in statics. dataType<T>() is decided at compile time (no typeid table). - lod's in-memory HDF5 names: each app has its own nonce and count. model's embedded-texture temp names: an app tag and count. tf::overlay_job counts each app's jobs (instances(app); a mesh job takes its app). - Constant tables are constexpr: lsys recipes, tf preset names (preset_names() returns a new vector), oidc's own parameters, spider_io's error strings, cvc::data_type_strings. - archive's fixed Huffman codes are built per decoder at its first fixed block. The EDT scratch is the call's own; se2_train's no-gradient scratch is lent from a per-call pool; media_rungs' TurboJPEG handles are a call's own, or lent from the shaper's pool. - rawiv_io's stray global header (every reader shadowed it) is gone. Left, as real process resources or another area's: curl_global_init's once flags (libcurl's global state is one per process), ImageMagick's init once, the HDF5 library lock, the CUDA device manager and raycast.cu's __constant__ tables and their upload flag, the process nice value (set_process_class), cvc-cli's serve signal flag, the stb_image statics (third-party code compiled into stb_io.cpp), and the per-thread role markers of exec_pool, thread_pool, async_lane and app::poolDropReason (each says what the calling thread is doing now) with exec_pool's group membership mutex (its home is exec_group's pool_link, in state_exec). Tests: two apps in both orders, apps on threads at once, and a later app starting clean, for the HTTP client (net_http_client_test), the browser hooks (net_oidc_test), the volren cache (volren_render_test; volren_cuda_test on CUDA), overlay job counts (tf_overlays_test), pool-task channels and data types (app_test), lod names (lod_store_test) and lane keys (async_lane_test); multi_app_integration_test's workload adds net (each app's fake client answers with its index, its opener records its own URLs, its page and --no-browser are its own), volren (each app renders its own volume; its cache holds only that) and core counters. Tests that set the process-wide client or opener now set their app's.
…ine's include pycvc declares stackless_evaluator::all_special_forms() as it now is, returning a new set by value (its set out-typemap takes the value). python_engine.cpp includes lock_manager.h outside the server-only block, where attach() notes the threaded host on the app it is given.
…p no process state Nav, world, physics and the vendored SDF library kept process-wide state: caches, counters, flags, registries and thread-locals. They are each app's own now (app.slot), or the object's that does the work, or constants. Allowlist -72 lines (cvc 261 -> 190, cvc_physics_jolt 2 -> 1). - world: the terrain and city generators are each app's own (slot cvc.world.generators): register_terrain_generator, terrain_generator_names, make_terrain, register_city_generator, city_generator_names, to_world_params, generate_world and world_builder take the app. Every app starts with the built-ins; what one registers, another never sees. world_builder looks both generators up as it is made (it keeps them, not the app); an unknown name still fails at the first step. ariadne's make_height_field takes the app too. pycvc's generate_world uses the app's generators, or the built-ins without an app. - world: surface_registry's three ontologies are constexpr tables built at compile time (read-only data); ontology() returns const char *. graded_terrain::sample / graded_at keep their candidates on the stack (small_vector), not in thread-locals. - nav: sim_world's CVC_NAV_PROFILE flag and its per-phase sums are the world's (read when it is made), and policy_key(0)'s empty string is a member. The plant ledger's items are constexpr tables; plant_ledger_vehicle / plant_ledger_episode return std::span. grid_nav's scratch thread-locals are gone: build_sdf and astar make their own, astar_batch's queries share a pool, and sense_batch takes a caller-owned sense_scratch (a sim_world keeps one, tick to tick). - physics: world_binding's thread-locals are the binding's: who is writing its own keys (shared with its tree watch) and whether a pull read a key through a link. jolt_backend's heightfield rotation is made where used. - geometry/SDF: the legacy API's 26 globals in head.cpp (and init_all_vars, which reset them) are gone; every computation's state is its SDFContext's. octree.cpp's INF is constexpr; main.cpp's unused thread-local context is gone. Left on purpose: jolt_backend's jolt_runtime::state() use count and mutex. Jolt's factory, type registry, allocator hooks and trace/assert hooks are the library's process globals; the count guards their one setup and teardown across every world in the process, so it cannot be per app. Tests: world_generated_test adds GeneratorsAreEachAppsOwn (two apps in both orders, a later app clean) and GeneratorsOfAppsOnThreads, and checks a new app's generators are the built-ins exactly (the old test allowed more because other tests registered process-wide). nav_test adds ScratchIsTheCallersAndShareable; nav_sim_world_test adds WorldsOfSeveralAppsAreEachTheirOwn; physics_world_test adds BindingsOfSeveralAppsAreEachTheirOwn; geometry_test adds SDFV1OfSeveralAppsAreEachTheirOwn; world_roads_test adds SamplingOnThreadsAtOnceIsSamplingAlone. multi_app_integration_test's workload adds nav_world: each app registers its own terrain generator, computes an SDF of its own size, steps a sim_world from its own tree and binds a physics world to its own gravity.
cvcGL and the pycvc bindings kept process-wide state: scene node types and shader presets, the transfer-function bindings, the UI font settings, the low-memory mapper's policy, draw path and shared shader sources, the X11 clipboard connection, SDL's window and timer routes, the props marked as casting no shadow, the flushing publisher, the JPEG handles and constant tables built at first use. Each now lives on the cvc::app (app.slot<T>()), in the object that uses it, in the SDL window it describes, or in read-only data. cvcGL: - Scene node types and shader presets are the app's (scene_realize.cpp): register_scene_node_type, has_scene_node_type, register_shader_preset, has_shader_preset, register_default_shader_presets and verify_scene_customs take the app, as do the registrars that call them (register_lsystem_node_types, register_mesh_node_types, register_world_node_types, register_vehicle_preview_node, register_stream_node_type). A scene realizes only its own app's types and presets. - tf_binding: the live bindings, the seeds and the overlay_status owners, and the owner-tag counter, are the app's (they were keyed by app pointer in a process-wide map). idle_status's "unavailable: " is a constexpr string_view. - tf_editor_imgui: the stand-in default model and overlays are built per call. - ImGuiOverlay: the UI font settings are the app's (setUiFontPath / setUiFontFallbacks / setUiFontMemory / loadUiFonts take the app). The clipboard buffer handed to ImGui is the overlay's. A failed ImGui_ImplOpenGL3_Init is remembered per overlay, and clears imgui's GL loader table (imgl3wShutdown, as ImGui_ImplOpenGL3_Shutdown does) so a later overlay's Init fails cleanly instead of crashing on a null GL_VERSION: that was why g_glBackendFailed had to be process-wide. - Clipboard: clipboard::set/get take the app; on X11 the app holds its own X connection (closed with the app). Backend::set_clipboard takes the document's app (the core passes the Runtime's). - LowMemoryPolyDataMapper: the policy, draw path, pass-program switch and stage observer are the app's, read from the environment when the app's settings are first used; a mapper draws by the settings of the app newPolyDataMapper(app) (or a node's setApp) gave it, and shares its shader source copies with that app's mappers. newPolyDataMapper, setLowMemoryMapperPolicy, lowMemoryMapperPolicy, setDrawPath/drawPath, setPassProgramsEnabled/passProgramsEnabled and setStageObserver take the app. BBoxNode and RenderView take the app for it. - SdlWindow: which SDL windows are cvcGL's (openWindows) and whose events each window's are are SDL window properties, not process-wide tables; a timer tick goes to the interactor whose timers have its id. The registered timer event type is an SDL resource of the process (SDL_RegisterEvents gives each type once and none back), so it is kept in SDL's own global properties. The cursor and punctuation tables are constexpr. - GraphicsNode: the shadow non-caster mark is the app's (setPropCastsShadow / propCastsShadow take the app); it was a process-wide VTK information key. The shadow passes ask their scene's app. - state_publisher: which publisher is flushing on a thread is kept by the app (flushing(app) / in_flush(app)), not in thread-locals. - VolumeNode: its own transfer-function writes in progress are the node's (with the writing thread), not a thread-local; the first-call log is per node. - jpeg_codec: jpeg_encoder / jpeg_decoder objects own their TurboJPEG handles (the encode source and the stream view's decoder keep theirs) instead of thread-local handles. - GeometryNode / VolumeNode computed keys, SdlInput's key names, StageLighting's gizmo names: in constexpr tables. TouchScroll's ImGui ids are hashed per call. ViewportManager sets VTK's output window each time instead of once behind a static flag. pycvc / pycvc_gl: - The enum classes, exception types, dsl_error factory and the kept `who` names live on the _pycvc module object (found through the interpreter's dict), not in C statics. - symbol_swig_type / value_swig_type / async_call_to_py use SWIG's own type-table entries. - The capsule names are constexpr. - Exec's "a run() is active on this thread" mark and pycvc_gl's deferred rung-style error are kept in Python's per-thread state (PyThreadState_GetDict), not in C++ thread-locals. Tests: - cvcgl_multi_app (new, headless): a workload of node types, shader presets, mapper settings, shadow marks, publisher flushes and JPEG codecs, alone, on threads at once and in reverse order, plus a later app starting clean and per-app UI fonts. - cvcgl_state_publisher: flushing is per app (nested both ways, on threads at once, a later app). - cvcgl_lowmem_fastdraw: another app keeps its own policy and draw path. - cvcgl_shadow_casters: a non-caster mark is its app's alone. - test_pycvc_app.py: two apps' module state (enums, exceptions, dsl_error, kept names, the running-Exec mark) alone, in either order and on threads. - Tests that relied on process-wide registrations now register on their own app. Allowlist: 103 lines removed (cvcGL 76, pycvc 26, pycvc_gl 1).
…sources Both are third-party code compiled into our targets, not libcvc's: - stb_image / stb_image_write's implementation is compiled into image/stb_io.cpp (stbi__g_failure_reason, the PNG chunk buffer, the PNG writer's filter tables): THIRD_PARTY matches ^stbiw?__. - Dear ImGui's stock imgui_impl_opengl3.cpp and imgui_freetype.cpp are compiled into cvcGL from the deps bundle (its GL loader table, loader handles, FreeType hooks): the new THIRD_PARTY_SOURCES matches their source path. The allowlist drops their 15 lines (cvc 4, cvcGL 11). Our own code in stb_io.cpp and in cvcGL's ImGui files is still scanned (tests).
exec_pool's process-wide g_membership mutex guarded every group's pool_link().call. Each group_pool_link now has its own membership mutex: pump_all takes it per group while it claims and releases the group, and a group's purge_host_calls holds its own across the wait, so the call still cannot end while the purge waits on it. Pools of different apps no longer share a lock. Allowlist: -1.
…/no-singletons-combined # Conflicts: # src/cvc/tests/multi_app_integration_test.cpp # tools/singleton_scan/allowlist.txt
…o p0a/no-singletons-combined # Conflicts: # src/cvc/tests/multi_app_integration_test.cpp # tools/singleton_scan/allowlist.txt
…a/no-singletons-combined # Conflicts: # tools/singleton_scan/allowlist.txt
…to p0a/no-singletons-combined # Conflicts: # bindings/pycvc/pycvc.i # src/cvc/core/exec_pool.cpp # src/cvc/tests/multi_app_integration_test.cpp # tools/singleton_scan/allowlist.txt
…ombined # Conflicts: # tools/singleton_scan/allowlist.txt
…o p0a/no-singletons-combined # Conflicts: # tools/singleton_scan/allowlist.txt
…p0a/no-singletons-combined # Conflicts: # tools/singleton_scan/allowlist.txt
sea_surface::source kept the last source a thread found in a thread_local (O7c, #1159), which landed after the writable-data allowlist was cut (#1152), so the scan fails on master and on every PR into it. The band for one time (frame) now keeps them, one a slot in a 64-slot table picked by the point's bits, under its own mutex. A fluid field's height-then-velocity pair still finds its source the second time; the values are unchanged (the platform digest test passes as before).
…p0a/no-singletons-combined
… into p0a/no-singletons-ariadne
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
#1203 gives every cvc command its app as an argument and removes cvc_app(). - src/cvc-cli/main.cpp: the conflict was cmd_skeleton beside cmd_tetrahedralize2's new signature; kept both, and cmd_skeleton takes cvc::app & like the rest. - cmd_trace (#1168) still had the old signature and called cvc_app(), so master's cvc-cli does not build; it takes cvc::app & too, the same change as the separate fix for master.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…le-pick-upload Conflicts, each side kept: - ImGuiBackend.h: master's set_clipboard on the document's app, then this branch's pick_files and begin_frame. - net_intrinsics.cpp: master's net verbs on the app with its OpenUrlLimit, then this branch's http-upload provider. The upload follows #1203: perform() and http_starts_async() take the app, and the started upload's StartedRequest gets the app it starts on (its go() calls cvc::net::start(*app, ...)). Master's ariadne_runtime_test doesn't build: #1180's three rich-text cases call load_string with one argument, and #1203 made it take the app. They pass their test's app now.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
The upload tests' guard turns off its test's app's network and drops that app's fake transport; each test installs its transport on its own app.
This was referenced Nov 14, 2026
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
… app #1203 gives every cvc command its app as an argument, removes cvc_app() and makes cvc::ariadne::load_string take the app. It merged after #1168 and #1180, whose new code still used the old forms, so master does not build: - src/cvc-cli/main.cpp: cmd_trace (#1168) takes cvc::app & like the other commands and replays on it, not cvc_app(). - src/cvc/tests/ariadne_runtime_test.cpp: #1180's three AriadneRichText tests pass their app to load_string; each already makes one.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…ted-gas #1197 is in master as its squash, so the conflicts were #1197's own lines against this branch's changes to them: this branch's are kept. Two compile breaks on master, fixed here as #1203 fixed its own callers: - ariadne_wasm_browser_test.cpp (#1197) called register_script_engine(engine) and unregister_script_engine("wasm"), which #1203 removed: the fixture registers nothing, as each test's AppRuntime calls use_script_engine. - ariadne_runtime_test.cpp (#1180) called load_string(yaml), which #1203 made load_string(app, yaml): the three calls pass the test's app.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…s), so py_console's CI builds
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
Master gained #1203 (this branch's base), #1192 (state_exec Stage S, several steps a pick) and ten others. Conflicts, both #1192's run code against this branch's registry work: - async_scheduler.cpp: the slice setters from #1192, set_cycle_registry from here (it also gives the evaluator the registry). The cycle check takes the registry in the evaluation context (the one given, else its evaluator's own) where #1192 fell back to the thread's own, which this branch removes; collect_cycles_if_due now takes a registry. A run's steps go through the same context as its first; step_run's drain check is check_not_in_kernel, as step_once's is. - state_exec_groups_test.cpp: OC01's caller-pumped case keeps #1192's one step a pick and this branch's watched group. The file's note on leaks no longer speaks of a thread's own registry. Semantic, not textual: - #1192's Slices tests: SL04's spin-step and SL08's heavy take call_args and reach their context through it (eval_deadline_check(a.context()), a.context()->data), as this branch's other natives do. - cvc-cli's trace command (#1168) takes its app, and #1180's three rich-text tests pass theirs to load_string. Both landed after #1203's last master merge and still used what #1203 removed, so master does not build at 7ead20e or 69c7091; #1225 makes the same change there. Checked on Windows (MSVC Release): full build; groups 28/28; Slices and run-budget tests 19/19; rich text and heap 10/10; the cycle collector and registry tests, pycvc_ariadne, CvcCliTest.TraceInfoAndVerifyReplayASession and state_exec_async_test_slice256, 20/20.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
#1203 (no singletons) moved the URI registry, the HTTP client and options provider, the HTTP cache's in-flight table, the net and OIDC hosts, the WebSocket table and open-url's clock onto each app. This branch had changed the same code for threads. The merge keeps both: - uri.h/uri.cpp: register_uri_handler and resolve take the app (#1203) and keep this branch's UriCancelled and UriLocalHandler; the http(s) handlers and the HTTP cache pass the request's cancel predicate through to the app's client. - net_intrinsics.cpp: the providers stay by kind with each call on the calling program's host (ictx.host) and its finisher. The requests, fetch and WebSocket verbs take the app, the app's WsTable and its OpenUrlLimit (both app slots, got once at registration). open-url stays in its host_proxied provider, on the app's OpenUrlLimit instead of a clock of the provider's own. - oidc_host.cpp: the refresh sends through the app's client with the asker's cancel predicate. - ariadne.cpp: the Runtime's owner id is counted per app (#1203); has_snapshot asks the app's widget registry. - allowlist.txt: master's (76 lines); the one line this branch removed is gone there too. This branch's tests move onto the per-app APIs: the removed NetIntrinsicsGuard, L4Guard and NetHostGuard go, set_http_client and send take the app, live_groups takes the app by reference, and the worker pump counts come from the pool's stats (pool_stats::worker_pumps) where the process-wide exec_pool_worker_pumps_total() was, in the tests, mt.ariadne_docs and the docs. Also fixed: #1180's three rich-text tests called load_string without the app #1203 added.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
Conflict in src/cvc/world/generated_world.cpp: master's #1203 made the terrain generators each app's own (generators(app), terrainFrom), and #1215 had put the shore edge (shore_terrain) in the old make_terrain. shore_terrain now sits beside terrainFrom, which wraps any app's generator in it, so make_terrain(app, p) and to_world_params(app, p) both get the shore. #1203 also broke code that only feat/world-gym has: its edge and gym tests call generate_world, make_terrain and load_string without an app. They make one first now. cvc-cli's cmd_trace and three ariadne_runtime_test rich-text tests do not build on master itself after #1203. This takes #1225's fix for them line for line, so that #1170 builds; the two merge cleanly either way.
This was referenced Nov 14, 2026
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…app (master builds again) (#1229) #1197's ariadne_wasm_browser_test.cpp (built natively as ariadne_wasm_transform_test wherever wasmtime is found, and in the wasm-guests node job) still called register_script_engine(engine) and unregister_script_engine("wasm"), which #1203 replaced with the (app, ...) forms. #1197's CI ran before #1203 landed, so master at accadc3 doesn't compile it. As #1203 did for ariadne_wasm_test.cpp: SetUp no longer registers the engine, and the TearDown that unregistered it goes. Each of the file's 18 AppRuntimes already calls use_script_engine(engine), which registers it on that runtime's app.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…wser (G2, second part) (#1206) A guest's work now counts the same on wasmtime and in the browser, and however a call is sliced. - meter.h/.cpp: the gas pass, in C++. It reads a core module, charges each metered block's cost against a new exported i64 global, ari_gas, inline, and calls a new import, ari.gas(cost), only when the slice can't pay for the block. A block starts at a function's entry and after loop, if, else, end and the conditional branches. An instruction costs what wasmtime's fuel charges. The new import shifts every defined function's index, in calls, ref.func, element segments, exports, the start function and the name section. ari_gas starts at the start function's allowance. - It refuses GC types and instructions, the legacy exception handling, components, and code that names a global index the pass's own would take. A module that imports ari.gas already is left as it is. - It's C++ rather than paritytech/wasm-instrument, which the roadmap named: that crate and its parser, parity-wasm, haven't changed since 2022, and parity-wasm doesn't read reference types, which LLVM 19 turns on by default for wasm32. - meter_main.cpp: ari_wasm_meter, the pass as a command. Under Emscripten it runs in node. - cvc_ariadne_wasm_transform: binaryen reads the guest, ari_wasm_meter meters it, then wasm-opt --asyncify --pass-arg=asyncify-imports@ari.* -O1. This replaces --log-execution. - wasmtime validates and meters each module it compiles. A poll sets ari_gas to its slice; ari.gas is an async import that ends the poll. When a charge ends a slice, the next slice is at least that block's cost. Fuel stays on as a backstop (16 units per unit of gas). A start function past its allowance traps instead of hanging. - browser_runtime.cpp pauses at ari.gas instead of counting log_execution checks. The page sets ari_gas before each call, and the gas the guest took is the call's. kFuelPerCheck is gone. - Call::poll(gas), gas_used() and Instance::run(..., gas, ...) replace the fuel names. - Tests: WasmGasTest (ariadne_wasm_test). A module naming functions everywhere runs as it did. count(1000) costs 8001 in slices of 1, 7, 8, 100, 4096 and in one. A module is metered once. What the pass can't read is refused, and every prefix of a module is read or refused. A start function that never ends is refused. WasmTransformed.ASpinCountsTheSameOnBothBackends: the transformed guest's spin costs 24,000,001 in one slice and in 376 of 64,000, on wasmtime and in the browser. - The WASI guest (#1199) is metered and Asyncified in the transform too, and the transform passes binaryen CVC_WASM_GUEST_FEATURES on both runs. - The branch also carries the compile fixes for #1203's API change that #1225 and #1229 bring to master (cmd_trace, the rich-text tests' load_string, the browser test's fixture), which master may have first.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
Two conflicts, both resolved by keeping both sides: src/cvc/CMakeLists.txt keeps chart_emit.cpp next to files.cpp and file_picker.cpp, and ariadne.cpp includes both chart_emit.h and file_picker.h. #1169's tests still called load_string without an app, as before #1203, so master's ariadne_loader_test and ariadne_chart_test do not build. ChartWidget now uses the file's fresh_load, and FromADocument loads into the app it renders with.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
… app (#1225) #1203 gives every cvc command its app as an argument, removes cvc_app() and makes cvc::ariadne::load_string take the app. It merged after #1168 and #1180, whose new code still used the old forms, so master does not build: - src/cvc-cli/main.cpp: cmd_trace (#1168) takes cvc::app & like the other commands and replays on it, not cvc_app(). - src/cvc/tests/ariadne_runtime_test.cpp: #1180's three AriadneRichText tests pass their app to load_string; each already makes one.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…nks that resume (#1190) A document can attach a file: nicotina's roadmap item L18 (Attach in the compose view), built on two generic verbs. Docs are in docs/ARIADNE.md section 10.8. (file-pick [OPTS]) is async: the program parks until the user picks or cancels, and gets a list of {handle name size type}. A handle names a FileSource the app keeps (app.slot<PickedFiles>()), so the program never holds the file's bytes or path. (file-info H) and (file-forget H) go with it. Options: accept, multiple, title, dir. - arigl native: SDL3's system file dialog. - browser builds (arigl-web, ari.html): the page's <input type=file>; reads slice the File. - ari's FTXUI and tvision, a GL window without SDL, a mock: an Open file window drawn with the backend's own widgets (folder, name field, listing filtered by accept, Open, Cancel). (http-upload URL FILE [OPTS]) sends a picked file under the http verbs' rules (policy, auth:, credentials in headers, 401 renewal, echo blanked): - as: multipart (default), as: body, or as: chunks: PATCHes with Upload-Offset, resynced from the server's offset after a 2xx or 409, retried with back-off on a dropped connection, 408, 425, 429 or 5xx (asking status_url how far it got), and resumable from offset. - progress names a state path for the sent fraction. - Native runs it on the background pool; the single-threaded browser starts each read and request without waiting, so frames go on; wasm-mt proxies the File reads to the main thread. Also: one-line fields drop pasted line breaks (tvision reads a burst of keys as a paste), and FTXUI's radio no longer prints an ImGui-style ##id caption. Master's ariadne_loader_test and ariadne_chart_test build again: two of #1169's chart cases now load into an app, as load_string has required since #1203. Tests: ariadne_files_test (15 cases: pickers, refusals, an FTXUI terminal driven by keys, tvision's layout, multipart, body, chunks resuming through 409/503/lost replies, origin and credential rules, aborts); ari_run_file_pick_upload_{ftxui,tvision} (tmux, sha256 checked); two arigl_web_smoke.mjs cases on arigl-web and ari's page.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
CI at 9d002d1 built it on master as of 09:28, after #1197 added ariadne_wasm_browser_test.cpp with register_script_engine calls that predate #1203 (all three package-linux lanes and wasm-guests failed to compile it). Master fixed that in #1229, and the load_string calls #1169 left in the loader and chart tests in #1190. This merge takes master as it is now, so CI builds on those fixes. No conflicts. Master's new natives (#1190's file-pick and http-upload, #1195's py_console, #1169's chart) build against this branch's call_args context as they are. Checked on Windows (MSVC Release): full build; the Ariadne, net, HTTP, state_exec, groups, slices, async-call, cycle-registry and multi-app ctests, 1336/1336. ariadne_wasm_browser_test is not built here (it needs wasmtime or Emscripten); master's CI builds it.
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
transfix
added a commit
that referenced
this pull request
Nov 14, 2026
…ction #1203 turned state_exec's nil_value, true_value and false_value from constants into functions. `k ? keys_value(*k) : se::nil_value` still compiled: the function's address converts to a bool, so (e2ee-identity) with no identity, and five more nil results, came back true. ariadne_e2ee_test caught it after the master merge (ui.dm.none was "some"). se::value_t() is nil on master and on release/3.x alike, so the code stays the same on both.
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.
Moves libcvc's process-wide state onto
cvc::app, onto the object that uses it, or deletes it, across every library we control. Each change has a test that runs several apps at once and checks they don't collide. The writable-data allowlist drops from master's 510 lines to 59. 4.0, breaking.This one PR replaces the stack below. Landing them one at a time would have taken about ten full CI runs in a row: each squash changes the next branch, and the sibling PRs conflict with each other in the allowlist, the multi-app test,
exec_pool.cppandpycvc.i. Every replaced PR's head is an ancestor of this branch, so please merge with a merge commit: it keeps each part's history.Bugs this fixes
Each of these was one app seeing or changing another app's state:
state://answered from the last app to register, for every app.--no-browserchanged every app.send_messageand room-lane ids repeated when a client rejoined under the same pid. The bus drops ids it has already seen.world:block for the whole process.API changes (4.0)
.ariblocks, data decoders, script engines, the media factory and play policy, URI handlers, scene node types, shader presets, and terrain and city generators. Examples:register_widget(app, ...),load_string(app, ...),load_file(app, ...).Runtime::app(),section_epoch(app)andpython::Engine::register_on(app).make_scope.The proof
multi_app_integration_testruns many workloads, each in its own app: file handlers, action intrinsics, the state tree and sections, the state layer, net, volren, core's counters, nav/world and state_exec. It runs them alone, then all at once on threads, then in reverse order. Each must produce the same transcript every time.Area tests add more multi-app cases, and cvcGL has a new headless
cvcgl_multi_apptest.What is left (59 lines)
host_signalsg_previousandg_raised, and cvc-cli'sg_serve_running. A signal handler has no context to reach an app through, so these stay (approved).raycast.cu's__constant__tables and their one-time upload (7), the process nice level (1), and Jolt's one-per-process runtime (1).exec_pool'st_worker,t_caller,t_defer,t_callback,t_failed(and a TLS guard),thread_pool'st_active_poolandt_fanout_context,async_lane'st_running_top, andapp.cpp'st_poolDropReason. Whether these go too is an open question, so this PR leaves them as they are.g_next_serial_run: it must stay process-wide, becausescope_markrelies on unique low-32-bit serials per address.Also not covered: the executables' own globals (ari/arigl
g_wasm), which the scan doesn't look at, andariadne_python'sscript_engine().Master's scan failure
Master's writable-data scan fails on its own, on the
thread_localthat #1159 added tocvc::ocean::sea_surface::source. This branch merges #1181's branch, the fix that was picked, so its scan passes now. When #1181 lands on master, the contents match and the merge is clean. If #1181 changes before then, this branch needs master merged in again.A fix found in review:
task.hon GCC and Clang#1189's run failed to compile on every Linux, macOS and wasm lane. The trampoline's
await_suspendbecame a member template, and GCC and Clang reject member templates in a local class.CVC_COROUTINE_TRAMPOLINEis on only off MSVC, so the Windows build never saw the problem.task<T>::awaiterandtask<void>::awaiterare now nested classes (696301d).Checked locally with clang-cl, with the trampoline forced on: it reproduces CI's two errors on the old header and passes on the new one. It also passes on 71 of 72 sources: core, state_exec, and every
.cppthat #1189 changed. The one that fails,python_engine.cpp, does so because the check script strips quoted-path defines. Its code is unchanged since master.Testing
ctest -j 6(bench, slow and soak left out): 7,235 of 7,236 pass. This ran before master's ports P0d, part 1: cvc::contour_stack, its formats on each app, contours.* and pycvc #1156 and Demo pages fit a phone; iOS: byte voxels, a nearest shadow map; ?gldiag and ?nofloatlinear #1166 and ocean: the caller owns the sea's source memo, not a thread_local #1181's fix were merged in; see the next item for the run after.pycvc_ariadne, is a timing flake. It counts frames during a 0.3 s async call and needs more than 20. It got 16 under parallel load and passed 5 of 5 run alone. Windows'time.sleep(0.002)really sleeps about 15 ms, so the check has little headroom on a loaded machine.ratchet.pyagainst master passes (no line gained). No new writable statics came in with ports P0d, part 1: cvc::contour_stack, its formats on each app, contours.* and pycvc #1156 or Demo pages fit a phone; iOS: byte voxels, a nearest shadow map; ?gldiag and ?nofloatlinear #1166.