Skip to content

Ariadne shell SH11: the network, credentials, keys and sign-ins per principal - #1576

Merged
transfix merged 7 commits into
masterfrom
tfx/shell-sh11-net-principals-8f9594
Nov 28, 2026
Merged

transfix merged 7 commits into
masterfrom
tfx/shell-sh11-net-principals-8f9594

Conversation

@transfix

@transfix transfix commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Phase SH11 of the Ariadne shell (docs/roadmap/ARIADNE_SHELL.md 4.12): the network, its credentials, the end-to-end keys and the OIDC sign-ins per principal, so a document mounted beside nicotina cannot post as the reader or reach the origins nicotina may. It gates SH12-SH15.

Built on SH1 (#1566, merged): each mounts: entry runs as the principal SH1's mount_principal gives it.

What it builds

  • Who a program runs as (inc/cvc/ariadne/principal.h): a table per app of scope to principal (local, file:<dir>, remote:<origin>). A scope under several recorded ones runs as the innermost. A local one inside a sandboxed one runs as the sandboxed one. A host can check a principal as it is recorded: the net host refuses a local application whose own policy does not load.
  • Mounts: open_mount records each mount's principal under its scope before any of its programs is built. It reads the entry's shell.apps.<as>.net_policy, .credential_store and .e2ee_store, and refuses the mount if a check fails or a sandboxed mount names one. close_mount and the Runtime's teardown clear it once the mount's processes are gone. shell.ari takes those three from a catalog entry (paths relative to the catalog) and opens such an entry under its slug with them written first.
  • Credentials (CredentialStore): one store, one file and one lock, seen through one view per principal (for_principal). Each view has its own entries, bindings and renewers. A lookup by name finds only the caller's principal's. File lines are <principal> <name> <origin> <token>, with the principal percent-encoded. A three-word line from an older file loads as local.
  • The request check (enable_net): each program's verbs are bound to net_host_access(app, scope), where the scope is intrinsics_context::root_path. That covers the http verbs, fetch, http-upload, ws-*, net-*, open-url and oidc-*.
    • local gets the launcher's allowlist, as before.
    • remote:<origin> gets its own origin plus ScopePrincipal::net_origins.
    • file:<dir> gets only net_origins.
    • net_origins is the input from SH7's net.origin grants. Nothing writes it yet.
  • A local application's own network: its policy file, its credential store and its e2ee store, as bin/nicotina passes --net-policy fleet.policy --credential-store .... A policy with no store of its own gets an in-memory store, so its credential lines don't rebind the launcher's names.
  • WebSockets: a handle belongs to the program that opened it. Another principal's program gets "no WebSocket" for it.
  • Sign-ins: kept per owner, with the owner's policy and store. A sandboxed principal's sign-ins are not posted to the global oidc#NAME channel, which any program can read.
  • End-to-end keys: a sandboxed principal gets its own in-memory store, never the launcher's keys.
  • Pictures, video and Save with auth: are fetched as the principal of the widget that names them (ImageRequest::scope, PlayerSource::scope, MediaSave::scope, each the struct's last member, so existing positional initializers are unchanged). Each is checked against that principal's allowlist and uses its credential, and the image cache keeps one principal's pictures apart from another's.
  • mount_principal: a mount whose name has no directory (a loader that gives no canonical path, and no base) is file:. rather than file:. A principal names a directory, and the store refuses an empty one.
  • Docs: ARIADNE.md §10.3 "Per principal" and §6.7's entry keys; an "As built in SH11" note in ARIADNE_SHELL.md §4.12.
  • Schema: SH11 adds no .ari document key. The new settings are state keys under the shell's shell.apps.<as>.

Tests

  • ariadne_net_principal_test (new):
    • a credential captured by one mount is not found from another, even where the other may reach the origin;
    • the credential file keeps each principal's lines, and the next run gives each principal its own back;
    • each mount's allowlist holds (local, remote: with a grant, file: with and without one), and fetch keeps to it too;
    • nicotina, with its own policy and credential file, signs in and posts against a local stand-in;
    • an own policy that does not load refuses the mount;
    • WebSocket handles, sign-ins, e2ee keys and a picture's credential are each their principal's;
    • the scope-to-principal rules.
  • ariadne_runtime_test, through mounts::
    • AriadneMountsNet.AMountReachesTheNetworkAsItsPrincipal: a catalog mount as local and another file as file:<dir>, with credentials and allowlist apart;
    • AriadneMountsNet.AnEntryGivesALocalApplicationItsOwnNetwork: an entry's own policy and store, and the refusals;
    • AriadneComponents.ShellGivesACatalogEntryItsOwnNetwork: shell.ari opening a catalog entry with its own network.
  • net_policy_test: the store's views per principal, its bindings and renewers, principal spellings, the file's new lines, old lines loading as local, and malformed principals refused without quoting the line.
  • Run on Windows (MSVC Release) after merging master: all 381 ariadne_runtime_test cases (SH1's mount, shell and budget ones and the existing net, OIDC, WebSocket and media ones among them), ariadne_deep_nesting_test 19, ariadne_media_test 62, ariadne_files_test 23, multi_app_integration_test 5, net_policy_test 31 (1 skip), ariadne_net_principal_test 10 (the e2ee case skips: no libsodium), and the other ariadne_*, net_* and OIDC suites. The ari_* and e2ee suites skip on that box (no FTXUI, no libsodium); CI runs them.

Compatibility

  • A credential file from before this change loads unchanged: its lines all become local's. The first capture, forget or clear after that rewrites the file with a principal on every line, and an older libcvc then refuses to load it ("is not ' '"). Going back to an older host means signing in again, or deleting the leading local from each line.
  • enable_oidc's signature changed: it now takes the base NetAccess and a resolver from scope to access. It is called only from enable_net.

Not verified

  • The real nicotina in the shell, against dev.tx.wtf or stub_txwtf.py: checked instead with the nicotina-shaped stand-in above, at the libcvc level.
  • The e2ee case (EndToEndKeysAreAPrincipalsOwn) skips on the Windows box (no libsodium); CI runs it.

Not in this PR

  • data: entries still read over the launcher's allowlist, into the one store all documents share. Splitting them goes with SH12/SH13's fetching.
  • Keeping a sandboxed program off the other global # channels is SH12's.
  • Granting origins (the requires: net.origin ask and its sheet) is SH7's; it fills ScopePrincipal::net_origins.

…rincipal

A program's verbs are bound to the network of the principal its scope runs as
(docs/roadmap/ARIADNE_SHELL.md 4.12), so a document mounted beside nicotina cannot
post as the reader or reach the origins nicotina may.

- principal.h: a table per app of scope to principal (local, file:<dir>,
  remote:<origin>), the innermost recorded scope deciding and a local one inside a
  sandboxed one unable to raise it; hosts may check a principal as it is recorded.
- CredentialStore: one store and file, viewed per principal (for_principal); each
  view has its own entries, bindings and renewers. File lines are
  "<principal> <name> <origin> <token>"; three-word lines load as local.
- enable_net: each program's http verbs, fetch, http-upload, ws-*, net-*,
  open-url and oidc-* use net_host_access(app, scope): the launcher's for local,
  its own origin and granted origins for remote:, granted origins only for file:.
  A local application may have its own policy, credential store and e2ee store.
- WebSocket handles and OIDC sign-ins are their owner's; a sandboxed principal's
  sign-ins are not posted to the global oidc# channel.
- e2ee: a sandboxed principal gets its own in-memory key store.
- Pictures, video and Save with auth: are fetched as the widget's principal.
- Tests: ariadne_net_principal_test (credential isolation, allowlists, the file,
  nicotina's own policy and store against a local stand-in, WebSockets, sign-ins,
  e2ee, pictures) and the store's own in net_policy_test.
@transfix
transfix marked this pull request as ready for review November 27, 2026 05:12
The new scope member sat between auth and w in ImageRequest, so the
positional initializers in ariadne_media_test.cpp (uri, auth, w, h, fit,
shape) no longer compiled, and every package job failed on it. Each
struct now ends with scope, so an initializer written before SH11 still
lines up and leaves scope empty (the launcher's).
- open_mount records the mount's principal (SH1's mount_principal, with the
  entry's net_policy, credential_store and e2ee_store) under its scope before any
  of its programs is built; a check that fails refuses the mount. close_mount and
  the Runtime's teardown clear it.
- shell.ari: a catalog entry's net_policy, credential_store and e2ee_store
  (relative to the catalog) are kept with its row; such an entry opens under its
  slug with them written into shell.apps.<slug> first.
- Tests: a catalog mount as local and another file as file:<dir> (credentials and
  allowlist), a local application's own network from its entry and the refusals,
  and shell.ari's catalog entry with its own network.
- ARIADNE.md 6.7 lists the entry's keys; ARIADNE_SHELL.md's SH11 note says where
  the principal is recorded.
…bare name

- close_mount cleared the mount's principal right after quit_app, before
  the children that share its scope were killed, and the Runtime's teardown
  before the group's own teardown reaped what was left. A program built in
  between would have run as the scope's parent, local in a catalog shell.
  Both now clear it once the mount's processes are gone.
- mount_principal gave "file:" (no directory) for a mount whose name has no
  directory and whose loader gives no canonical path, and SH11's store
  refuses an empty file: principal, so open_mount refused every such mount
  (AriadneDeepNesting.AMountsSlotsEntriesDraw, from #1586). Such a name is in
  the current directory: file:.
@transfix
transfix enabled auto-merge (squash) November 27, 2026 20:12
AriadneComponents.ShellGivesACatalogEntryItsOwnNetwork compared the
credential store's path with temp_directory_path() / ... after
lexically_normal. On the windows-2022 runner the temp directory comes
back in its 8.3 spelling (C:/Users/RUNNER~1/...), while the store's
path is resolved to long names, so the same file compared unequal.
Both sides are now weakly_canonical. Reproduced locally with TMP set to
a short-name folder: the old assertion fails, the new one passes.
transfix added a commit that referenced this pull request Nov 27, 2026
…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).
Conflicts resolved keeping both sides:
- open_mount: #1594's mount_principal(..., slot.catalog), then SH11's block
  recording the principal (a flag change reopens the entry through
  close_mount and open_mount, so the new principal is recorded again).
- shell.ari shell-open: sets the catalog flag on what it opens, as #1594
  does; an entry with a network of its own opens under its slug with its
  flag and network written first, so it opens as local.
- ARIADNE.md 6.8: #1594's paragraph, plus SH11's sentence on what a
  principal reaches. ARIADNE_SHELL.md's SH11 note says so.
@transfix
transfix merged commit c303b8f into master Nov 28, 2026
30 checks passed
@transfix
transfix deleted the tfx/shell-sh11-net-principals-8f9594 branch November 28, 2026 02:44
transfix added a commit that referenced this pull request Nov 28, 2026
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?).
transfix added a commit that referenced this pull request Nov 28, 2026
docs/ARIADNE.md: the mounts entry keys keep both SH3's background and SH11's net_policy, credential_store and e2ee_store.
transfix added a commit that referenced this pull request Nov 28, 2026
…ications, argv: (#1598)

* Ariadne shell SH7: asks and grants, input and signals to granted applications, 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).

* SH7: origins read as the network policy reads them; a remote principal'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).

* SH7: the terminal backends report focus, hover and the keyboard as ImGui 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).

* mount_scene.h: clang-format the include comment the SH3 merge realigned
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