Documentation channel: current development main at compiler checkpoint 1d7e15e. The latest tagged release is v0.0.3; pages identify APIs that are not yet released.

Architecture

Version: This page describes current-main / unreleased at compiler checkpoint 1d7e15e. Stable v0.0.3 established focused string/thread/atomic runtime slicing and the HTTP runtime; bytes, crypto/encoding, streaming HTTP, WebSockets, cancellation, process-pipe work, PTYs, and P10 composition described here are post-v0.0.3 additions.

Compiler and generated runtime

Strut parses and checks source, lowers it to a typed intermediate representation, determines the required runtime capabilities, and emits portable C++20 plus a native link plan. Generated applications are native executables; there is no VM or tracing garbage collector.

A canonical API registry supplies semantic checking, checked-error contracts, runtime-component selection, native dependency metadata, CLI inspection, and language-server data. A builtin's spelling alone does not select a component: the typed use of its callable or surface type does.

Dependency-driven slicing

The backend starts from the types and operations present in the complete lowered program, including nested lambdas and switch cases. It resolves a directed component graph, emits each transitive dependency once, and links only the resulting native libraries. This keeps unrelated facilities out of the executable rather than relying on the linker to discard one monolithic runtime.

Program capabilityRuntime sliceNative boundary
Plain stringscore + stringsnone
bytesstrings + collections + bytesnone
Base64/Base64urlbytes + encodingnone
Crypto primitivesbytes + OpenSSL crypto + cryptolibcrypto
Outbound HTTPnetworking + JSON + HTTP clientlibcurl
Plain HTTP servernetworking + collections + IO + threading + mutex + cancellation + serverOS sockets
WebSocket server routeHTTP server + bytes + WebSocketOS sockets; no added library for plaintext
HTTPS serverHTTP server + server TLSlibssl + libcrypto
PTYprocess + bytes + cancellation + PTYoperating-system process and PTY APIs

The graph preserves static link order for mixed programs as curl, SSL, then crypto. A hello-world program does not include networking, curl, OpenSSL, SQLite, process, or PTY code.

HTTP boundaries

libcurl is the sole outbound HTTP implementation. Synchronous and asynchronous buffered calls, and the current-main streaming client, share the same client policy and native ownership. The built-in inbound HTTP/1 server does not use libcurl: it is Strut-owned protocol code over the cross-platform TCP substrate.

Server WebSockets are an upgrade and frame/message layer on that same HTTP worker-owned transport. A plaintext WebSocket route adds bytes and the WebSocket runtime, not libcurl or OpenSSL. Its RFC-required SHA-1 handshake implementation is internal to that component and does not expose SHA-1 publicly. A WebSocket route served through listen_tls composes the existing server TLS component. Plain TCP permits one receive and one serialized send concurrently; upgraded TLS transfers the SSL* to one nonblocking owner thread that services at most one bounded request per direction without concurrent OpenSSL entry.

OpenSSL boundaries

OpenSSL has two separately selected roles. Public cryptographic primitives use libcrypto without TLS. HTTPS server transport uses libssl and libcrypto. Base64 encoding is independent of both. Outbound HTTPS remains behind libcurl, including libcurl's selected TLS backend, rather than calling the server TLS implementation.

Process and PTY boundaries

Process launch is an operating-system boundary. Normal exec, process, and pty_spawn construct argv rather than evaluating arguments as shell source; exec_shell is the explicit shell path.

The PTY component composes existing process launch/lifecycle helpers, owned bytes, and the shared cancellation model. POSIX uses native PTY/session/ioctl/signal APIs. Windows dynamically resolves native ConPTY, uses overlapped host pipes, attaches the opaque pseudo-console through STARTUPINFOEXW, and assigns the suspended child to a kill-on-close Job before resume. A weak process monitor owns only a duplicated process handle; pending reads separately observe process completion and close ConPTY while draining final output. The slice does not interpret escape sequences, emulate a terminal, depend on a third-party terminal library, or pull in HTTP, WebSockets, curl, OpenSSL, or SQLite.

WebSocket and PTY composition boundary

P10 deliberately remains above the runtime graph: there is no WebSocket-to-PTY component, no dependency edge in either direction, and no built-in terminal protocol. Generated application code owns an input/control pump and a joined output pump using the two ordinary public handles. The HTTP request cancellation token links their lifetime at the application layer, while synchronous writes preserve transport and terminal backpressure without an unbounded intermediary.

Ownership boundaries

Safe T* ownership is reference-counted; T& is a compiler-checked non-owning borrow. Native pointers and C ABI calls require unsafe. Runtime handles such as processes, PTYs, sockets, and cancellation tokens own or share explicit native state, and their checked errors translate failures at that boundary.

Packages and external integrations

Language/runtime facilities are distinct from packages. SQLite follows the component model as an external/system native library through the official package integration. Archive formats, authentication frameworks, ORMs, HTTP/2, WebSocket compression and an outbound WebSocket client are not hidden runtime dependencies; they are package-level, deferred, or unsupported work.