Skip to content

Ariadne: host network policy and host-owned credentials (nicotina L1, L2) - #888

Merged
transfix merged 5 commits into
masterfrom
feat/ariadne-net-policy
Oct 30, 2026
Merged

transfix merged 5 commits into
masterfrom
feat/ariadne-net-policy

Conversation

@transfix

@transfix transfix commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Items L1 and L2 of nicotina's host roadmap (cy-pca/nicotina docs/ROADMAP.md; atx-crypto-club/txwtf docs/roadmap/ARIADNE_CLIENT.md): stock ari and arigl hosts get a network allowlist and credentials that stay in the host, switched on by command-line flags alone. With no flag the network stays off, as before.

What a launcher gets

arigl run --net-allow https://tx.wtf --credential-store nicotina share/nicotina/main.ari
flag (before the document) what
--net network on; in a browser the page's own origin is allowed
--net-allow ORIGIN allow scheme://host[:port] (repeatable; implies --net)
--net-policy FILE allow ORIGIN and credential NAME ORIGIN... lines (repeatable)
--credential-store S keep credentials across runs: a name under ~/.config/cvc/credentials/ (%LOCALAPPDATA%\cvc\credentials on Windows), or a path; written 0600; refused in a browser

These flags make enable_net (inc/cvc/ariadne/net_host.h) do the following:

  • Verbs and the URI handler. It registers the http verbs and the http(s):// URI handler.
  • Origin checks. Every request is checked against the allowlist, and so is every redirect. The host follows redirects itself, one checked hop at a time, and drops Authorization, Cookie and Proxy-Authorization on a cross-origin hop.
  • Capability tokens. net, net.auth and net.auth.persist now hold, so a document's requires: fails clearly when the launcher didn't turn the network on.

The flags behave the same in ari with either terminal backend (FTXUI, --backend tvision, over SSH too) and in arigl (window, --terminal, browser), for run, snapshot, check and info. With the network on, ari snapshot waits after its frames until the document's requests have come back (at most 10 s), so CI can render a document that signs in against a local server. It also prints the programs' warnings, as arigl snapshot does.

AppRuntime::enable_net and AriRuntime::enable_net are the matching setters, and the network is turned off again when the runtime is destroyed.

Credentials (L2)

  • (http-get url (dict "auth" "txwtf")): the host adds Authorization: Bearer <token> as the request is sent, but only when the credential is bound to the URL's origin. Otherwise the request isn't sent and the reply says no credential 'txwtf' for <origin> (sign in first).
  • (http-request "POST" login (dict "form" ... "capture_auth" (dict "name" "txwtf" "field" "token"))): the host keeps the JSON string at field from a 2xx reply. The body comes back with "[redacted]" in that one place; every other byte is unchanged.
  • Any echo of a token, in the body or a header, is blanked. Requests that use credentials don't follow redirects.
  • New verbs: net-auth-has?, net-auth-forget, net-auth-clear, net-allowed?.
  • A credential is bound to the origin it was captured from, unless a policy credential line binds the name to a list of origins.
  • Tokens must be RFC 6750 bearer tokens, 16 to 4096 characters, so one can never split a header line.
  • Tokens never enter a value_t, so they never reach the state tree or a program variable, and no error string quotes one.

Response headers (item 3)

The reply dict now also has content_type, header_map (lowercased name to value) and captured, alongside {ok status body url headers error}.

Two changes beyond the brief

  • state_exec::async_options::io. An Ariadne action's default budget is 5000 steps and 0.1 s, and an async call was charged its kernel's wall time and CPU. Measured here (Linux, Release):

    • one HTTPS request: about 16–18 ms of CPU (130,000–145,000 steps) and about 180 ms of wall time;
    • the first localhost request in a process: 13,500 steps.

    So no document could have made a single HTTPS request in a stock host. The existing tests didn't catch it because their fake transports cost nothing. With io set, a call is charged one step, and the transport's own timeouts and size cap bound it instead. The net verbs register with it. Decided (Joe, 2026-10-29): keep async_options::io. The alternative was for hosts to raise ariadne.limits.* whenever the network is on, which loosens the guard for every action.

  • host_cli on boost::program_options, as asked. The existing flags behave as before (all of ariadne_host_test passes), except that abbreviated flags are no longer guessed. libcvc now links Boost::program_options, which is in the exported find_dependency and in the Boost components each in-tree directory re-imports. The cvcpkg boost bundles have it on every platform, wasm included.

Tests

  • net_policy_test (new, 22 tests): origin parsing and what it refuses, the policy file and its errors, and the checked send with redirect rules (a fake transport, plus two real localhost servers on different origins). It also covers the credential store: binding, capture, forget and clear, and the file's 0600/0700 modes, round trip, refusal of a group-readable file, and errors that never quote the token. JSON capture and redaction are covered too.
  • ariadne_runtime_test AriadneNetHost.* (8 tests), run against a localhost server shaped like txwtf:
    • capture keeps the token out of the reply and out of the whole state tree, and auth sends it;
    • auth goes only to bound origins; disallowed origins are refused with no request made; echoes are blanked;
    • forget and clear work;
    • a persisted credential survives a restart;
    • the capability tokens and requires: [net] follow the host;
    • bad configs are refused;
    • credential options are refused without a store;
    • a 300 ms reply completes under the default action budget.
  • ari_net_test (new, 5): the built ari run as a launcher would, against localhost servers:
    • a document that requires the network fails without the flags and loads with them (FTXUI and tvision);
    • a snapshot signs in, the token is sent, and another origin is refused;
    • a credential store carries the sign-in to the next run (0600);
    • bad flags exit 2;
    • every run's stdout and stderr is checked for the token, across these error paths: a reply whose token isn't a bearer token, an unwritable store, an endpoint that echoes the header, a program that raises an error with the reply, the token sent to a dead server, and credential files ari refuses (malformed, open to others). None prints it.
  • ariadne_host_test: the network flags, their errors, and that a flag after the document is the document's.
  • state_exec_async_calls_test AnIoCallIsChargedItsOneStep, on both schedulers.
  • Local results (Linux, RelWithDebInfo, cvcpkg deps): every ariadne, net, state_exec and uri_http_cache suite passes; the one skip is the unrelated AriadneTfEditor.InlineSeedIsLocaleIndependent.
  • End to end in the real ari binary, against a Python stand-in for txwtf:
    • without flags, requires: [net, net.auth] fails the load, naming both;
    • with --net-allow, sign-in returns 200 and captured: true, the body shows "token": "[redacted]", /user/me returns 200 with the injected token, and https://evil.example is refused;
    • a second process with --credential-store signed in from the file without the document seeing the token.
  • Wasm, built here with the cvcpkg emsdk and deps:
    • single-threaded ari (CI's "ari terminal backend" configure): built, and under node ari.js info --net-allow https://tx.wtf shows the allowlist and tokens, --credential-store is refused ("a browser host keeps credentials in memory only"), and the baked tour still renders;
    • wasm-mt arigl, in the gallery configuration (examples on): built and linked.
    • Not run: a request from a browser page; node has no fetch backend.
    • A standalone wasm arigl (examples off) fails to link on emscripten_fetch_* with this PR alone, because enable_net now pulls the fetch backend in. arigl-web + ari page: stock browser hosts that run .ari documents by URL; arigl and arigl-web packages #887 (the arigl packaging work) moves arigl's -sFETCH=1 and -sASYNCIFY out of the examples block, which fixes it. No CI job builds that configuration.

Not done here (follow-ups)

  • The §13.9 cached http handler isn't policy-checked. No host registers it.
  • arisrv doesn't use host_cli, so it has no network flags.
  • In a browser the browser follows redirects, so only the first URL is checked there; CORS bounds the rest. This is documented, not tested in a browser.
  • Credential expiry isn't tracked; a document that gets a 401 calls net-auth-forget.
  • Two processes writing one credential store: the last writer wins.

An async call is charged its kernel's wall time against max_time and its CPU time as steps
(docs/STATE_EXEC_EXCEPTIONS.md 3.8). For a kernel that waits on the network that charges the
process for the round trip and for the host's transport. One HTTPS request measured about 16-18 ms
of CPU (130,000-145,000 steps at the default 8000 a CPU ms: the TLS handshake and the CA store) and
180 ms of wall time, and the first localhost request of a process 13,500 steps. An Ariadne action's
default budget is 5000 steps and 0.1 s, so no document could make one request.

- async_options::io (off by default): the call's run time, CPU time and unmetered time read 0, so
  it is charged its one step. The function's own bounds limit it instead (a transport's timeouts
  and size cap, async_options::timeout).
- STATE_EXEC_EXCEPTIONS.md 3.8 says so.
- AnIoCallIsChargedItsOneStep: on both schedulers, a CPU-bound and a sleeping I/O call finish
  under a budget (1000 steps, 0.1 s) that the same work as plain calls runs out of; each is
  charged one step and no time.
parse_host_args, the command line ari and arigl share, walked argv by hand. boost::program_options
now does the reading: it splits --flag=value and --flag value, knows which flags take a value, and
rejects an unknown flag, one missing its value, or a value given to a bare flag (--ansi=1). Two
rules stay this file's own: the first argument that is not a flag (or the one after "--") is the
document, and it and everything after it are the document's, never the runtime's; and a repeated
flag's last value wins while the repeatable ones collect.

One change in behaviour: program_options' guessing is off, so an abbreviated flag (--comp for
--component-path) is an unknown option rather than a guess. All 20 ariadne_host_test cases pass
unchanged.

libcvc links Boost::program_options with its other Boost components, and its exported config asks
for it. cvc-cli already used it; the cvcpkg boost bundles carry it on every platform, wasm and
wasm-mt included.
Items L1 and L2 for nicotina (cy-pca/nicotina docs/ROADMAP.md): a stock ari or arigl, given only
flags, lets a document reach the origins it allows and sign in without ever holding the token.
Nothing changes without the flags: no host registered the net verbs or the http(s) URI handler
before, and none does now unless told to.

L1, the allowlist (cvc/net/net_policy.h, cvc/ariadne/net_host.h):
- Flags before the document, in ari and arigl (window, terminal, browser): --net, --net-allow
  ORIGIN (repeatable), --net-policy FILE (allow and credential lines) and --credential-store S.
  Each implies --net. In a browser the page's own origin is allowed too.
- enable_net builds the allowlist and registers the http verbs and the http(s) URI handler with
  it. cvc::net::send(req, policy) refuses a request to an origin the policy does not allow and
  follows redirects itself, checking each hop and dropping Authorization, Cookie and
  Proxy-Authorization on a cross-origin one. URLs are parsed strictly (http/https, no user info,
  backslash, space or control byte, an ASCII host), so the origin checked is the one dialled.
- AppRuntime::enable_net / AriRuntime::enable_net for other hosts; the runtime turns it off as it
  dies. register_net_intrinsics(app) alone is still the unchecked, credential-free form.
- The capability tokens net, net.auth and net.auth.persist, so requires: fails clearly where the
  launcher did not turn the network on. ari/arigl info show the allowlist.

L2, credentials (cvc/net/credentials.h):
- A request's auth: "NAME" has the host add "Authorization: Bearer <token>" as it is sent, only to
  an origin the credential is bound to; elsewhere the request is not sent. capture_auth: {name,
  field} keeps the JSON string at field from a 2xx reply and puts "[redacted]" in its place, every
  other byte unchanged. Any echo of a token in a reply is blanked. Neither option follows a
  redirect. Tokens never become a value_t, so they reach no program variable, no state node (which
  a state transport replicates) and no error message.
- A credential is bound to the origin it came from, or to the origins a policy's credential line
  names. Tokens are RFC 6750 bearer tokens of 16-4096 characters.
- net-auth-has?, net-auth-forget, net-auth-clear and net-allowed?.
- --credential-store keeps them across runs: a name is a file in the user's config dir
  (~/.config/cvc/credentials/, %LOCALAPPDATA%\cvc\credentials), anything else a path; one
  "<name> <origin> <token>" line each, written 0600 in a 0700 directory and replaced whole. A file
  another user owns or others can read is refused. A browser keeps them in memory.

The reply dict gains content_type, header_map (lowercased name -> value) and captured. The verbs
are I/O calls (the previous commit), so a request is charged one step.

Tests:
- net_policy_test (new, 22): origins and what is refused, the policy file and its errors, the
  checked send and its redirect rules (a fake transport, and two localhost servers end to end), the
  credential store, its file's modes, round trip and refusals, the JSON capture and redaction.
- ariadne_runtime_test AriadneNetHost.* (8), against a localhost server shaped like txwtf: the
  token kept out of the reply and of the whole state tree and sent by auth, sent only to a bound
  origin, refused origins never contacted, forget and clear, a credential surviving a restart, the
  tokens and requires:, refused configs, and a 300 ms reply under the default action budget.
- ariadne_host_test: the flags, their errors, and a flag after the document being the document's.

docs/ARIADNE.md: 10.2 (the reply, the I/O charge) and a new 10.3 (the flags, the allowlist, the
policy file, credentials); the 11 caveats no longer say no host registers http.
…ts for requests, and its tests

nicotina runs in ari (FTXUI and tvision, over SSH too) as much as in arigl, so the ari path gets
the same coverage. The flags were already the shared host_cli's and ari already turned the network
on for every command; what changes:

- ari snapshot, with the network on, drains after its frames until no async call has been in
  flight for three drains (at most 10 s), then prints the frame. Frames drain faster than a reply
  comes back, so a document that signs in and fetches showed nothing in one frame; now one frame
  does, which CI can render against a local test server. Without the network it is as before.
- ari snapshot prints the programs' warnings after the frame, as arigl snapshot does.
- ari --help and docs/ARIADNE.md 10.3: the flags hold for run, snapshot, check and info, with
  either backend; examples for ari, ari --backend tvision and arigl.
- ari_net_test (new, 5): the built ari against localhost servers. A document needing the network
  fails without the flags and loads with them (FTXUI and tvision); a snapshot signs in, is sent
  the token, is refused elsewhere; a credential store carries the sign-in to the next run (0600);
  bad flags exit 2. Every run's stdout and stderr is checked for the token: a reply with a token
  that is not a bearer token, an unwritable store, an endpoint echoing the header and a program
  raising with the reply, the token sent to a server that is gone, and credential files ari
  refuses (malformed, open to others) all print none.
- Boost::program_options joins the Boost components each in-tree directory re-imports (ari,
  arigl, arisrv, cvc-cli, cvcGL, pycvc), so cvc's public link evaluates there on every CMake.
transfix added a commit to cy-pca/cypkg that referenced this pull request Oct 30, 2026
…untested

Checked against transfix/libcvc#888 (276afd54) and #887 (44e7ec1b).
#888 can capture and send cvcpkg's access token, but leaves the refresh
token visible to the document, cannot send a stored credential in a form
field for the refresh, and has no way to supply a cvctok_ token. On the
single-threaded wasm page the verbs run inline, and no browser test makes
a request through #887's page with #888's flags.
@transfix
transfix enabled auto-merge (squash) October 30, 2026 03:56
clang-format and the C preprocessor both read an EM_JS body as C++ tokens, so the
`typeof location !== "undefined"` test was written out as `!= =`. Emscripten's JS optimizer
(acorn, at -O3) rejected that and the wasm ari link failed ("ari terminal backend (wasm, node)").
The test is now `typeof location == "object" && location && location.origin`, which survives
both. Rebuilt locally: the wasm ari links and the CI job's node checks pass (the baked tour's
snapshot, and `ari info --net --net-allow https://tx.wtf`).
@transfix

Copy link
Copy Markdown
Owner Author

cypkg (cy-pca/cypkg), a terminal client for cvcpkg registries written as .ari documents, needs the same host as nicotina. I checked this PR (276afd5) against cvcpkg's CLI sign-in, which is the device pairing that cvcpkg login --code uses. Most of it works as-is:

  • capture_auth {name: "cvcpkg", field: "access_token"} keeps the cvcses_ token from POST /v1/auth/device/token.
  • auth: "cvcpkg" sends it.
  • net-auth-has? and net-auth-forget handle the signed-in check and sign-out.
  • The token format (cvcses_ plus token_urlsafe(32)) passes valid_token.

Three things are missing. Each is generic, not specific to cvcpkg, so it could go in this PR or a follow-up:

  1. Capture more than one field from a reply. A token reply carries both access_token and refresh_token. capture_auth takes and redacts one field (take_json_string in net_intrinsics.cpp), so refresh_token reaches the document in clear. That breaks the guarantee that tokens never enter document variables or state, and the refresh token is the longer-lived one (30 days, against 12 hours for the access token). For example, capture_auth could take a list of {name, field}, keeping each field as its own credential bound to the same origin.

  2. Send a stored credential as a form or body value, not only as a Bearer header. Refreshing is POST /v1/auth/token with grant_type=refresh_token&refresh_token=... (RFC 6749 §6), which auth: can't express. For example, a form value like {credential: "cvcpkg.refresh"} would be filled in by the host as the request is sent and redacted from the reply, the same way auth: works. Combined with (1) on the reply, a document can rotate its session without ever seeing either token. Without this, the user has to pair again every time the access token expires.

  3. A host flag that supplies a token, for API tokens and CI. Nothing lets a launcher hand the host an existing token, such as a cvctok_ API token. A document could only take one from a text field, which would put it in state, and policy credential lines bind origins only. A native-only flag such as --credential-env NAME=VAR would cover it: it reads the token from an environment variable, and the binding comes from the policy (or --net-allow). It matches cvcpkg's own CVCPKG_TOKEN. Today the only workaround is a launcher that writes the store file itself.

A note on the browser side: as far as I can tell, --net on #887's single-threaded ari page should work, because the verbs run inline (async_lane_has_threads is false) and the fetch backend spins on emscripten_sleep. But neither PR makes a request from a browser page, so the two together are untested. A request in #887's smoke test, once both have landed, would cover it.

@transfix
transfix merged commit 276887d into master Oct 30, 2026
12 of 26 checks passed
@transfix
transfix deleted the feat/ariadne-net-policy branch October 30, 2026 05:19
transfix added a commit that referenced this pull request Oct 30, 2026
…r values, --credential-env

cypkg (cy-pca/cypkg), a terminal client for cvcpkg registries written as .ari documents, signs in
with cvcpkg's device pairing. Its token reply carries an access and a refresh token, a refresh is
an RFC 6749 section 6 form POST, and CI uses an API token from the environment. #888's credentials
covered one token per reply, sent as a Bearer header; these three generic additions cover the rest
without a token ever reaching the document
(#888 (comment)).

- capture_auth takes a list of {name, field, optional} dicts, one credential each, all captured
  from the URL's origin. Every field is taken first and each token blanked wherever the reply
  carries it, then each is kept. A missing optional field is no error: a refresh reply need not
  rotate the refresh token. A name given twice is an error. captured is true when every required
  field was kept; error names the ones that were not.
- A credential value, (dict "credential" NAME), as a form or headers dict value: the request is
  encoded with a random letters-and-digits placeholder in its place, and the host puts the token
  there as it is sent (percent-encoded in a form, as is in a header), only for an origin NAME is
  bound to, like auth; elsewhere the request is not sent. Echoes are blanked in both spellings. A
  query refuses one (URLs are logged). Any credential option turns off redirect following, and the
  origin is checked against the policy before any token is looked up.
- --credential-env NAME=VAR (repeatable, implies --net, native only): enable_net holds the token in
  VAR as credential NAME for the run, through the new CredentialStore::provide: in memory, ahead
  of the file's token for NAME, never written, replaced by a capture. A policy credential line must
  bind NAME, so the launcher decides where it goes. An unset or empty VAR supplies nothing, so a
  launcher can always pass the flag; a malformed value stops the host without being quoted.
  ari/arigl info list the names it supplied.
- ari and arigl --help, net_intrinsics.h and docs/ARIADNE.md 10.2 and 10.3 describe them.

Tests:
- net_policy_test: provide (bound names only, ahead of the file, never written, replaced by a
  capture, forgotten).
- ariadne_host_test: --credential-env parsing and its errors.
- ariadne_runtime_test, against a localhost registry: a device reply gives two credentials and a
  refresh with a form credential sends the refresh token (percent-encoded) and keeps the new access
  token, no token in the state tree; credential values only for bound origins, never in a query, a
  duplicate capture name refused; an environment token as a Bearer and as an X-Api-Key header,
  never in the store file, an unbound name and a malformed value refused, an unset variable
  harmless.
- ari_net_test: the same device sign-in and refresh, and --credential-env, through the built ari,
  no output carrying a token.
transfix added a commit that referenced this pull request Oct 30, 2026
…took §10.3

#888 added §10.3 (the host's allowlist and credentials) beside this branch's §10.3, so the
merge left two. The JSON section is now §10.4, its links follow, and its http-get example
says the host has to allow the origin.
transfix added a commit that referenced this pull request Oct 30, 2026
From nicotina M0's notes on #888:
- arigl snapshot (window and --terminal) did not wait for requests as ari snapshot does, so one
  frame showed a document's first frame; nicotina's tests passed --frames 60 instead.
- ari's wait ended after three drains with no async call in flight. A program working between two
  requests (parsing a reply is a sliced data step, not an async call) looked idle then, and the
  snapshot could miss the second reply.

AppRuntime::idle() is now "no async call in flight and no program step waiting to run"
(async_scheduler::has_runnable), and AppRuntime::settle(step, max_seconds) runs a host's step until
the document has been idle for three steps running, at most 10 s. ari snapshot, arigl's terminal
snapshot (a drain) and its window snapshot (a whole frame, the PNG written after) call it when the
network is on.

- ari_net_test SnapshotWaitsThroughWorkBetweenRequests: a document that loops between two requests
  shows both replies in a one-frame snapshot. With idle() back at "no call in flight" it fails
  (the second is empty); the whole suite still runs in about 3 s.
- arigl is built only through the wasm-mt tree here (no native VTK); it compiles and links. CI's
  cvcGL lanes build it natively.
- ari and arigl --help and docs/ARIADNE.md 10.3 say so.
transfix added a commit that referenced this pull request Oct 30, 2026
…dential-env (cypkg) (#895)

* ariadne: several credentials per reply, credentials as form and header values, --credential-env

cypkg (cy-pca/cypkg), a terminal client for cvcpkg registries written as .ari documents, signs in
with cvcpkg's device pairing. Its token reply carries an access and a refresh token, a refresh is
an RFC 6749 section 6 form POST, and CI uses an API token from the environment. #888's credentials
covered one token per reply, sent as a Bearer header; these three generic additions cover the rest
without a token ever reaching the document
(#888 (comment)).

- capture_auth takes a list of {name, field, optional} dicts, one credential each, all captured
  from the URL's origin. Every field is taken first and each token blanked wherever the reply
  carries it, then each is kept. A missing optional field is no error: a refresh reply need not
  rotate the refresh token. A name given twice is an error. captured is true when every required
  field was kept; error names the ones that were not.
- A credential value, (dict "credential" NAME), as a form or headers dict value: the request is
  encoded with a random letters-and-digits placeholder in its place, and the host puts the token
  there as it is sent (percent-encoded in a form, as is in a header), only for an origin NAME is
  bound to, like auth; elsewhere the request is not sent. Echoes are blanked in both spellings. A
  query refuses one (URLs are logged). Any credential option turns off redirect following, and the
  origin is checked against the policy before any token is looked up.
- --credential-env NAME=VAR (repeatable, implies --net, native only): enable_net holds the token in
  VAR as credential NAME for the run, through the new CredentialStore::provide: in memory, ahead
  of the file's token for NAME, never written, replaced by a capture. A policy credential line must
  bind NAME, so the launcher decides where it goes. An unset or empty VAR supplies nothing, so a
  launcher can always pass the flag; a malformed value stops the host without being quoted.
  ari/arigl info list the names it supplied.
- ari and arigl --help, net_intrinsics.h and docs/ARIADNE.md 10.2 and 10.3 describe them.

Tests:
- net_policy_test: provide (bound names only, ahead of the file, never written, replaced by a
  capture, forgotten).
- ariadne_host_test: --credential-env parsing and its errors.
- ariadne_runtime_test, against a localhost registry: a device reply gives two credentials and a
  refresh with a form credential sends the refresh token (percent-encoded) and keeps the new access
  token, no token in the state tree; credential values only for bound origins, never in a query, a
  duplicate capture name refused; an environment token as a Bearer and as an X-Api-Key header,
  never in the store file, an unbound name and a malformed value refused, an unset variable
  harmless.
- ari_net_test: the same device sign-in and refresh, and --credential-env, through the built ari,
  no output carrying a token.

* ci: the wasm ari makes requests under node

Nothing tested a request from the single-threaded browser build, where the verbs run inline and
the fetch backend spins on emscripten_sleep. The "ari terminal backend (wasm, node)" job now does:

- src/ari/tests/net_probe.ari signs in (two tokens from one reply), refreshes with the refresh token
  as a form credential, fetches with the refreshed token, and is refused another origin;
  net_probe_server.py stands in for the registry.
- xhr-shim.cjs: a small XMLHttpRequest over node's fetch, enough for emscripten's Fetch.js, so the
  page's cvc::net fetch backend runs under node (which has fetch but no XMLHttpRequest).
- CVC_ARI_WASM_TEST_DOCS (off by default) embeds src/ari/tests at /tests in the wasm ari; the job
  turns it on, runs the probe, checks the results and that no token reached the output.
- The job also runs when src/cvc/net or inc/cvc/net change.

Run locally with the cvcpkg emsdk 5.0.7: every check passes.

* ari, arigl: snapshot waits until the document is idle, arigl too

From nicotina M0's notes on #888:
- arigl snapshot (window and --terminal) did not wait for requests as ari snapshot does, so one
  frame showed a document's first frame; nicotina's tests passed --frames 60 instead.
- ari's wait ended after three drains with no async call in flight. A program working between two
  requests (parsing a reply is a sliced data step, not an async call) looked idle then, and the
  snapshot could miss the second reply.

AppRuntime::idle() is now "no async call in flight and no program step waiting to run"
(async_scheduler::has_runnable), and AppRuntime::settle(step, max_seconds) runs a host's step until
the document has been idle for three steps running, at most 10 s. ari snapshot, arigl's terminal
snapshot (a drain) and its window snapshot (a whole frame, the PNG written after) call it when the
network is on.

- ari_net_test SnapshotWaitsThroughWorkBetweenRequests: a document that loops between two requests
  shows both replies in a one-frame snapshot. With idle() back at "no call in flight" it fails
  (the second is empty); the whole suite still runs in about 3 s.
- arigl is built only through the wasm-mt tree here (no native VTK); it compiles and links. CI's
  cvcGL lanes build it natively.
- ari and arigl --help and docs/ARIADNE.md 10.3 say so.
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