Skip to content

Ariadne shell SH1: mounts:, app-open/app-close, budgets per mount, shell.ari - #1566

Merged
transfix merged 7 commits into
masterfrom
tfx/shell-sh1-mounts-fb75fd
Nov 27, 2026
Merged

transfix merged 7 commits into
masterfrom
tfx/shell-sh1-mounts-fb75fd

Conversation

@transfix

@transfix transfix commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Ariadne shell phase SH1 (docs/roadmap/ARIADNE_SHELL.md 4.1, 4.2 and 4.11, the SH1 row, the decisions of 2026-11-23). Documented in docs/ARIADNE.md §6.8, with an "As built in SH1" note in ARIADNE_SHELL.md 4.2 and 4.11.

What it builds

  • mounts: <state key>: one isolated mount per child of the key (uri, args.*, budget.*).
    • It loads through load_mount (loader.h): expand_load in a fresh context, stateless, using the same resolver, component paths and guards as a static load:, plus the min_libcvc gate.
    • AppRuntime gives the Runtime that loader (Runtime::set_mount_loader), with the requires: check against its host.
    • The Runtime keeps each mount in a slot by sub-prefix (includes.<id> under the slot's scope). It reconciles the slots at the top of each frame (open, close, parse again) and plans the Windows menu over them.
    • A mount is an application: its bar becomes one menu of the outer bar. One without a bar gets a menu of Restart, Quit and Close.
    • Its init: runs and its on_tick: starts as it opens.
    • The entry gets status, error, principal and name back.
  • Closing quits the mount, kills every process under its scope (forks and spawns too) and frees its slot, widgets and budget. Its state stays under includes.<id>, so reopening resumes it without running init: again.
  • Caching and hot reload. A mount is parsed again only when its uri, args or one of its files changes. AppRuntime::reload_if_changed also polls the mounts' files. A mount parsed again keeps its on_tick: resident when the program is the same.
  • allow:, a literal list or { bind: <key> }. A refused URI is posted to the feed.
  • requires: at mount time. What the static scan would fail or warn on refuses the mount, named: a required entry, a function a program calls that the host lacks, or gl.scene for a scene: on a host without one. An optional entry the host lacks stays a warning.
  • (app-open URI [AS [ARGS]]) and (app-close AS) act on the calling document's first slot. Without an id, app-open takes the URI's file name and returns an entry already open on that URI. A mounted document gets a PermissionError.
  • Budgets. cvc::state_exec::frame_account (process.h) is a share of each frame that several processes draw on (execute_options::account; spawn and fork keep the parent's).
    • The async scheduler charges each step's steps and seconds and ends a run at the limit.

    • It parks a spent account's processes as (await) does, until the next frame, and never kills them. wake_awaiting starts every account's new frame.

    • Memory is the processes' measured heap shares. The scheduler now measures them under a memory-capped account without a limit of its own (process::measures_heap). The Runtime sums them four times a second.

    • Defaults by principal, local / file: and remote: (per frame):

      local file:, remote:
      steps 100000 20000
      seconds 0.025 0.005
      memory 256 MB 64 MB
    • After 3 s held, a notice is posted. Its click opens a Budgets window with Allow more (doubles the entry's budget.*), Quit and Restart, because a feed entry has a single action.

    • The apps mirror carries principal and budget.*, and processes.ari shows each application's share.

  • data: entry uri: { arg: NAME }, filled in from the parsed command line. A relative path is taken from the working directory.
  • A menu_item: label that is an expression is worked out each frame. The Apps menu needs it to list the catalog by title.
  • components/shell.ari (cvc://components/shell.ari):
    • --catalog in gallery.json format, plus --open SLUG,...;
    • an Apps menu, a Launcher window (Open, Close, each entry's state), processes.ari and a mounts: shell.apps slot.
    • examples/ariadne/documents/shell_apps.json lists tray_demo, json_feed and apps/counter.
  • Schema. The closed .ari schema gets mounts: (mounts_site, with allow:/catalog: as uri_list) and the data uri: { arg }. ari validate follows from the schema. INDEX.ari lists shell as a document component.

A decision for Joe

catalog: on the slot. Principals come from where the bytes came from (4.12). A local file can't say on its own whether it is the shell's catalog app (local) or a file the user opened (file:<dir>), so the slot names its catalog: catalog: { bind: shell.catalog_uris }, which shell.ari fills from --catalog.

The alternative is a flag the shell writes on each entry (shell.apps.<id>.catalog). It's an easy swap if you prefer it.

view, background, grants and argv aren't read yet; they belong to SH3, SH6 and SH7. A static load: still shares its document's budget.

Verified

On Windows (MSVC 19.44, Release, cvcGL off; this ari has FTXUI and tvision), at 189d397 (this branch with master 104bca2 merged in), with TMP set to a short path:

Suite Result
ariadne_runtime_test 378 passed
ariadne_loader_test 280 passed
ariadne_host_test 69 passed
state_exec_async_test 144 passed (1 skipped: a death test that Release skips)
state_exec_integration_test 105 passed
ariadne_schema_test 13 passed, including EveryShippedDocumentIsValid (1 skipped: the case without a validator)
ariadne_deep_nesting_test 15 passed (#1577's 256 KiB stack and #1586's 2 MiB), including the new AMountsSlotsEntriesDraw

The new tests:

  • AriadneMounts.AMountsStateBlockIsWrittenAsItOpens: a mounted document's state: (Ariadne: a state: block, the document's starting values without init: calls #1563) is written as it opens, before its init: reads it; a reopen keeps a changed value, and Restart writes the seeds again. It fails without the fix.
  • AriadneMounts.OpenCloseAndReopenKeepItsState: after close, no process is left under the mount, its sources and slot are gone, the scheduler holds no account, no widgets are drawn, and it is no longer an application.
  • AppOpenAndAppCloseActOnTheCallingDocument.
  • ARefusedUriIsPostedToTheFeed.
  • AnUnmetRequiresRefusesTheMount.
  • HotReloadKeepsTheResidentWhenItsProgramIsTheSame.
  • ABusyMountIsHeldToItsBudgetWhileTheOthersRun: the busy mount never exceeds 5064 steps a frame, isn't killed, gets the notice, and Allow more doubles its budget.
  • AMountPastItsMemoryIsHeld.
  • TheShippedExamplesKeepWithinTheLocalBudget: every example mounted as a catalog application with a stub scene adapter. The busiest uses 108 steps and under 0.4 ms in a frame; none is held. The 8 the host refuses (net, oidc, stream_view, quit, a custom verb) are listed.
  • AriadneComponents.ShellOpensItsCatalogOnDemand: the AppRuntime stand-in for the tmux run. It opens with --open, checks the menus and windows, runs a menu item in the mount's scope, closes, and reopens with state kept.
  • AriadneLoader.MountsSlotAndADataUriFromAnArgument.
  • AriadneLoader.LoadMountParsesAnEntrysDocument.
  • AriadneLoader.LoadMountRefusesADocumentNestedPastTheLimit: a mounted document at Ariadne loader: about 1 KB of stack a level, and a document nests at most 256 levels #1586's 256-level limit mounts, and one a level deeper is refused with the nesting error.
  • AsyncSchedulerTest.AFrameAccountHoldsItsProcessesToTheirFrame, at slice 1 and slice 256.

The first CI run failed ARefusedUriIsPostedToTheFeed on Windows. The runner's temp path uses an 8.3 short name (RUNNER~1), and the slot compared it with the resolver's long-name base. Since eaa7b11 (originally 9d8125b, before the rebase), allow: and catalog: paths are compared in canonical form. The failure reproduces locally with TMP set to a short path, and with the fix all 377 runtime tests pass that way.

ari validate passes shell.ari. ari snapshot --backend ftxui of shell.ari --catalog shell_apps.json --open counter,json_feed draws the bar as Apps Counter JSON feed Windows, with the Counter's tray star and the feed's window.

Not run here: ari_run_shell_{ftxui,tvision}, the tmux run (Linux CI only, no tmux on this box). The cvcGL build wasn't built locally; the ImGui backend and arigl are left to CI.

Merged with #1563 (state:)

#1563 landed on master after the rebase. It is merged in (36d8db4); the one conflict was two declarations added at the same place in widget.h, and both are kept.

With #1563, a load: module's state: seeds are written just before its init:. A mounts: entry's wrapper carries them too, but open_mount ran only the init:. That marked the mount done, so the seeds were never written.

f9f6a94 writes them just before the init:, as a load: module's are: once as it opens, not again on a reopen, and again on Restart. ARIADNE.md 5.3 and 6.8 say so.

Merged with #1586 (the loader's nesting limit)

#1586 landed next and conflicted in loader.cpp, ARIADNE.md and the deep nesting tests. Master is merged in (189d397):

The writable-data scan

CI at f9f6a94 failed package-linux / libcvc-release-grpc in its writable-data scan; all its tests passed. mount_principal and open_mount each kept a static const MountsSpec kNoSpec for a slot without a spec, a bss object and a guard variable each. Since aac42a3 each is a local, so nothing is left process-wide and the allowlist is unchanged. The scan reads ELF objects, so it can't run on this box; CI checks it again.

On top of #1577 (the walk on the heap)

As Joe asked, #1577 merged first, and this branch was replayed onto it. The SH1 parts of the walk now follow #1577's rules: nothing in them recurses, so a mounts: slot draws on #1577's 256 KiB test stack.

  • emit_mounts pushes one walk frame per open mount (its id, then the wrapper's walk) rather than calling emit(), which nests a walk.
  • plan_windows_menu's Kind::Mounts case puts each open mount's wrapper on the plan's Visit stack. After it comes a marker visit that records the mount as an application when it has no bar of its own.
  • app_commands ends each application's menu: Restart, Quit, and Close for a mounts: entry's. An application without a bar gets that menu alone.
  • drop_mount_ticks walks each kept mount's wrapper on its heap list.
  • set_root's search for the document's own slot is a loop over a heap list. It used to recurse, which overflowed four of Ariadne: the per-frame walk keeps its place on the heap, so any depth draws on a small stack #1577's deep tests.
  • New test AriadneDeepNesting.AMountsSlotsEntriesDraw:
    • on a 256 KiB stack, three mounts open in one slot: a window nesting 3000 groups, a bar of 3000 nested menus, and one with no bar;
    • over three frames, each mount draws in full every frame (the deepest text, the deepest menu item, each application's Close), and the pushes and pops stay balanced.

Before #1577, this branch had to keep emit_node's frame small, so the slot's data sits behind one pointer (Widget::mounts) and its emit work is in helpers that are never inlined. Both stay: they cost nothing, and they keep each walk step small.

…ell.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).
…l 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.
…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.
@transfix
transfix force-pushed the tfx/shell-sh1-mounts-fb75fd branch from 9d8125b to 124a59c Compare November 27, 2026 04:54
#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.
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.
…ounts-fb75fd

#1586 builds each widget in place and splits expand_load into read_fragment, open_mount and
finish_mount. SH1's LoadOutcome (why a fragment was not mounted, its canonical path, whether it has
a scene, and the min_libcvc gate a run-time mount keeps) moves into read_fragment, and expand_load
passes it through. parse_mounts builds its slot in place like the other widgets.

load_mount gives its context a Nesting, as load_node does, and refuses a document nested past
kMaxNesting with that error rather than mounting it cut short: a mounts: entry's document nests as
a document of its own does. New AriadneLoader.LoadMountRefusesADocumentNestedPastTheLimit.

ARIADNE.md: #1586's "How deep a document nests" keeps 6.7, which its error message cites, and
mounts: is now 6.8; SH1's references to it follow. The deep nesting tests keep both sides.
@transfix
transfix merged commit daf6367 into master Nov 27, 2026
31 checks passed
@transfix
transfix deleted the tfx/shell-sh1-mounts-fb75fd branch November 27, 2026 19:15
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