Repository navigation
Ariadne: functions: shared with a document's programs and granted to its modules - #900
Merged
Merged
Conversation
- (quit [code]): AppRuntime::register_quit() binds `on: quit` and the verb; the first close request's code is exit_code(). ari run/snapshot/check and arigl (window and --terminal) exit with it; snapshot stops on the frame the document quit. - (assert cond [message [data]]): a builtin raising AssertionError (a new class under Exception), "assertion failed[: message]"; its traceback ends at the form. - tests: block (name -> program) captured by the loader; Runtime::run_program runs a program on the action lane and reports how it ended to a callback. - ari test [--tap] [--timeout S] [--frames N] doc.ari...: each document headless until it quits, its tests have run, N frames, or the timeout. Fails on a non-zero quit, an uncaught error, a failed or warning load, a failed test, or a timeout. One line per document with what failed and in which program; TAP with --tap; exit 1 on failure. Network flags and settling as snapshot's. - Action failure warnings name their program; resident ones their lane. - Docs: ARIADNE.md §13, the exceptions table, the developer guide.
…s modules (#894) - functions: (top level): a program of (defun ...) forms that every program in the document's scope can call (init:, on:, residents, key bindings, tests:); anything else is skipped with a warning. import: merges a library's functions. - load: functions: [names] | name | "*": grants the parent's functions to the module, each with the functions it calls; a module gets none otherwise, and its own functions: stay inside it. Code, not authority: a granted function runs chrooted to the module. - Mechanism: Widget::functions (FunctionScope) on the root and every mount wrapper; the runtime keeps a function-scope stack beside the mount scopes and runs the scope's prelude ahead of each program (actions, residents, run_program, init:, mount init:). - The free-head preflight is scope-aware and scans function bodies and mount init:. - Docs: ARIADNE.md §6.6.
transfix
added a commit
to cy-pca/cypkg
that referenced
this pull request
Oct 30, 2026
lib.ari holds cypkg's logic as functions: (transfix/libcvc#900), pure: reply parsing, the search query and status, failure messages, cutting, size and date text, build rows and page bounds. main.ari imports it, and its on_tick only moves values between those functions and state. tests/lib/lib_test.ari tests each function with assert (15 tests, no network). tests/run.sh runs it as layer 2b; CI merges #900 too and checks the ari has functions:.
…illing stepped_solve::impl did f.assign(nv, f[0]): the value is a reference into f, and libc++'s assign frees the old buffer before filling the new one, so on macOS every entry was read from freed memory (Fem.SteppedPoissonMatchesTheOneShotSolve, rel diff 6.7e268 in the macOS recipe lanes). libstdc++ and MSVC copy the value first, so Linux and Windows passed.
Takes #903's fix for the stepped Poisson solve in place of the same fix made here.
This was referenced Oct 30, 2026
transfix
enabled auto-merge (squash)
October 31, 2026 02:38
transfix
pushed a commit
that referenced
this pull request
Oct 31, 2026
This was referenced Oct 31, 2026
Ariadne: video:/audio: in the browser pages through <video>/<audio> (media M6, stacked on #935)
#936
Merged
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.
The fourth ask of #894: functions a document defines once and hands to the documents it
load:s. Stacked on #896 (ari testandtests:); its base isfeat/ari-quit-assert-test, and it retargets to master when #896 merges.Design
The problem.
defundefines a function for one program. The stdlib scope is frozen. Aload:ed module is chrooted to its own state subtree and reaches its parent only throughlink:holes. So shared logic had to be copied into everyon:handler, and could not be tested on its own.Declaring: a top-level
functions:block. It is a scalar state_exec program made only of(defun name (params) body...)forms:;comments are respected) and parses each one.init:,on:actions, residents (on_tick:and the rest), key bindings,tests:, and the functions themselves. The read lane (bind:,visible_when:) keeps its reduced environment.import:merges a library's functions, as it mergesunits:.ari testdocument that imports it is a unit test.Granting:
functions:on aload:entry. Next tolink:(state) andchannels:(messaging), this is the code grant:requires:. Those are callable in the module too.functions:and imports are visible only inside the module. Replacing a granted name warns.Code, not authority. A granted function runs in the module's program, chrooted to the module's sub-prefix.
(state-set "out" ...)from a granted function writesincludes.<as>.out, and the function reaches the parent only through the module'slink:holes. Granting a function never grants state.Mechanism: a per-scope prelude.
Widget::functionsis aFunctionScope(the defs plus their sources joined into a prelude). It is set on the document root and on every mount wrapper, and is empty when the mount grants nothing.submit_actionruns prelude + program.run_programuse the document's prelude.Runtime::set_rootrecords it at once, so a resident submitted before the swap still gets it.init:and a mount'sinit:get their own scope's prelude.Checked at load. The free-head preflight (§5.7) is scope-aware.
ari testfail.functions:, and a mount'sinit:is now scanned too.Not in this PR (follow-ups from cypkg's findings):
on_tick:(today only itsinit:runs);link:holes (a hole to an interior node exposing its descendants);Tests
ariadne_loader_test(AriadneFunctions.*):"*", an unknown name, the transitive callees, an empty scope for an ungranted mount, a module redefining a granted name;ariadne_host_test(AriadneFunctions.*):NameErrorat run time.ari_test_command_test(AriTest.FunctionsImportedAndGranted):ari teston a document that imports a semver library, tests it directly, and mounts a module grantedsemver-major(which bringssemver-part). Without the grant it fails at load.Locally all 38 ariadne_* and state_exec_* suites pass, including
ariadne_loader_test(207),ariadne_host_test(32),ariadne_runtime_test(200),ariadne_ftxui_test(66) andari_test_command_test(7).Docs: docs/ARIADNE.md §6.6 (new), §5.1, §6.3, §7.4 and §13; docs/STATE_EXEC_DEVELOPER_GUIDE.md §11.