Skip to content

No singletons, Ariadne part 3: URIs, HTTP, and the net and OIDC hosts per app [4.0, breaking] - #1176

Closed
transfix wants to merge 2 commits into
p0a/no-singletons-ariadne-3from
p0a/no-singletons-ariadne-4
Closed

transfix wants to merge 2 commits into
p0a/no-singletons-ariadne-3from
p0a/no-singletons-ariadne-4

Conversation

@transfix

Copy link
Copy Markdown
Owner

No singletons, Ariadne part 3: the URI resolver, HTTP, and the net and OIDC hosts are each app's own. Stacked on #1163 (then #1161, #1155, #1152). Breaking (4.0).

This finishes Ariadne. What remains on the allowlist from src/cvc/ariadne is host_signals.cpp's two objects. A signal handler can only reach process-wide data, and Joe agreed (2026-11-12) that it stays.

What moved onto the app

  • The URI resolver (uri.h), as one app slot. These take the app:

    • resolve, resolve_async, resolve_to_file and store;
    • the handler, store-handler and async-handler registries (register_uri_handler(app, ...) and the rest);
    • the read and store byte caps.

    The built-in file reader and writer are every app's. The Windows temp-file name drew on a process-wide token and counter; it is now random per call.

  • state:// resolves against the app it is registered on (register_state_uri_handler(app)). Bug fixed: the registry was the process's, so the last app to register answered every app's state:// reads and writes. sync_resolver_caps_from_state(app) sets that app's caps.

  • HTTP:

    • set_http_options_provider(app, ...);
    • register_http_uri_handler(app[, policy]);
    • register_cached_http_uri_handler(app) / unregister_cached_http_uri_handler(app).

    Bug fixed: the cache's single-flight map was the process's, keyed by URL. Two apps fetching one URL waited on one transfer, and only the first app's cache was written.

  • The net host: enable_net, disable_net(app), net_host_status(app) and net_host_access(app). Turning the network on for one app no longer turns it on for every app's documents.

  • The OIDC host: enable_oidc, disable_oidc(app), pump_oidc(app) and oidc_busy(app).

Callers updated

  • the loader (its parse context carries the app into imports, mounts and transfer functions);
  • data loads: a local scheme (state://, cvc://) resolves while the load holds the app (with_app; the load stops if the app has gone). The network wait still holds no app;
  • media: fetch_bytes(app, ...). PlayerSource carries the app; make_player sets it, and the browser and FFmpeg players fetch with it;
  • the fetch verb;
  • the relay session's credential source;
  • the scene and cvcGL source resolvers (resolve_generated_world_file(app, ...));
  • save_state(app, ...) / restore_state(app, ...);
  • the hosts and the examples (register_cvc_uri_handler(app, ...), after the app is made).

Allowlist: -22 lines (cvc 283 -> 261)

uri.cpp (the three registries, their mutex and guards, and the two caps), uri_http.cpp (the provider cell, mutex and guard), uri_http_cache.cpp (the flight map, mutex and guard), net_host.cpp and oidc_host.cpp (the host cells, mutexes, guards and g_on).

Tests

  • ariadne_registries_test:
    • URI handlers and caps per app, in both orders;
    • state:// reading and writing each app's own tree, and a later app having none;
    • the net host per app;
    • four apps on threads resolving with their own handlers.
  • multi_app_integration_test: the workload adds URIs. App i's memo scheme answers its index, its state:// reads its own tree, and its cap is its own.
  • The loader, runtime, HTTP cache and media tests: their guards (StateHandlerGuard, HttpHandlerGuard, HttpProviderGuard, SchemeGuard, CapGuard, NetGuard, NetHostGuard) existed only to undo process-wide registrations, and are gone. Each test registers on its own app and loads against it. The guards that also reset cvc::net's own hooks keep those resets; cvc::net moves to per-app in a later PR.

Locally (Windows, MSVC 2022): the whole tree builds, and these pass:

  • ariadne_registries_test 14, multi_app_integration_test 2, ariadne_loader_test 228, uri_http_cache_test 13, net_policy_test 25, ariadne_runtime_test 262;
  • the other Ariadne and room suites;
  • the cvcGL and cvcMedia ctests (15).

CI

Full run: the push to ci/full/no-singletons-ariadne-4, https://github.com/transfix/libcvc/actions/runs/43186547811.

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