magic.signals
magic.signals is a “Super Signals” implementation for .Net 8 built on top of magic.node, allowing you to invoke functions from one assembly in another assembly without having any direct references between your projects.
Execution scoped context
magic.signals also provides the low level runtime pieces required for execution scoped cancellation.
An execution can carry ambient state through the signaler stack, allowing C# slots to retrieve the
current execution context from ISignaler without changing every method signature in the system.
The current execution context can be retrieved in C# using the helper extensions in this project.
var execution = signaler.GetExecutionContext();
var token = signaler.GetCancellationToken();
signaler.ThrowIfCancelled();
An execution context contains the execution id, cancellation token, reference counting for forked work, and optional deadline tracking for execution timeouts. This allows one request to cancel a different in-flight request by id, while still allowing child threads to share the same execution state safely.
Hyperlambda does not receive the raw execution object. Instead, higher layers may expose selected
values such as the execution id through ordinary context values such as dynamic.execution-id,
allowing code to use existing helpers such as [get-context] without exposing internal runtime
objects.
Slots a whitelist can never name
A [whitelist] restricts the slots a piece of Hyperlambda can invoke, which is how a sandboxed caller is given
a small vocabulary. A slot that would hand that caller the host itself, such as running a command, loading code,
minting a ticket or reading secrets, declares so on its [Slot] attribute
[Slot(Name = "system.execute", Whitelistable = false)]
Whitelistable defaults to true. A [whitelist] whose [vocabulary] names a slot declaring false is
refused when it is created, with [system.execute] can never be used inside a [whitelist]. It is declared per slot
name, so a class declaring several slots can mark only some of them. The declaration is read once at startup by the
ISignalsProvider, never while slots are invoked.
Notice, this only limits what a [whitelist] can grant. A trusted file invoked with [execute-file] runs without the whitelist, so it still calls whatever slots it needs.
Magic Signals a DSL
A lot of the idea behind Magic Signals is that combined with magic.node,
and especially its ability to parse Hyperlambda, it becomes a very good foundation for a DSL, or a Domain Specific
programming Language implementation, allowing you to easily create your own programming languages, and keywords,
based upon Hyperlambda syntax trees. Hyperlambda in this context being the textual representation of your Node
hierarchy.
Topics
- Active Events or Super Signals internals - Zero cross project references is made possible by always having a YALOA, allowing us to invoke methods in classes through a “magic string”, which references a type in a dictionary, where the string is
- Passing arguments to your slots - The Node class provides a graph object for you, allowing you to automagically pass in any arguments you wish.