Skip to content

arisrv: server documents (--doc) and server: publish: namespaces (S0) - #1046

Merged
transfix merged 8 commits into
masterfrom
feat/arisrv-server-documents
Nov 8, 2026
Merged

transfix merged 8 commits into
masterfrom
feat/arisrv-server-documents

Conversation

@transfix

@transfix transfix commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

Phase S0 of the scripting-hosts roadmap (docs/roadmap/ARIADNE_SCRIPTING_HOSTS.md §6.1, §6.5.3, §10). It is the first step of the application-services cut that cy-pca/cyprov needs: S0 -> S1 (arisrvx) -> S2 + S5 -> S7. The reference is the new ARIADNE.md §9.7.

What it does

arisrv --doc server.ari runs a document on the relay. It is a headless AppRuntime over the relay's own app (cvc::ariadne::ServerDocument, inc/cvc/ariadne/server_document.h), for room rules, bots and checks written in the DSL.

server:
  publish: [cyprov]          # every client is sent it; only this document writes it
init: (state-set "cyprov.status" "up")
on_tick: (state-set "cyprov.present" (length (state-children "room.participants")))

In arisrv

  • arisrv reads the server: block before it listens on anything. A document that doesn't parse, or a bad block, exits 2.
  • The document loads after the C++ seeds (scene, catalog, policy, aoi params); its init: runs then. A failed load exits 1.
  • Its programs run every room step (60 Hz), ahead of the holon, under the DSL's caps. Each step first writes the holon's world-clock tick and time to the document's sim.tick and sim.time.
  • (quit [code]) stops the relay with that exit status.
  • --set is where it was: before the seeds and the document.
  • requires: [relay] holds only in a server document. On another host the load fails and says it runs on the relay (arisrv --doc).

The document's chroot

  • It binds under ui.docs.arisrv, which the relay never sends.
  • Each published namespace is a writable transparent link of the same name in the chroot, so cyprov there is the tree's cyprov.
  • room is a read-only link on conf.rooms.<room>.
  • A name may not be under conf, ui, ariadne, state_exec or room. No two may overlap, and none may overlap the document's own prefix.

What the relay sends

  • state_cluster_shard has an outbound scope (add_publish_prefix). drain_local, replay_local and snapshot() keep only what is under it, so live writes, backfill, the admit snapshot and the WS re-broadcast all follow it. The publish cursor moves past what is held back, so a trim erases that too.
  • arisrv scopes its whole-tree shard to conf plus the published namespaces, with or without a document. Clients took nothing else before, since their interest is conf.
  • The area of interest subscribes each participant to the same prefixes; before this they were subscribed to conf alone.

Client writes. Bound writes already refuse a client's write outside its own participant. A document that publishes therefore needs --bind-writes on, and arisrv refuses to start without it.

Clients are all sent the published subtrees. They still apply only conf until S2's relay: subscribe: adds the namespace to their interest.

The scene. A scene: isn't run on the relay yet. Its parse, physics and bodies included, is kept on the runtime (ServerDocument::scene()) for the world runtime that will make it the holon's one physics world (ARIADNE_WORLDS.md §14). The load warns that its physics isn't simulated. Other hosts ignore a server: block, with a warning.

Two core fixes it needed

  • A fresh node's first write was never journaled. state_sync_adapter attaches to a new node lazily, when an ancestor's childChanged names it. That comes after the node's own valueChanged, so the first value was lost. C++ writers worked around it with touch() first (set_replicated), and tests wrote everything twice. A DSL program can do neither, so the first (state-set "cyprov.jobs.42.status" ...) would have reached WS clients only on the next re-broadcast, and gRPC clients never. The adapter now journals a node's content (value, and data() with a codec) when a local write first shows it the node. A remote apply is still suppressed, and a node without content (made on the way to another, or touched) journals nothing.
    • Four gRPC transport tests then raced: they wrote a throwaway value, waited for one frame and checked. The second commit drops every such warm-up write, and keeps the comments accurate.
  • state-set-tree followed a link only at the last hop. So (state-set-tree "cyprov.jobs" ...) wrote the hole's own children, unpublished. It now walks through writable links on every hop, as state-set does, so it can replace (and prune) a published subtree. state-delete and state-watch still act on the physical path (ARIADNE.md §7.4). ARIADNE.md §7.4's list now names state-set-tree.

Coordination with the worlds plan (ARIADNE_WORLDS.md, #1041 and #1043)

WD1 rides S0, so S0 is built for both uses of one --doc: cyprov's service document and a world document. #1043 merged while this was open, so master is merged in, and both texts are the same.

  • One runtime, and later the world's. The parsed scene: (physics and bodies included) is kept for the world runtime (L0, then WD2) to attach to, as the holon's only physics world. S0 builds no physics of its own.
  • Its state never replicates. The document binds under ui.docs.arisrv (worlds Q2, settled as proposed).
  • One write path. The holes plus the shard's scope carry the application namespaces now. They carry the world sections under conf.rooms.<room>.* later, since those are already in the scope.
  • Private rooms. Nothing makes "every room's sections are relay-written" an invariant of the write gate.
  • Order. A section's fields, then its rev last, arrive in that order; RoomRelayLoopbackTest.ServerDocumentPublishesItsNamespaceOnly pins it. So WD1's revisioned-section writer (in core, for L0 to share) is sugar over what the DSL can already do. It isn't built here.
  • The clock. on_tick runs once per room step (60 Hz, the room-rules cadence). sim.tick is the holon's world clock (120 Hz, never backwards), so a future activation tick is a future sim.tick.
  • Many rooms. ServerDocument(app, room, prefix) makes one runtime per room under its own prefix (RM1, RM2).
  • Names. The relay token stays clear of conference.world, cvc://worlds/* and the server.* feature tokens, and conference.world can build on it.

For Joe, where S0 settles something differently from the text:

  1. No ingest interest. §6.5.3 says publishing "adds them to the relay's interest". S0 adds them to the shard's new outbound scope instead. The relay never ingests a client write there, and bound writes refuse one first.
  2. Ports bind first. "Load the document before the relay accepts clients": arisrv binds its ports first, as it always has for the seeds. A client that connects in the milliseconds before the document loads still gets init:'s writes, live. Making acceptance wait would mean reordering arisrv's startup, which I left alone.
  3. The token's name. S0's capability token is relay.

Tests

  • ServerBlockTest (2) and ServerDocumentTest (8), in the new ariadne_server_document_test:
    • parsing and refusals;
    • writes through the holes, own state kept, the room read-only;
    • what a scoped shard sends;
    • state-set-tree pruning;
    • a changed block refused at load;
    • (quit 3);
    • the kept scene with its warning;
    • the document's own prefix refused;
    • the relay token on and off the relay.
  • StatePublishScopeTest (4): drain, capped drain, replay and snapshot under the scope.
  • RoomRelayLoopbackTest.ServerDocumentPublishesItsNamespaceOnly: a relay assembled as arisrv assembles it, with the area of interest on.
    • A subscribing client gets echo live and a late joiner gets it from its admit snapshot; one that doesn't subscribe is sent it and filters it.
    • A whole-tree client never gets ui.docs.arisrv, and its write to echo is refused.
    • A client never sees echo.board.rev before that revision's fields. That holds live, and for a late joiner from its admit snapshot onward. The world clock the document copies never goes back.
  • Adapter and state-set-tree cases in state_sync_adapter_test and state_exec_intrinsics_test.
  • ctests: arisrv_doc_echo, arisrv_doc_quit_code, arisrv_doc_publish_conf, arisrv_doc_needs_bound_writes (arisrv on loopback ports, through tests/run_arisrv.cmake, which checks exit status and output), ari_server_block_ignored and ari_server_document_needs_relay.

Locally, on a Windows static Release tree (gRPC + WS, tests on), ctest run as CI runs it (same exclusions, --repeat until-pass:3):

  • First run: 6,344 of 6,346. The two failures were warm-up races, which the second commit fixes.
  • At the head of this PR: 6,349 of 6,349.

The Linux-only IPC tests (state_transport_ipc_test, state_multiprocess_ipc_test, state_reconnect_resilience_test) lost the same warm-up lines but weren't built here, so CI is their first run.

Not in S0

  • Reloading a changed document, --net, and on_signal: for arisrv's own signals.
  • Running the scene (WD1 and the world runtime).
  • The revisioned-section writer (WD1, L0): the rev-last order it relies on is tested here.
  • Size caps on a published namespace; the DSL's action caps are its only write budget (risk 18).

Both roadmaps are updated:

  • ARIADNE_SCRIPTING_HOSTS.md: the S0 row and §6.1 / §6.5.3 as built.
  • ARIADNE_WORLDS.md: the §1 "Documents on the server" row, WD1's dependency marked met, and the first-cut paragraph. Also the relay token under conference.world, and Q2 as built.

`arisrv --doc server.ari` runs a document on the relay: a headless AppRuntime over the relay's
app (cvc::ariadne::ServerDocument), for room rules, bots and checks in the DSL. It binds under
ui.docs.arisrv, which the relay never sends, and reads the room through a read-only `room` hole.
Its server: block's publish: list names namespaces every client is sent and only the server
writes. ARIADNE_SCRIPTING_HOSTS.md S0 (§6.1, §6.5.3); the reference is ARIADNE.md §9.7.

- arisrv reads the server: block before it listens (a bad one exits 2), loads the document once
  the room is seeded, and pumps it every room step ahead of the holon, with the holon's world
  clock at sim.tick / sim.time. (quit [code]) is arisrv's exit status; a failed load exits 1. A
  document that publishes needs --bind-writes on, which refuses client writes there.
- Each published namespace is a writable hole of the same name in the document's chroot.
- state_cluster_shard gets an outbound scope (add_publish_prefix): drain_local, replay_local and
  snapshot() send only what is under it, and the publish cursor moves past what is held back.
  arisrv scopes its whole-tree shard to conf plus the published namespaces, and the area of
  interest subscribes each participant to the same prefixes.
- The sync adapter journals a node's content when a local write first shows it the node, so the
  first write to a fresh node replicates (it was lost: valueChanged fired before the lazy attach).
  A DSL program cannot touch() first as set_replicated does.
- state-set-tree follows a writable link on every hop, as state-set does, so it can replace a
  published subtree.
- The parsed scene: is kept on the runtime for the world runtime, with a warning that its physics
  is not simulated (ARIADNE_WORLDS.md §14). Other hosts ignore a server: block with a warning.

Tests: ServerBlockTest, ServerDocumentTest, StatePublishScopeTest,
RoomRelayLoopbackTest.ServerDocumentPublishesItsNamespaceOnly, adapter and state-set-tree cases,
and the arisrv_doc_* and ari_server_block_ignored ctests.
The sync adapter now journals a fresh node's first write, so a test that wrote a throwaway
value first ("set twice") sends two frames where it waited for one, and could check before
the second landed (StateTransportGrpcTest.ThreeEndpointFanOut, TwoEndpointConvergence,
RoundTripSuppressedByDedup and StateTransportGrpcReconnectTest.StopRestartReconnect failed that
way on Windows). Each such pair loses its warm-up write and keeps the frame counts it had,
and the comments that explained the old loss go.
…, and a rev-order test

- requires: [relay] holds in a relay's server document only (Runtime::set_relay_document, set
  by ServerDocument). Elsewhere a load fails with a hint that such a document runs on the relay
  (arisrv --doc). It is outside server.* and conference.world, so a world token can build on it.
- A server: publish: entry that is, holds or lies inside the document's own prefix is refused,
  whatever prefix the runtime binds under.
- RoomRelayLoopbackTest.ServerDocumentPublishesItsNamespaceOnly also writes a revisioned section
  by hand each step (echo.board's fields, then its rev last), and checks that a client never sees
  a rev before that revision's fields. The test also checks that the world clock the document
  copies (sim.tick) never goes back.
- ari ctests: ari_server_document_needs_relay, and ari_server_block_ignored on its own document.
ARIADNE.md §9.7 and the scripting-hosts roadmap's §6.1 / §6.5.3:
- the startup order, with --set before the seeds and the document (WD0 moves it last);
- on_tick once per room step, with sim.tick as the world clock;
- requires: [relay], and the rev-last order a live view relies on;
- where S0 departs from §6.5.3's text: an outbound scope, not ingest interest;
- one write path for the namespaces and, later, WD1's sections;
- this runtime is the one the world will run in headless.

ARIADNE_WORLDS.md: the §1 row, WD1's S0 dependency as met, the first-cut paragraph, the relay
token under conference.world, and Q2 as S0 builds it.
…as built

RoomRelayLoopbackTest.ServerDocumentPublishesItsNamespaceOnly checks the rev-last order for the
late joiner as well: from its admit snapshot and the live frames after it, it never sees
echo.board.rev before that revision's fields. ARIADNE_WORLDS.md's "Documents on the server" row
says the parsed scene: is kept on ServerDocument::scene(), and points at §14's headless world
runtime.
… warm-up write

It wrote a throwaway "seed" before its 32 values, which the sync adapter now journals too (a
fresh node's first write), so B received 33 mutations where the test counts exactly 32. v0 is
now the first write and is journaled, so the count is 32 again.
@transfix
transfix merged commit f831f7b into master Nov 8, 2026
28 checks passed
@transfix
transfix deleted the feat/arisrv-server-documents branch November 8, 2026 00:09
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