Repository navigation
Ariadne: a state: block, the document's starting values without init: calls - #1563
Merged
Merged
Conversation
… calls A document's state: is a map of state paths to literal values, written under its prefix (seed_state) on every load just before init: runs, so init: reads and may override them and, like an init: seed, they win over a widget's def:. A load:ed module's state: is written at its mount's sub-prefix just before its init:, once, and again on a Restart. A map's keys are path segments (one may hold dots; a top-level one may start with / for the app root); a scalar is written as spelled, a list of scalars joined by commas, nothing as "". Anything else, and a key that is not a path, warns and is left out; a key given twice warns. The schema gains top-level state and a recursive $defs/state_tree. ARIADNE.md 5.1, 5.3, 5.25 and 12 describe it, and cars.ari's 24-line init: becomes a state: block with the same keys and values in the same order.
transfix
added a commit
that referenced
this pull request
Nov 27, 2026
#1563 added a document's state: block. A load:ed module's seeds are written at its sub-prefix just before its init:, once, and again on a Restart. A mounts: entry's wrapper carries the same seeds (load_mount goes through expand_load), but open_mount ran only its init:. That marked the mount done in ran_inits, so the seeds were never written. open_mount now writes them just before the init:, under the same once-only check. Reopening resumes without writing them, and a Restart writes them again (emit_container, as for a load: module). AriadneMounts.AMountsStateBlockIsWrittenAsItOpens checks that init: reads the seeds, a reopen keeps a changed value, and a Restart writes the seeds again. It fails without the fix: the mount opens but count is empty. ARIADNE.md 5.3 and 6.7 and the ARIADNE_SHELL.md 4.2 note say so.
transfix
added a commit
that referenced
this pull request
Nov 27, 2026
…ell.ari (#1566) * Ariadne shell SH1: mounts:, app-open/app-close, budgets per mount, shell.ari docs/roadmap/ARIADNE_SHELL.md 4.1, 4.2, 4.11 and the SH1 row; ARIADNE.md 6.7. - mounts: <key>: one isolated mount per child of the key (uri, args), loaded through load_mount (expand_load in a fresh context, stateless) with the loader AppRuntime gives the Runtime (Runtime::set_mount_loader). Its init: runs and its on_tick: starts as it opens; it is an application (its bar one menu of the outer bar; one without a bar gets Restart, Quit, Close). Closing quits it, kills every process under its scope and frees its slot; its state stays, so reopening resumes it. Parsed again only when its uri, args or a file changes; hot reload keeps its resident when its program is the same. allow: (a list or { bind }) narrows what may be mounted, a refusal posted to the feed; catalog: names the documents that run as the local principal. The requires: check at mount refuses what the static scan would fail or warn on (a required entry, an unprovided call, gl.scene for a scene: on a host without one). - (app-open URI [AS [ARGS]]) and (app-close AS) on the calling document's first slot; a mounted document gets a PermissionError. - A budget per mount: cvc::state_exec::frame_account (execute_options::account, kept by spawn and fork). The async scheduler charges steps and seconds, ends a run at the limit, and parks a spent account's processes until the next frame (never killed); wake_awaiting starts each account's new frame. Memory is the processes' measured heap shares (process::measures_heap), summed by the Runtime. Defaults by principal (local 100000 steps, 0.025 s, 256 MB a frame; file: and remote: 20000, 0.005 s, 64 MB), settled against every shipped example (busiest: 108 steps, under 0.4 ms a frame). Held for 3 s: a notice whose click offers Allow more, Quit and Restart. The apps mirror carries principal and budget.*; processes.ari shows each share. - data: uri: { arg: NAME }; a menu_item: label that is an expression. - components/shell.ari (--catalog in gallery.json format, --open), an Apps menu, a Launcher, processes.ari, a mounts: slot; examples/ariadne/documents/shell_apps.json (tray_demo, json_feed, apps/counter). - The .ari schema learns mounts:, allow:, catalog: and uri: { arg }. Tests: AriadneMounts.* (open, close with its memory freed, reopen with state kept, the verbs, a refused URI, unmet requires:, hot reload, a busy mount held while another runs, a mount past its memory, the shipped examples within the local budget), AriadneComponents.ShellOpensIts- CatalogOnDemand, AriadneLoader.MountsSlotAndADataUriFromAnArgument and LoadMountParsesAn- EntrysDocument, AsyncSchedulerTest.AFrameAccountHoldsItsProcessesToTheirFrame, and ari_run_shell_{ftxui,tvision} (tmux, Linux). * mounts: compare an allow: or catalog: path in the resolver's canonical form On the Windows CI runner the temp directory is spelled with an 8.3 short name (C:\Users\RUNNER~1\...). The slot's base comes from the resolver, which uses weakly_canonical, so it holds the long name. The entry's path was only made lexically normal, so the two never matched, and AriadneMounts.ARefusedUriIsPostedToTheFeed saw its allowed file refused. mount_norm now makes a local path canonical the way the resolver does (links followed, short names spelled out), and keeps a trailing slash so an allow: prefix still matches only under its directory. Reproduced and verified locally by running ariadne_runtime_test with TMP set to a short path: all 377 pass. * mounts: no recursion on a deep document, and a mounts: slot drawn on a small stack Rebased onto the iterative walk (#1577): - emit_mounts pushes a frame per open mount (its id and emit_path entry, the wrapper on the walk, then a Then that pops them) instead of emitting each in a nested walk. - plan_windows_menu's Mounts case pushes each open mount's tree, then a marker visit that makes it an application if it brought no bar (ARIADNE_SHELL.md 4.9), keeping tree order. - app_menu ends every application's menu through app_commands (Restart, Quit, and Close for a mounts: entry's); one without a bar gets those alone. - drop_mount_ticks seeds its loop with the slots' wrappers. Runtime::set_root's search for the document's own first mounts: slot recursed once a level: it overflowed ariadne_deep_nesting_test's 256 KiB stack on PlainGroups, MenusAndTrayMenus and the FTXUI and tvision plain-group tests. It is a loop now. AriadneDeepNesting.AMountsSlotsEntriesDraw: three entries opened and drawn on the small stack, a window nesting 3000 groups, a bar whose menu nests 3000 submenus, and one without a bar, each with its Close item, every begin_* and push_id balanced. * mounts: a mounts: entry's state: block is written as it opens #1563 added a document's state: block. A load:ed module's seeds are written at its sub-prefix just before its init:, once, and again on a Restart. A mounts: entry's wrapper carries the same seeds (load_mount goes through expand_load), but open_mount ran only its init:. That marked the mount done in ran_inits, so the seeds were never written. open_mount now writes them just before the init:, under the same once-only check. Reopening resumes without writing them, and a Restart writes them again (emit_container, as for a load: module). AriadneMounts.AMountsStateBlockIsWrittenAsItOpens checks that init: reads the seeds, a reopen keeps a changed value, and a Restart writes the seeds again. It fails without the fix: the mount opens but count is empty. ARIADNE.md 5.3 and 6.7 and the ARIADNE_SHELL.md 4.2 note say so. * mounts: no function-local static for a slot without a spec mount_principal and open_mount each kept a `static const MountsSpec kNoSpec` to stand for a slot without a spec. A function-local static of a non-trivial type is a bss object and a guard variable, so the writable-data scan on package-linux / libcvc-release-grpc failed on four symbols that are not on the allowlist. Each is now a local MountsSpec: an empty one costs no allocation, and nothing is left process-wide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A document can now give state keys their starting values in a
state:block, instead of a run of(state-set ...)calls ininit:.Why
68 of the 202 shipped documents use
init:to seed literal values: 231state-setcalls with a literal value. In 53 of them,init:does nothing else.cars.ari's was 24 lines of(state-set "run.crop" "600")and the like.What it does
bind:. A top-level key starting with/is app-root-absolute.seed_state) on every load and reload, just beforeinit:runs, afterargs:,data:and thekeys:defaults. Soinit:reads them and may override them, and, like aninit:seed, they win over a widget'sdef:.load:ed module's ownstate:is written at its mount's sub-prefix just before the module'sinit:, once, and again on a Restart, under the same once-only gateinit:already has. A module with astate:and noinit:is seeded too.paused: 0writes0,ready: truewritestrue), so converting aninit:keeps what it wrote;"".a..b, a trailing dot, a/below the top level);A key given twice warns, and the later value is used.
Changes
inc/cvc/ariadne/widget.h:StateSeeds, andWidget::state_seedson a mount wrapper.inc/cvc/ariadne/loader.h,src/cvc/ariadne/loader.cpp:LoadResult::state_seeds,parse_state(for the document and aload:fragment), andstateamong the loader's top-level blocks.inc/cvc/ariadne/ariadne.h,src/cvc/ariadne/ariadne.cpp:seed_state. A mount writes its seeds just before itsinit:, and a restart clears that gate as before.src/cvc/ariadne/app_runtime.cpp:AppRuntime::loadseeds just beforerun_init. The relay's server document loads through it too.state, and a recursive$defs/state_tree(scalars, null, lists of scalars, maps). Its keys stay open because they are the document's own names.state(andprototypes, which was missing);state:is written before itsinit:.bindings/pycvc/pymod_gl/cars.ari: itsinit:becomes astate:block holding the same 24 keys and values in the same order (checked by script), withmin_libcvc4.0.9. The other shipped documents are left as they are, to stay out of other work's way.Tests
ariadne_loader_test:AriadneState.BlockFlattenedInOrder: nested and dotted keys, an app-root key, a list, an empty list, nothing, a quoted string,yesand1.50kept as spelled.AriadneState.BadEntriesWarnAndAreLeftOut: a list for the block, an empty block (no warning),/below the top level,a..b, a trailing dot, a map in a list, a key given twice.ariadne_host_test:AriadneState.AppRuntimeWritesItBeforeInit:init:reads one seed and overrides another, an app-root key lands at the root, a list and an empty value, and a slider'sdef:does not replace a seed.AriadneState.AReloadWritesItAgain.AriadneState.AModulesStateIsWrittenAtItsMountBeforeItsInit: a module'sinit:reads its seed at the sub-prefix, a module with noinit:is seeded, the parent's key of the same name is untouched, and a second frame does not seed again.ariadne_schema_test: a validstate:document inkValid, and two mistakes: a list for the block, and a map inside a list.Verified locally
Windows, MSVC, with the JSON-schema validator and FTXUI (no cvcGL, no pycvc), on master 633e605:
ariadne_loader_test: 274 pass.ariadne_schema_test: 13 pass, plus 1 skip by design (the without-validator case). This includesEveryShippedDocumentIsValid, socars.ari'sstate:validates.ariadne_host_test: 69 pass.ariadne_runtime_test: 368 pass.ari validate: a nested, list and emptystate:is valid. A map inside a list is reported at/state/a/1, at its line and column.-R [Aa]ri): 1,286 of 1,290 pass. The 4 that fail areAriMediaterminal-snapshot colour checks, and they fail the same way on an older build without this change, so the cause is something on this machine.Not verified: cvcGL, pycvc, wasm, Linux and macOS (CI covers them). No code builds
Widgetpositionally, so the new member shifts nothing.