runtime

6 modules

  • runtime/deps.ts

    Shared dependency interfaces for runtime operations.

    Small composable interfaces that functions accept for only the capabilities they need. create_node_runtime (Node and Bun) and create_mock_runtime satisfy all these interfaces via RuntimeDeps.

    Running a program is not a RuntimeDeps member: a helper that spawns takes each program it runs as its own Program handle, or a ProgramFactory that makes one, from the composition root, so no helper resolves a command name against the ambient PATH and environment.

  • runtime/fs.ts

    File system utilities.

  • runtime/mock.ts

    Mock RuntimeDeps for testing.

    Provides a fully controllable runtime implementation for unit tests. Consumer projects can extend MockRuntime with project-specific helpers (e.g. setup_mock_zap_config) that stay local.

  • runtime/node.ts

    Node.js implementation of RuntimeDeps.

    Backed by Node.js APIs. Used for running servers on Node and Bun (which implements the node:* surface this module touches) and for tests (vitest runs in Node).

  • runtime/process_id.ts

    Process ID validation shared by the probe_process implementations and their callers.

  • runtime/secure_file.ts

    Hardened secret-file read and burn — the TS twins of the Rust spine's fuz_sys::secure_file::load_secure_file and burn_secure_file.

    The file this guards is typically the highest-value credential on the host (the bootstrap token mints the keeper account), so the read fails loud rather than degrading: a symlink, a non-regular file (FIFO, device node, directory), a group/other-accessible mode, or an oversized file is refused, never returned — and, for a reader that asks (SecureReadOptions), a file with a link count other than 1. The deploy recipe places the token at 0600, so the check ratifies the shape zap produces; a hand-placed 0644 file fails at boot instead of being read.

    The real implementations live here (load_secure_file_node and burn_secure_file_node, wired as create_node_runtime().read_secure_file and .burn_secure_file), and the mock honors the mode/size and link-count checks over its in-memory map (it has no file types). Both refuse through the shared assert_secure_mode / assert_secure_size / assert_secure_link_count helpers, so the checks — and their operator-facing messages — can't drift between them.