Skip to content

ariadne: a document owns its command line (argv + args:), shared runtime flags - #721

Merged
transfix merged 1 commit into
masterfrom
feat/ariadne-doc-args
Oct 20, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ariadne-doc-args

Conversation

@transfix

Copy link
Copy Markdown
Owner

A runtime now takes only its general flags, before the document path. Everything after the path belongs to the .ari document, which reads it from the state tree. This is the first of two PRs for Joe's runtime split: ari (core, terminal), arigl (GL: a real window, or the terminal with a 3D scene) and arisrv (headless server). The second PR, stacked on this one, adds arigl.

Why

Joe: "I don't want a bunch of registered command line arguments for the cli, we should have some that apply generally to every ari program but in general, flags and cli args should get passed to the .ari document being run and handled there. so .ari files need a safe way to access the argv of the process. Perhaps the outermost ari program has access to them somewhere on the state tree and sub programs can be given access using our access controls as needed"

He chose raw argv plus an optional declared args: block.

What a document gets

ari run --fps 30 conf.ari --room standup --camera
args:
  room:   {type: string, default: lobby, help: Room to join}
  camera: {type: bool, help: Use the real camera}
  peers:  {type: int, default: 8}
init: |
  (state-set "status" (str-concat "joining " (state-get "args.room")))

All of these are read-only and published before init: runs (inc/cvc/ariadne/doc_args.h):

  • argv is the strings as given. Its data is a DSL list, read with (state-data-get "argv").
  • args.<name> holds each declared argument that was given or has a default. Its value is the canonical text, its data the typed value.
  • args is the whole set as one DSL dict.

Parsing:

  • Accepts --name value, --name=value, --flag / --no-flag, positionals in order, and --.
  • An unknown option, a bad value, a missing required argument or an extra positional fails the load with generated usage, and ari exits 2.
  • doc.ari --help prints the document's usage.
  • A malformed args: block fails the load.
  • With no block, nothing is checked; the document just has argv.

Access control uses the existing mount model. Programs are chrooted to their subtree, so a load:-mounted module sees neither argv nor args unless its parent grants a read-only hole: link: {args: {to: args, mode: ro}} passes the dict, or link: {room: {to: args.room, mode: ro}} passes one argument. A module's own args: block is ignored with a warning.

Shared by every runtime

  • inc/cvc/ariadne/host_cli.h is one parser for the general flags: --prefix, --component-path, --backend, --fps, --no-mouse, and the snapshot flags --width/--height/--frames/--ansi/--png. A runtime can add its own bool flags; arigl will add --terminal. A general flag written after the document goes to the document, and the runtime points that out.
  • inc/cvc/ariadne/host_signals.h holds the sigaction traps ari used, as opt-in host helpers. libcvc never installs them by itself.
  • ari uses both. Its flags must now come before the document. The CI wasm snapshot step, the docs and the example comments are updated.

Fixes found on the way (AppRuntime)

  • Only the first register_verb was ever bound. The program-lane provider copied the verb list at the first registration, so every later verb was an unbound symbol. ari registered only quit, which is why nobody hit this. The table is now shared with the provider, and it empties when the runtime is destroyed, so a stale provider can't call into a dead host. A regression test fails against the old code and passes now.
  • A failing init: was silent; it is now a load warning.
  • drain() threw away the read-lane diagnostics that take_warnings() claims to return; they are kept now.

Verification

  • New ariadne_host_test, 15 tests:
    • the shared CLI;
    • parsing, errors and usage;
    • loader spec validation;
    • publication before init:;
    • read-only enforcement;
    • --help / errors / check;
    • raw argv without a block;
    • the mount grant against a refusal;
    • the verb fix and init warnings.
  • All 392 Ariadne tests pass locally.
  • ari by hand:
    • terminal_tour.ari --agents 128 --name ada reaches init:;
    • --help prints the document's usage; --agents many exits 2 with usage;
    • ari snapshot doc --width 100 gets the misplaced-flag note.
  • In tmux: SIGTERM goes to on_signal (asks, then exits 0), and an unhandled SIGTERM exits 143.
  • clang-format is clean on the changed lines.

…ime flags

A runtime now takes only its general flags, before the document path; everything after the path
belongs to the document, as with `python script.py args`.

- doc_args.h: the runtime publishes the read-only <root>.argv (a DSL list) before init: runs.
  An optional top-level args: block declares typed options and positionals, parsed into the
  read-only args.<name> plus an args dict. Unknown options, bad values or missing required
  arguments fail the load with generated usage; --help prints it. A load:-mounted module sees
  neither unless its parent grants a read-only link: hole.
- host_cli.h: the general flags every runtime (ari, arigl, arisrv) shares, in one parser.
- host_signals.h: the sigaction traps ari used, as opt-in host helpers.
- ari uses all three. Its flags must now precede the document (the CI wasm snapshot step and
  the docs are updated), and it notes a runtime flag written after the document.
- AppRuntime: every register_verb is bound, not only the first. The provider used to copy the
  verb list on the first registration; the table is now shared, and it empties when the
  runtime is destroyed. A failing init: is a warning, not silent, and take_warnings() keeps the
  read-lane diagnostics drain() used to drop.
- terminal_tour.ari takes --agents and --name as its example.
@transfix
transfix merged commit 2a08f91 into master Oct 20, 2026
24 checks passed
@transfix
transfix deleted the feat/ariadne-doc-args branch October 29, 2026 20:52
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