Skip to content

OW8: a world's rate, chosen by the relay and followed by its clients - #1441

Merged
transfix merged 4 commits into
masterfrom
feat/world-clock-rate
Nov 22, 2026
Merged

transfix merged 4 commits into
masterfrom
feat/world-clock-rate

Conversation

@transfix

@transfix transfix commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Joe asked whether there's a knob to run a world below 120 Hz, "such that the server can change the rate and the clients follow suit". There wasn't one: every holon defaulted to 1/120 s on its own, and nothing told a client the relay's quantum. This PR adds the knob (OW8, ARIADNE_WORLDS.md §18.9).

The knob

  • A scene's clock: { hz: 60 } sets a world's rate. arisrv --sim-hz 60 overrides the document's rate.
  • The rate must be a whole number from 10 to 240; 0 or absent means 120.
  • A bad value is a load warning, and the world then runs at 120 Hz.

What follows the rate

  • The quantum, 1/hz. The app's world clock goes to it (SceneWorld::use_vehicle_clock, before the physics world is built), so a physics step and the holon's clock are 1/hz too.

  • The navigator's tick. It is the whole number of quanta nearest the policies' 0.06 s (cvc::sim_tick_quanta):

    • 7 at 120 Hz (kSimTick, unchanged);
    • 4 at 60 Hz (0.0667 s);
    • 2 at 30 Hz.

    WorldVehicles' default tick follows the world's step, and a tick set with set_tick still wins.

  • The holon's windows. They count ticks and were sized for 120 Hz: skew, lead slack, peer playout, intent lead and catch-up. holon_config_at(cfg, hz) converts each one so it keeps its length in seconds, with a minimum of one tick.

The relay

  • arisrv takes the rate from --sim-hz, else the document's (or stock world's) clock: hz, else 120. It builds its holon at that rate.
  • It builds the server document's world at the same rate. A load hook sets the scene's hz, so attach_world finds the world's step equal to the holon's quantum.
  • It publishes the rate as conf.rooms.<room>.clock.hz, a revisioned section stamped with the run's epoch (write_room_clock / read_room_clock).
  • A near entity's pose update is held at 30 Hz whatever the rate.

Clients

  • A client builds its holon from room_holon_config(app, room), at the room's rate.
  • A holon can't change its quantum in place, so arigl's new follow_room_clock() rebuilds it whenever on_room_clock says it is off the room's rate. That happens after a join, or when the relay restarts at another rate.
  • A room with no clock section (an older relay) runs at 120 Hz.

What a lower rate saves: mostly relay CPU. Poses already go out at 60/30/20 Hz by round trip, and the room loop steps at 60 Hz whatever the rate.

Tested locally (Windows, static Release, Jolt):

  • New tests:
    • SimTickTest.AWorldsRateSetsItsQuantumAndTheNavigatorsTick
    • HolonSyncTest.ARoomsRateIsItsClockSection
    • HolonSyncTest.ARoomAt60HzIsFollowedByItsClients: a client built at 120 Hz rebuilds at 60, predicts its own walk and plays out its peer
    • AriadneOneWorld.AWorldAt60HzRunsOnAHolonAt60Hz
    • AriadneScene.ClockBlockTakesAWorldsRate
  • Existing suites:
    • ariadne_scene_world_test: 110 passed, 1 skipped
    • holon_sync_test: 33/33
    • world_clock_test: 52/52
    • the loader's AriadneScene tests: 53/53
  • arisrv --doc cvc://worlds/traffic.ari --sim-hz 60 logs clock: 60 Hz (--sim-hz) ... navigate every 4 steps (0.0667 s) and runs one world at 60 Hz with its 18 vehicles. With no flag it stays at 120 Hz with 7 steps.
  • arigl compiles, but hasn't been run against a 60 Hz relay.
  • The policies hold at 4/60 s, the tick at 60 Hz and 30 Hz. The heavy NavPlantConvergence.PoliciesHoldTheirReachAtTheSimulationTick (CVC_NAV_TICK_AB=1) now has that arm: 20 seeds of 48 Jolt RoboRacers through the city. Reach at 0.06 s, then at 4/60 s: the shipped weights 0.519, then 0.512; the untrained default 0.522, then 0.517. Both are within the seeds' noise, so no retraining. ARIADNE_WORLDS.md §18.9 records the run.

Not in this PR

  • Changing the rate on a running relay; today it takes a restart.
  • A scene with a swarm and a rate of its own: the swarm still needs 120 Hz.

Overlaps: #1420 and #1426 touch the same files (holon.h, holon_sync, arigl main.cpp, arisrv main.cpp, room_rules.cpp). My changes there are additive, so whichever of them lands after this one should merge with little or no conflict.

…(ARIADNE_WORLDS.md §18.9)

120 Hz was the only rate: each holon defaulted to 1/120 s on its own, and nothing told a client
the relay's quantum. A world can now run at a rate of its own, from 10 to 240 Hz:

- The knob: a scene's clock: { hz }, or arisrv --sim-hz to override the document's. 0 or absent
  means 120.
- sim_tick.h: sim_quantum, sim_tick_quanta and sim_tick. The navigator's tick is the whole number
  of quanta nearest the policies' 0.06 s: 7 at 120 Hz (kSimTick, unchanged), 4 at 60, 2 at 30.
  sim_clock_config and adopt_sim_clock take the quantum.
- SceneWorld::use_vehicle_clock puts the app's clock on the scene's rate before the physics world
  is made. WorldVehicles' default tick follows the world's step.
- holon_config_at(cfg, hz) keeps each tick-counted window's length in seconds: the skew, the lead
  slack, the peer playout, the intent lead and the catch-up.
- The relay builds its holon, and the server document's world (through a load hook), at the rate.
  It publishes the rate as conf.rooms.<room>.clock.hz, a revisioned section with the run's epoch,
  and holds a near entity's pose at 30 Hz.
- Clients build their holon from room_holon_config(app, room). arigl's follow_room_clock rebuilds
  it when on_room_clock says it is off the room's rate, because a holon can't change its quantum
  in place.

Tests: SimTickTest.AWorldsRateSetsItsQuantumAndTheNavigatorsTick,
HolonSyncTest.ARoomsRateIsItsClockSection, HolonSyncTest.ARoomAt60HzIsFollowedByItsClients,
AriadneOneWorld.AWorldAt60HzRunsOnAHolonAt60Hz and AriadneScene.ClockBlockTakesAWorldsRate.
The heavy policy A/B (CVC_NAV_TICK_AB=1) gains a 4/60 s arm.

Not yet: changing the rate on a running relay (today it takes a restart), and a scene swarm,
which needs 120 Hz.
The heavy A/B (CVC_NAV_TICK_AB=1) with its 4/60 s arm, 20 seeds of 48 Jolt RoboRacers through
the city. Reach at 0.06 s, then at 4/60 s: the shipped weights 0.519, then 0.512; the untrained
default 0.522, then 0.517. Both are within the seeds' noise, so no retraining.
…il JX2

numpy-cp312 2.4.6+cvc.7 was published for wasm and wasm-mt on 2026-11-21 (23:43Z), built with
-fwasm-exceptions for JX2 (#1409). libcvc still links ariglx with Emscripten's JS exceptions, so
every ariglx-web job that has installed it since fails to link bin/ariglx.js:

  wasm-ld: error: .../numpy/_core/_multiarray_umath.cpython-312-wasm32-emscripten.so:
    undefined symbol: __cpp_exception (also __wasm_lpad_context, _Unwind_CallPersonality)

pin-wasm-pre-jx1.sh now puts cvc.6 back, as it does for the JX1 bundles. cvc.6 is the bundle
#1417's ariglx-web jobs linked on both columns. Checked locally on wasm and wasm-mt: with cvc.7
installed, 2 of numpy's 19 extensions import __cpp_exception; after the script, the lockfile
says cvc.6 and none do. JX2 deletes the script and its calls.
…clock-rate

JX2 deleted .github/scripts/pin-wasm-pre-jx1.sh, so this branch's numpy pin goes with it.
@transfix
transfix enabled auto-merge (squash) November 22, 2026 09:02
@transfix
transfix merged commit 8552a6b into master Nov 22, 2026
31 of 32 checks passed
@transfix
transfix deleted the feat/world-clock-rate branch November 22, 2026 18:06
transfix added a commit that referenced this pull request Nov 24, 2026
)

* Ariadne: a closed .ari schema every load checks, and ari validate

The .ari document's structure gets a formal definition, roadmap section 15,
now docs/ARIADNE.md section 14:

- src/cvc/ariadne/schema/ari.v1.schema.json: one JSON Schema for every
  top-level block, all 35 built-in widget types, the scene, include: and
  load: sites, with descriptions. Every map is closed: an unknown key is an
  error, except x- keys, a custom widget's or node's own keys, and a block an
  app registered or the document declares in customs:. A widget's type is its
  first type key in the loader's order. It keeps to json-schema-validator's
  draft-7 subset.
- CMake embeds it (CvcEmbedText.cmake) for ari_schema_json() and installs it
  under share/libcvc/ariadne/schema/.
- With the validator built in, every load checks the document, its import:ed
  libraries, its load: fragments and each include: expansion (placed in the
  unit's own file), as warnings and LoadResult::schema_issues with line and
  column. The compiled validators live in a cvc::app slot.
- validate_string / validate_file check without loading, the document's own
  units instantiated with their declared args.
- ari validate [--structural-only] [--strict] [--json] and ari schema.
- ci.yml: package-linux's configure assertion also requires the validator.

All 176 shipped documents are valid; reopen_refit.ari gains its missing
meta.min_libcvc. Five loader tests that feed bad values count the loader's own
warnings and check the schema flags the same pointer. New ariadne_schema_test
and ctests for ari validate and ari schema.

* Ariadne schema: scene: clock: hz, the world's rate

OW8 (#1441) gave the scene's clock an hz key: a whole number of ticks a
second from 10 to 240, as sim_rate_valid takes it. The schema takes it the
same way in both clock entries, and ClockBlockTakesAWorldsRate checks that the
schema accepts hz: 60 and flags each rate the loader warns about.

* Ariadne schema: the hosts' blocks in their short forms

wasm: takes a guest's path alone and relay: a relay's URL alone, as
their readers do; a bare server: or world: sets nothing, as theirs do.
The schema took a map only, so WasmWasiTest's `wasm: all.wat`, under
min_libcvc 3.7.13, failed its load on Linux.

* Ariadne schema: the keys the open PRs add to the loader

The closed schema lands after the PRs that add loader keys, so it carries
their keys now:

- notifications: always, as well as a flag (#1450);
- a tray_icon's icon: and auth: (#1450);
- a color picker's fmt: rgb | hex (#1452);
- a load:'s name:, a key or an expression that names the application
  (#1485);
- scene: clock: max_lag:, more than 0 and at most 10 s, in the scene and
  in a scene of its own (#1475).

Master's own new keys need none: #1472's look: wheel:, wheelbase: and
track: sit in world:, which the world rules check, and #1399's region: is
a custom node's own key.

AcceptsWhatTheLoaderTakes takes each new form; FindsEachMistakeWhereItIs
finds fmt: cmyk and notifications: sometimes.
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