Skip to content

arisrvx: ServerHarness for a service's tests, and the end-to-end ctest (S7) - #1177

Merged
transfix merged 6 commits into
masterfrom
feat/arisrvx-harness
Nov 14, 2026
Merged

transfix merged 6 commits into
masterfrom
feat/arisrvx-harness

Conversation

@transfix

Copy link
Copy Markdown
Owner

S7 of the scripting-hosts roadmap (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md §6.5.8), the last phase of the application-services cut: testing a service without a server, and one end-to-end test in CI.

import myservice                                     # its Host, hooks and exports
from pycvc.ariadne.testing import ServerHarness

harness = ServerHarness(myservice.host, publish=["cyprov"])
alice = harness.connect("test-token")                # through host.authenticate
assert alice.call("instances_list", project="acme") == []
assert alice.progress["instances_list"][-1] == (1.0, "done")
assert alice.get("cyprov.public.status") == "up"     # what the relay would send her

What it adds

  • pycvc.ariadne.testing.ServerHarness, for a service's tests under plain python (pytest, with FastAPI's TestClient for the HTTP half). No relay, no network.
    • It drives arisrvx's own dispatch (_Program) on host.loop, with an in-process link in place of the relay. So these are the same code a relay runs, not a copy:
      • the authenticate and read_scope hooks;
      • the role gates and ctx;
      • the timeouts and CallError;
      • the per-principal limits.
    • Values cross through pycvc's capsules, as the wire carries them: a tuple arrives as a list, and a function doesn't cross (a TypeError).
  • The client API.
    • connect(bearer) raises Refused when the relay would refuse the connection. client(principal) makes a client as though the hook had admitted it.
    • call, call_with (room-call-opts), acall and acall_with return the value, or raise CallError with the code the client would get. progress[name] holds the latest call's steps.
    • get, get_tree and reads show what the relay would send the client: the publish= namespaces, bounded by its principal's read scope (S6). host.refresh_scope updates that scope, and host.disconnect closes the principal's clients.
    • pycvc.ariadne.testing is registered by the module itself, since it is a single file.
    • Not modeled: the relay's result cap, and the room's conf tree.
  • The end-to-end ctest arisrvx_echo_service.
    • tests/echo_service.py has an HTTP route and an export over one function, an authenticate hook with a fixed test token, the echo subtree its document publishes, and a read scope of echo.public.
    • tests/echo_client.ari (run by arix when it is built, else ari) joins with the token and calls the export (its reply, its typed int, its progress). Then it reads what the export wrote, checks it is not sent echo.private, and fetches the route.
    • relay_pair.py --client-net-asgi passes --net-allow for the origin in the program's "serving ASGI on" line.
  • Docs: ARIADNE.md §9.8.6, and the roadmap's §6.5.8 as-built notes. §10 marks S6 done (arisrv: bound reads, a read scope per principal (S6) #1147) and S7 built.

Tests

  • pycvc_ariadne_harness (bindings/pycvc/test_pycvc_ariadne_harness.py) runs a small service under plain python. It checks:
    • connects: a token, a refusal, a hook that raises, one past auth_timeout, a failing read_scope, and no hook;
    • ctx and progress, typed values, role gates, CallError whole, internal, deadline_exceeded, not_found, and the idempotency key;
    • call_concurrency's rate_limited;
    • the published and scoped views, refresh_scope, and host.disconnect;
    • the same function behind a FastAPI route through TestClient.
  • arisrvx_echo_service, as above.

Run locally on Windows (static Release, gRPC + WS, pycvc core, FastAPI and uvicorn in the arisrvx Python):

  • The arisrv/arisrvx and pycvc.ariadne ctest set: 55/55 with -j 3, both new ones included.
  • arisrvx_echo_service ran its five client tests through arix, with the read_scope hook on and the route fetched on its ephemeral port.
  • pycvc_ariadne_harness: 38 checks, with the FastAPI half run.
  • No C++ changed, and the CMake edits are in src/arisrv and bindings/pycvc, which the browser build doesn't include. So for the browser I ran a configure with CI's arigl-web flags (clean) rather than a compile identical to master's.

Not in this PR

  • No release: arisrvx with S1-S7 is unpublished until a v* release, on Joe's go-ahead.

…t (S7)

pycvc.ariadne.testing.ServerHarness (ARIADNE_SCRIPTING_HOSTS.md 6.5.8) plays arisrvx for a
service's tests under plain python, with no relay and no network. It drives arisrvx's own
dispatch, _Program, on host.loop with an in-process link in place of the relay, so the
authenticate hook, the read_scope hook, the role gates, ctx, the timeouts, CallError and the
per-principal limits are the same code a relay runs.

- connect(bearer) asks the authenticate hook (Refused when the relay would refuse), or
  client(principal). A client's call, call_with (room-call-opts), acall and acall_with return
  the value or raise CallError with the client's code; progress[name] holds the latest call's
  steps. Values cross through pycvc's capsules, as the wire carries them.
- get, get_tree and reads show what the relay would send the client: publish= namespaces,
  bounded by its principal's read scope, which host.refresh_scope updates. host.disconnect
  closes the principal's clients.
- pycvc.ariadne.testing is registered by the module itself (one file).
- The end-to-end ctest arisrvx_echo_service: tests/echo_service.py (an HTTP route and an export
  over one function, a fixed-token authenticate hook, the published echo subtree, a read scope
  of echo.public) against tests/echo_client.ari, which joins, calls the export, checks its reply
  and progress, reads what it wrote, is not sent echo.private, and fetches the route.
  relay_pair.py --client-net-asgi allows the origin the program serves on.
- Roadmap: S6 is done (#1147), S7 built; ARIADNE.md 9.8.6.

Tests: pycvc_ariadne_harness, arisrvx_echo_service.
#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.
…lient cannot load

CI's Python has fastapi but not the HTTP client starlette.testclient wants, and starlette says so with a RuntimeError, not an ImportError: pycvc-linux / cp312 failed on it. The HTTP half now skips on either.
pycvc-linux failed pycvc_ariadne_harness: CI's Python has FastAPI but no
httpx, and starlette.testclient raises RuntimeError (not ImportError) when
it finds neither httpx2 nor httpx, so the test's skip guard never caught it.
The guard now catches both, and CI installs httpx-cp312 (noarch on
cvcpkg.org) so the HTTP half runs there too.

Tests: pycvc_ariadne_harness on Windows, 38 checks with httpx and 37 with
httpx and httpx2 hidden (the HTTP half skipped).
@transfix
transfix enabled auto-merge (squash) November 13, 2026 03:54
@transfix
transfix merged commit ae46c92 into master Nov 14, 2026
29 of 33 checks passed
@transfix
transfix deleted the feat/arisrvx-harness branch November 14, 2026 03:34
transfix added a commit that referenced this pull request Nov 14, 2026
…#1177, #1167) into perf/threaded-s1b

The one conflict is the sanitizers' SAN_CXX_TESTS list in ci.yml: this branch added
stream_test, net_ws_client_test and ariadne_host_test, and #1167 added skeleton_test. The
list keeps all four.
transfix added a commit that referenced this pull request Nov 14, 2026
Conflicts, all master's #1216 and #1177 against this branch's embedded
Python:
- python_engine.cpp: _arihost stays made at boot by install_arihost (no
  inittab entry); its docstring takes #1216's name for the host,
  pycvc.ari.Host().
- ARIADNE_SCRIPTING_HOSTS.md: the same, in the roadmap's words.
- arigl/main.cpp: the conference camera keeps this branch's kWalkKeys
  comment and gains master's setMouseLookOrbits(true).

Nothing master added calls what this branch removed (g_python, g_wasm,
lent(), script_engine(), the inittab module, the CUDA manager's
instance(), the load bench's globals).

Checked on Windows (MSVC Release): full build; ratchet ok against
#1217's allowlist (22 lines) and master's (59), 13 here; the scan's own
tests; format clean; the host, Python and multi-app ctests, 24 pass and
18 skip (FTXUI and matplotlib, absent here), pycvc_ari and
pycvc_ariadne_harness among the passes.
transfix added a commit that referenced this pull request Nov 15, 2026
#1216 moved the Python Host to `pycvc.ari` and left `pycvc_gl.ariadne` as an alias. To stay off lines that open PRs edited, it kept the old name in a few places. With #1169 in, they can change. Comments, docstrings and Markdown only.

## Now `pycvc.ari`

- `ariadne_server.py`: the module docstring ("as `pycvc.ari.Host`'s do") and the values section's comment.
- ARIADNE.md:
  - where `display(obj)` is predefined;
  - what arisrvx's `host.set` / `set_tree` / `set_series` / `set_plot` match.
- Docstrings: `ariadne_display`'s (which host it shows in) and `ariadne_mpl.attach`'s.
- Comments: the `pycvc_gl_ariadne_host` test's in `bindings/pycvc/CMakeLists.txt`, and the ariglx smoke's in `publish-cvcpkg.yml`.

## The roadmap (ARIADNE_SCRIPTING_HOSTS.md)

- The plan's matplotlib bullet named `pycvc_gl.ariadne.mpl`. It now names the backend that shipped, `pycvc_gl.ariadne_mpl`.
- The "as built" note says why: the Host's module is a module, not a package. It said `pycvc_gl.ariadne`; it now says `pycvc.ari`.
- S7 is done:
  - the status says it shipped in #1177;
  - §10's row is **Done** (it said **Built**).

## Left as they are

- Lines that say `pycvc_gl.ariadne` is the same module:
  - `ari.py` and the alias itself;
  - `pycvc.i`, and two CMake comments;
  - `link-host.sh`, the arix recipe, and ARIADNE.md §9.3.
- Code that imports through the alias:
  - `cars.py`;
  - the `pycvc_gl_*` tests;
  - the matplotlib test documents.

  These keep the old name tested.

## Checks

- `git grep 'pycvc_gl\.ariadne\b'` finds only the lines above.
- The three edited Python files parse.
- No changed line passes 100 columns, except the §10 table row, which was already longer.
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