Expand description
Standard library builtins for the Harn VM.
Every builtin is declared with the #[harn_builtin] proc-macro
(crate::stdlib::macros::harn_builtin). Each annotation emits a sibling
static <FN>_DEF: VmBuiltinDef carrying the signature, aliases, handler,
and metadata, and registers it into the workspace-global
macros::ALL_BUILTIN_DEFS distributed slice at link time. The CLI / LSP /
lint / serve / dap binaries call force_link to defeat rlib dead-code
stripping (linkme issue #36) so every static lands in the slice. Modules
still expose a register_<module>_builtins(vm) helper for ordered eager
registration (e.g. so clock::timestamp can override process::timestamp).
register_vm_stdlib calls those helpers in order and then installs the
aggregated signatures into the parser registry.
See CONTRIBUTING.md (“Adding a stdlib builtin”) for the full template.
Modules§
- agent_
state - asset_
paths - Re-export of
harn_modules::asset_pathsplus a VM-side convenience that anchors the project-root walk at the currently-executing source file (viaVM_SOURCE_DIR) and falls back to the existing source-relative resolver when the path is not an@-prefixed asset reference. - host
- http_
response - HTTP response codec primitives for
.harnHTTP handlers. - long_
running - macros
- Support module referenced by
#[harn_builtin]-emitted code. - process
- secret_
scan - template
- Prompt-template engine for
.harn.promptassets and therender/render_promptbuiltins. - token_
redaction std/oauth/redaction(OA-06) — OAuth token redaction stdlib.- tracing
- workflow_
messages
Functions§
- all_
builtin_ defs - Aggregate of every
#[harn_builtin]-emittedVmBuiltinDefin the stdlib. - all_
builtin_ signatures - Driver-facing helper: flatten the macro-emitted
BuiltinDefs into a&'static [&'static BuiltinSignature]slice suitable forharn_builtin_registry::install_builtin_signatures. - force_
link - Force-link entry point: a
pub fnthat touchesALL_BUILTIN_DEFSso the linker keeps every#[harn_builtin]-emitted static. Drivers (harn-cli,harn-lsp, etc.) call this once at startup. Doing nothing at runtime is fine — the side effect is purely a link-time signal. - register_
agent_ stdlib - Register agent builtins (requires network access and async runtime).
- register_
all_ macro_ builtins - Register every
#[harn_builtin]-emitted def on the given VM. Drivers that build the full stdlib viaregister_vm_stdlibget this for free — each module’sregister_*_builtinswalks itsMODULE_BUILTINSslice. This helper is exposed for embedders / tests that want a one-call entry. - register_
core_ stdlib - Register core builtins: pure/deterministic, no I/O.
- register_
io_ stdlib - Register I/O builtins (requires OS access).
- register_
vm_ stdlib - Register all standard builtins on a VM (core + io + agent). Also installs the macro-emitted signature slice into the parser registry (idempotent under repeat calls with the same slice pointer).
- reset_
stdlib_ state - Reset thread-local stdlib state. Call between test runs.
- stdlib_
builtin_ metadata - Return discoverable metadata for registered stdlib builtins.
- stdlib_
builtin_ names - Return the canonical list of all stdlib builtin names. Used by harn-lint and harn-lsp to avoid hardcoded duplicate lists.