Parses a string into an Elixir term WITHOUT evaluating it.
Designed for agent bridges and other untrusted callers that need to send
structured actions (e.g. {:role_changed, 2}) to a Runtime. Code.eval_string
executes arbitrary code; Code.string_to_quoted returns an AST that we
walk to confirm every node is a pure literal.
Grammar
Accepted:
- atoms (incl.
true,false,nil) - binaries (double-quoted strings)
- integers
- tuples of any arity
- lists
Rejected:
- floats
- maps
- variables and function calls
- operators
- anonymous functions, sigils, module aliases
Atom safety
Uses existing_atoms_only: true so novel atoms in the source string are
rejected by the parser. This prevents atom-table exhaustion and naturally
restricts callers to atoms defined in already-loaded modules.
Summary
Functions
Parses str into a safe Elixir term.