Repository navigation
ariadne: a document owns its command line (argv + args:), shared runtime flags - #721
Merged
Merged
Conversation
…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.
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 runtime now takes only its general flags, before the document path. Everything after the path belongs to the
.aridocument, 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) andarisrv(headless server). The second PR, stacked on this one, addsarigl.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
All of these are read-only and published before
init:runs (inc/cvc/ariadne/doc_args.h):argvis 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.argsis the whole set as one DSL dict.Parsing:
--name value,--name=value,--flag/--no-flag, positionals in order, and--.ariexits 2.doc.ari --helpprints the document's usage.args:block fails the load.argv.Access control uses the existing mount model. Programs are chrooted to their subtree, so a
load:-mounted module sees neitherargvnorargsunless its parent grants a read-only hole:link: {args: {to: args, mode: ro}}passes the dict, orlink: {room: {to: args.room, mode: ro}}passes one argument. A module's ownargs:block is ignored with a warning.Shared by every runtime
inc/cvc/ariadne/host_cli.his 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.hholds thesigactiontrapsariused, as opt-in host helpers. libcvc never installs them by itself.ariuses 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)
register_verbwas ever bound. The program-lane provider copied the verb list at the first registration, so every later verb was an unbound symbol.ariregistered onlyquit, 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.init:was silent; it is now a load warning.drain()threw away the read-lane diagnostics thattake_warnings()claims to return; they are kept now.Verification
ariadne_host_test, 15 tests:init:;--help/ errors /check;ariby hand:terminal_tour.ari --agents 128 --name adareachesinit:;--helpprints the document's usage;--agents manyexits 2 with usage;ari snapshot doc --width 100gets the misplaced-flag note.on_signal(asks, then exits 0), and an unhandled SIGTERM exits 143.