Skip to content

Ariadne shell SH7: asks and grants, input and signals to granted applications, argv: - #1598

Merged
transfix merged 9 commits into
masterfrom
tfx/ariadne-shell-sh7
Nov 28, 2026
Merged

transfix merged 9 commits into
masterfrom
tfx/ariadne-shell-sh7

Conversation

@transfix

Copy link
Copy Markdown
Owner

Phase SH7 of the Ariadne shell (docs/roadmap/ARIADNE_SHELL.md 4.5, 4.6 and the SH7 row): asks and grants, input and signals to granted applications, and argv:. Docs: ARIADNE.md §5.6, §5.7, §6.3, §6.8 and §13, plus an "As built in SH7" note in ARIADNE_SHELL.md.

What it does

  • Grant tokens (inc/cvc/ariadne/grants.h, pure functions):

    • The tokens are delegate.keys/.pointer/.signals, extend.menubar/.tray/.context_menu/.settings, access.settings(.read), request.main_view, request.open and net.origin.
    • A mounted document asks for them in its requires:. net.origin takes origins:.
    • The loading document grants them with grants: on a load: or a mounts: slot. {delegate.signals: [...]} and {net.origin: [...]} limit what those two cover, and deny: takes tokens away.
    • With no grants:, a mount gets extend.tray and extend.settings.
    • A token holds when the document asked for it and was granted it. The two defaults hold without asking.
    • A mount grants its own mounts only what it holds itself. A mounts: entry's own grants picks from its slot's.
  • Refusal:

    • A required token that isn't granted fails a load: (the document's load), or refuses a mounts: entry. Either way the token is named.
    • An optional one leaves (has? ...) false.
    • The entry gets holds and net_origins back.
    • extend.tray now gates a loaded application's tray icons.
  • (has? NAME) answers per mount, in programs, in init: and in the read lane. The document's own scope answers as it would alone.

  • Keys and pointer:

    • The next drain routes a key to the focused application that holds delegate.keys: its on_key:, and its keys: bindings at <sub>.keys.<id>.
    • The document's own bindings match first.
    • No key reaches an application while a text field outside it has the keyboard.
    • The pointer over an application's window goes to its on_pointer: when it holds delegate.pointer.
    • Focus follows the focused window. The backend reports it through window_focused, window_hovered, item_has_keyboard and reports_focus, which ImGui answers.
    • (app-focus AS) also sets the focus. It is mirrored at ariadne.focus.
    • arigl now posts what ImGui takes marked InputEvent::ui, instead of dropping it.
  • Signals. If the shell has no on_signal: of its own:

    • an interrupt goes to the focused application, which takes it over;
    • SIGTERM and SIGHUP go to every application holding delegate.signals, and the host's default still applies.

    A shell that has its own on_signal: passes a signal on itself with (app-signal AS NAME).

  • argv:

    • A load:'s argv: or a mounts: entry's argv is parsed by the document's own args:.
    • It is published under the mount's sub-prefix before the document's init: runs.
    • A bad one refuses the mount with its usage. For a mounts: entry, the usage goes to the feed.
  • net.origin. The origins a mount holds are kept on its slot (MountState::net_origins), in the form SH11's ScopePrincipal::net_origins takes.

  • ari test --mounted runs a document as a shell's application, granted what it would hold alone, with its tests run in its scope.

  • Schema. The .ari schema learns grants:, deny: and argv:, and origins: on a requires: entry.

Where it differs from the design (in the As-built note)

  • An optional token that isn't granted does not warn.
  • The defaults hold without being asked for.
  • Only extend.tray is enforced among the extend.* tokens. The rest, and access.* and request.*, are only answered and checked at mount until SH9, SH6 and SH14.
  • grants: { ask: } warns (that's SH9).
  • Ctrl+Tab is not bound, because keys: bindings have no modifiers yet.
  • The pointer over the main view waits for SH6's front application.
  • The terminal backends don't report focus yet, so there (app-focus) is the only way to move it.

Coordination

Tests

  • ariadne_grants_test (20, new). It covers:
    • the grant arithmetic, and the loader's grants, warnings, origins and argv;
    • a refused mount;
    • keys reaching only the focused granted application, none while the shell's field has the keyboard, and the parent's binding keeping its key;
    • focus following the focused window;
    • SIGTERM reaching every granted application and SIGINT only the focused one, a signal list, and app-signal;
    • argv, and a bad one's usage in the feed;
    • has? per mount, origins, a static load: taking keys, and the tray gate;
    • one document's tests alone and mounted;
    • two apps side by side.
  • ari_grants_alone and ari_grants_mounted: src/ari/tests/grants_component.ari run with ari test and with ari test --mounted.
  • Run locally (Windows, MSVC Release, no cvcGL): ariadne_grants_test 20/20, ariadne_loader_test 282, ariadne_runtime_test 378, ariadne_requires_test 20, ariadne_schema_test 14 (1 skipped by design), ariadne_deep_nesting_test 19. The ctests ari_grants_alone, ari_grants_mounted, ari_processes_component and ari_chat_component pass.
  • Not built or run locally:
    • the cvcGL ImGuiBackend hooks and the arigl input change (cvcGL is off in this build);
    • the singleton scan, which needs Linux objects.

…ications, argv:

docs/roadmap/ARIADNE_SHELL.md 4.5, 4.6 and the SH7 row; ARIADNE.md 5.6, 5.7, 6.3, 6.8, 13.

- Grant tokens (inc/cvc/ariadne/grants.h): delegate.keys, .pointer, .signals, extend.menubar,
  .tray, .context_menu, .settings, access.settings(.read), request.main_view, request.open and
  net.origin, with a meaning for authors and words for the sheet. A mounted document asks in its
  requires: (net.origin with origins:), the loading document grants with grants: on its load: or
  mounts: slot ({delegate.signals: [...]} and {net.origin: [...]} limit what they cover), deny:
  takes tokens away, and with neither the mount gets extend.tray and extend.settings. A token
  holds when asked and granted (the defaults without asking); a mount grants its own mounts only
  what it holds. A mounts: entry's own grants pick from its slot's.
- A required token not granted fails a load: (the document's load) or refuses a mounts: entry,
  named; an optional one leaves (has? ...) false. (has? NAME) answers per mount in programs (the
  held set taken on the host thread with the context, kept by spawned children), init: and the
  read lane; the document's own scope answers as it would alone. The entry gets holds and
  net_origins back. extend.tray gates a loaded application's tray icons.
- Input: post_input queues what a mount may take; the drain routes a key to the focused
  application holding delegate.keys (its on_key: and its keys: bindings at <sub>.keys.<id>), after
  the document's own bindings, and to none while a text field outside it has the keyboard; the
  pointer over an application's window to its on_pointer: with delegate.pointer. The focus follows
  the focused window (Backend::window_focused, window_hovered, item_has_keyboard, reports_focus;
  ImGui answers them) or (app-focus AS), mirrored at ariadne.focus. InputEvent::ui marks what the
  host's UI took: arigl posts it marked instead of dropping it.
- Signals: without an on_signal: of its own, the shell passes an interrupt to the focused
  application (taken over) and a request to end to every application holding delegate.signals
  (the host's default still applies); with one, (app-signal AS NAME) passes one on.
- argv: a load:'s argv: or a mounts: entry's argv is parsed by the mounted document's args:,
  published under its sub-prefix before its init:; a bad one refuses the mount with its usage (in
  the feed for a mounts: entry).
- net.origin: the origins a mount holds are kept on its slot (MountState::net_origins), in the
  form SH11's ScopePrincipal::net_origins takes, ready to hand over once #1576 is
  on master.
- ari test --mounted runs a document as a shell's application, granted what it holds alone, with
  its tests in its scope (MountResult/MountState::tests, Runtime::run_program_in_mount).
- The .ari schema learns grants:, deny:, argv: on load: and mounts:, and requires: origins:.

Tests: ariadne_grants_test (the arithmetic; the loader's grants, warnings, origins and argv; a
refused mount, keys to the focused granted application only and none while the shell's field
has the keyboard, the parent's binding keeping its key, focus following the focused window,
SIGTERM to every granted application and SIGINT to the focused one, a signal list, app-signal,
argv and a bad one's usage in the feed, has? per mount, origins, a static load: taking keys, the
tray gate, one document's tests alone and mounted, two apps side by side); ari_grants_alone and
ari_grants_mounted (src/ari/tests/grants_component.ari, Linux CI with FTXUI).
…l's own left out

From SH11's review of the hand-off (#1576):
- policy_origin is cvc::net::parse_origin_spec(spec)->str(), the parse SH11's net host reads
  net_origins with. An origin it refuses (a path after it, not http(s)) is refused at grant
  time with its reason, in the requires: warning, the grants: warning and the mount's refusal:
  the net host would otherwise fail every request of the mount without a word.
- The origins a mount holds are worked out with its principal before the wrapper moves, so
  SH11's set_scope_principal block can take them before any program is built, and a remote:
  principal's own origin is left out (it reaches it anyway; listing it only costs a cache key).

Tests: AriadneGrants.PolicyOriginsAndSignalNames (a path refused, with its reason),
AriadneGrantsRuntime.AMountHoldsTheOriginsItsSlotGrants (a mount asking for an origin with a
path is refused, naming why).
SH11's ScopePrincipal::net_origins now gets what SH7 grants: open_mount
records a mount's held origins with its principal, and a hot reload that
changes them records the new list. Conflicts kept both sides (the source
list takes principal.cpp and grants.cpp; the shell entry list takes
grants/argv and net_policy/credential_store/e2ee_store; finish_context
passes the scope to install_host_verbs and the held grants to has?).
…Gui does

Joe's policy is that the shell works in ari on FTXUI and tvision, not only
in arigl, so grants and input routing must behave the same there.
FtxuiBackend now answers Backend::reports_focus, window_focused,
window_hovered and item_has_keyboard: the focus is in the window holding
the focused widget, else the one last clicked or raised; the pointer is
over the window at its cell; a focused text field has the keyboard.
Hosted, tvision says which (FtxuiBackend::set_window_focus): the desktop's
current window and the frontmost under the pointer. What the UI used now
goes to the Runtime marked InputEvent::ui (FtxuiBackend::post_taken), as
arigl posts what ImGui takes, so a focused application gets the keys its
own field takes and the shell's handlers still never see them.

Tests: AriadneFtxuiShell, a shell with two applications on FTXUI (click to
focus, keys and clicks to the one whose window has them, its own field's
keys too, none while the shell's field has the focus) and hosted (the host
sets the focus and the pointer).
@transfix

Copy link
Copy Markdown
Owner Author

package-linux / libcvc-debug at 07b26a9 (run 46111424334): merged master in as 215ee61.

  • AriadneMounts.ABusyMountIsHeldToItsBudgetWhileTheOthersRun (failed every retry) and TheShippedExamplesKeepWithinTheLocalBudget (failed once): fixed on master by AriadneMounts: budget tests that don't depend on runner speed #1605, which this branch now has.
  • AriadneMounts.TheCatalogFlagOrCatalogMakesALocalFileLocal failed once, in the third retry of ariadne_runtime_test_threads_auto. Its a/b/c mounts didn't each reach 2 ticks within pump_until's 5 s, and none of them had an error. In the same job it passed in 0.80 s as its own ctest and in the two earlier threads_auto runs.

SH7 doesn't slow mount ticking. What it adds to a frame is one ariadne.focus read in end_frame_focus, a loop over the mounts in want_mount_input, the backend's focus calls per window, and an app_of lookup plus a small set copy per action context (held_at). These mounts ask for no grants, and held_at is only called on the host thread (submit_action, ensure_resident, start_process). Timed locally on 215ee61 (Windows):

run passed whole test (ms)
serial, 30 repeats 30 / 30 median 108, max 132
CVC_EXEC_THREADS=auto, 30 repeats 30 / 30 median 95, max 130
CVC_EXEC_THREADS=auto, 44 copies at once on 22 cores (each with its own TMP), 15 repeats each 660 / 660 median 153, p95 216, max 366

So the CI miss was a stall of over 5 s on a loaded Debug runner, not a steady slowdown. If it recurs, the test's first pump_until can take a longer budget, as #1605 did for the budget tests.

Conflicts kept both sides: the mounts: slot's grants:/deny: next to its
in_background: (widget.h, the schema), a load:'s command line and keys'
defaults next to its datasets (emit_container, open_mount, hot reload),
a load:'s grants next to its scene plan (plan_windows_menu), grants.cpp
next to table_emit.cpp, and the docs' shell.apps entry list.
load_mount_checked keeps SH7's prefix-aware message for gl.scene and
drops the "not drawn in a mount yet" warning, as SH3 did.

As agreed for whichever of #1597/#1598 merged second, a fragment's keys:
are SH7's alone (MountGrants::keys, held with delegate.keys):
MountScene::keys, its parse in parse_mount_scene, its term in the null
check and its two asserts in AriadneLoader.AFragmentsSceneIsParsed are
gone, and the docs and comments that listed keys with a mount's scene and
datasets say so.
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