Skip to content

No singletons, Ariadne part 2: the document registries are each app's own [4.0, breaking] - #1161

Closed
transfix wants to merge 2 commits into
p0a/no-singletons-ariadnefrom
p0a/no-singletons-ariadne-2
Closed

transfix wants to merge 2 commits into
p0a/no-singletons-ariadnefrom
p0a/no-singletons-ariadne-2

Conversation

@transfix

@transfix transfix commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

No singletons, Ariadne part 2: the document registries are each app's own. Stacked on #1155 (which is on #1152). Breaking (4.0).

libcvc keeps no process-wide state in code we control. Ariadne's document registries were process-wide, so what one app registered, every app's documents saw. They are now each app's own (app.slot), and the loader checks a document against the app it loads for.

What moved onto the app

  • Widget types. register_widget_type(app, type, emit), register_known_widget_type(app, type) and has_widget_type(app, type).
    • The backends' native widgets declare themselves to an app: ImGuiBackend::register_widget(app, type, draw) and FtxuiBackend::register_widget(app, type, draw).
    • register_status_dot_widget(backend, app).
  • .ari blocks. register_ari_block(app, key, parse) and has_ari_block(app, key).
    • The world, server and relay blocks register per app: register_world_block(app), register_server_block(app) and register_relay_block(app). Their process-wide once-flags are gone.
  • Data decoders. register_data_decoder(app, as, decoder), has_data_decoder(app, as) and data_decoders(app). Every app starts with the built-ins.
  • The data store. DataStore::of(app) keeps the store in the app's slot, not in a table keyed by app*.
  • Script engines. register_script_engine(app, engine), unregister_script_engine(app, language), find_script_engine(app, language) and has_script_engine(app, language).
    • AppRuntime::use_script_engine(engine) now registers the engine on its runtime's app. So ari's and arigl's Wasm engine and the Python engine (src/ariadne_python) no longer register process-wide at startup.
    • The language tokens (python, wasm, python.<module>) are answered from HostFacts::app, which Runtime sets. capability_hint(app, name).
  • The loader. load_string(app, yaml) and load_file(app, path). The parse context carries the app into imports and mounts, for the widget-type, block, decoder and customs: checks and for the block parsers.

Callers updated

  • In the library: AppRuntime, ServerDocument, the relay session, the stream view, the cvcGL bundles, scene panels and views, and the stream-view and status-dot widgets.
  • The hosts: ari, arigl and arisrv.
  • The examples: hello, conference, stream, nav_compute and nav_convoy.
  • The tests:
    • A test that registers something and then loads now uses one app for both.
    • A test that only parses uses a file-local fresh_load(yaml) / fresh_load_file(path). It loads against a new app, so only the built-ins apply, and nothing is shared.

pycvc does not wrap any of these.

Allowlist: -19 lines (cvc 309 -> 290)

  • ariadne.cpp: widget_registry, widget_mutex, known_widget_types and their guards.
  • loader.cpp: block_registry, block_mutex and the guard.
  • data.cpp: decoder_map, decoder_mutex, stores, stores_mutex and their guards.
  • script_engine.cpp: engines, engines_mutex and the guard.
  • world_rules.cpp and server_document.cpp: the once-flags.

Tests

  • ariadne_registries_test:
    • DocumentRegistriesAreEachAppsOwn: two apps each register a widget type, a block and a decoder, in both orders. A document naming each app's three loads cleanly on its own app and gets all three warnings on the other.
    • EveryAppStartsWithTheBuiltInDecodersOnly: removing a built-in from one app leaves it on another.
    • AppsOnOtherThreadsKeepTheirOwnDocumentRegistries: four apps on four threads.
  • multi_app_integration_test: the workload adds the document registries. App i registers w, b and d, then loads a document naming every app's blocks; only its own are kept, alone, at once on threads, and in reverse order.
  • ariadne_script_engine_test: an engine registered on one app is not on another, and use_script_engine registers it on the runtime's app only. ariadne_requires_test: another app's facts, and facts with no app, don't see an engine.

CI

This PR targets #1155's branch, so ci.yml's full run comes from the push to ci/full/no-singletons-ariadne-2: https://github.com/transfix/libcvc/actions/runs/43157470987.

Locally (Windows, MSVC 2022): the whole tree builds (libraries, cvcGL, the hosts, the examples, pycvc), and these pass: multi_app_integration_test 2, ariadne_registries_test 10, app_test 121, ariadne_requires_test 18, ariadne_runtime_test 262, ariadne_loader_test 228, ariadne_media_test 55, ariadne_script_engine_test 31, ariadne_data_test 14, ariadne_doc_fetch_test 9, ariadne_host_test 46, ariadne_scene_tf_test 10, ariadne_scene_world_test 25, ariadne_stream_view_test 5, world_rules_test 7, room_scene_test 21, holon_sync_test 25, room_avatar_test 9, room_chat_test 14, and the cvcGL ariadne, media, stream and room-view tests (12). ariadne_wasm_test is not built here (no Wasm runtime); CI runs it.

Update: 57460d6 fixes arisrvx (a server host now registers its Python engine on its app before it reads its server document). Full run: https://github.com/transfix/libcvc/actions/runs/43171987170.

… 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.
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.
@transfix

Copy link
Copy Markdown
Owner Author

Replaced by #1203, which lands the whole no-singletons stack as one PR. This branch's head is an ancestor of #1203's branch, so its commits are all there; the branch is kept.

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