Part IV · Compiler Architecture, Backend Internals, Safety Proofs & ADRs
Chapter 18
Requirements, Trade-Offs & Architectural Decision Records
Complete engineering rationale across ADRs and milestone benchmarks
This document defines the architectural requirements, trade-off analyses, and locked Architecture Decision Records (ADRs) governing Veko's language design, ORO memory model, three-backend compiler, standard library, and developer toolchain.
1. Core Language & Memory Decisions
CAPABILITY GOVERNANCE
Defense-in-Depth Capability Gates, .secret Firewall & Supply-Chain Trust
Compile-time allow-caps enforcement, cryptographic taint tracking, zero-trust Wasm sandboxes, and signed VKP1 packages.
| Component & Module | Architectural Role |
|---|---|
veko.vk allow-capstypes.vk + main.vk | Declares the exact OS capabilities permitted inside the workspace module graph. |
Default-Deny .ffi Gatelib/ffi.vk + types.vk | Keeps foreign C-ABI shared libraries disabled by default and banned in Wasm. |
Signed VKP1 Bundleslib/pkg/vkp.vk | Verifies cryptographic package signatures against pinned trust-keys before compilation. |
Compile + Runtime .secrettypes.vk + runtime.vk | Blocks secret-tagged values from leaving process memory in cleartext. |
VM & Wasm HostSandboxoro_vm.vk + runtime_pal*.vk | Enforces defense-in-depth host policies at runtime for scripts and plugins. |
| ADR | Decision | Architectural Rationale |
|---|---|---|
| ADR-01 | Unshifted Kebab-Case + Load-Bearing Whitespace | Keeps everyday identifiers free of Shift keys while preserving a - b subtraction, a / b division, net/http module paths, /port refinements, and buf[0..n] tight indexing via deterministic 1-character lookahead. |
| ADR-02 | { ... } for Structs & Maps; [ ... ] for Blocks & Lists | Eliminates syntactic ambiguity between local assignment blocks [ x = 1 ] and map literals { x = 1 }, while keeping nested configuration and UI layouts visually distinct. |
| ADR-03 | Slash Refinements, Universal /or, Templates & interface | User-declarable /refinements extend arity predictably without keyword-argument runtime maps; universal /or [e -> ...] handles errors inline without stack-unwinding exception tables in user code; backtick templates (`Hello {name}`) propagate .secret taint automatically; and structural interface contracts verify duck-typed records statically. |
| ADR-04 | 1024-Based Size Literals & Nanosecond Duration Literals | Systems buffers and slab classes align naturally with binary multiples (b, kb, mb, gb, kib, mib, gib), paired with first-class dur literals (ns, us, ms, s, m, h). |
| ADR-05 | "No nil" Value Discipline | Eliminates null-dereference bugs across the language: unit actions evaluate to .ok, wire/JSON null maps to .null, and missing keys or out-of-range parses return err values handled via /or. |
| ADR-06 | 16-Byte Value Cell + 14-Byte Inline SSO | Packs all scalars (i64, f64, bool, dur, size, .enum) and short UTF-8 strings up to 14 bytes inside a 16-byte cell (4 values per 64-byte cache line), while forcing .secret values onto dedicated heap slabs so full capacity is zero-wiped at scope exit. |
| ADR-07 | One Reference Only (ORO) + Copy-on-Write (ensure_unique) | Tracks ownership on the 16-byte Value cell (flag_owned) so read-only function calls copy 16 bytes with zero refcount traffic, mut loans mutate unique (rc == 1) buffers in place, and shared snapshots split cleanly on mutation—making reference cycles mechanically impossible without a tracing GC. |
| ADR-08 | Gradual & Strict Static Verification (types.vk) | Supports untyped scripting alongside full static verification (veko check --strict-types), checking [T] generics, sealed structs, interface contracts, disjoint mut s.field borrows, checked narrowing (as-u8, str/to-i64), and compile-time .secret sink blocks. |
2. Execution Backends, PAL & Security Decisions
| ADR | Decision | Architectural Rationale |
|---|---|---|
| ADR-09 | Three Purpose-Built Execution Backends (44 src/ Modules) | Shares one pure-.vk frontend (lexer.vk, parser.vk, desugar.vk, macro_eval.vk, types.vk) across three backends: oro_vm.vk (64-bit VKO bytecode VM, REPL, dynamic eval, deterministic profiler), codegen.vk (zero-trust WebAssembly 3.0 sandbox via vvm), and native_emit.vk / arm64_emit.vk (standalone win-x64 PE32+, linux-x64 ELF64, linux-arm64 ELF64, and macos-arm64 Mach-O executables with zero C/LLVM or crypto library dependencies). |
| ADR-10 | Fixed-Width 64-Bit VKO Bytecode (vko_emit.vk) | Encodes instructions as aligned 64-bit words (op:u8 | flags:u8 | a:u16 | bx:u32), supporting 65,535 local/struct slots, 32-bit symbol/jump indices, source-mapped stack traces (file:line), whole-program dead-function tree-shaking, and zero-W^X VM superinstruction fusion. |
| ADR-11 | Strict Zero-JIT (W^X) Policy & CPUID Hardware Intrinsics | Never allocates writable-and-executable (RWX) memory pages on any backend. Native speed comes from KindMask scalar/escape elision, unboxed i64/f64 register loops, callee-saved regalloc, and startup CPUID dispatch (AVX2, SSE2, AES-NI, PCLMULQDQ). |
| ADR-12 | OS-Native Readiness Reactor Over Colored async/await | Implements non-blocking I/O multiplexing (epoll on Linux, kqueue on macOS, IOCP + WSAPoll on Windows, WASI net-poll on Wasm) via lib/reactor.vk so single-owner ORO bytes buffers are never pinned across kernel async lifetimes. |
| ADR-13 | Zero-Bloat .ui Desktop PAL (Win32 Hi-DPI + Linux Wayland/X11 + macOS Cocoa + Wasm <canvas>) | Keeps CLI/server binaries free of GUI imports while enabling desktop apps under .ui (--gui): Win32 StretchDIBits + Per-Monitor V2 Hi-DPI + OS clipboard on Windows, zero-libc AF_UNIX Wayland (wl_shm + memfd_create + SCM_RIGHTS) cascading to X11 on Linux, conditional AppKit/CoreGraphics Retina NSWindow (LC_LOAD_DYLIB only when .ui is active) on macos-arm64, and shared-linear-memory <canvas> rendering in browser WebAssembly. |
| ADR-14 | Default-Deny Opt-In .ffi C-ABI Trampolines (lib/ffi.vk + VEKO_LIB + veko bindgen) | Isolates foreign .dll/.so/.dylib calls behind explicit allow-caps = [.ffi] or --allow-ffi (strictly forbidden on --wasm), resolving search paths from VEKO_LIB, using static AOT 6-argument C-ABI trampolines, and switching Linux ELF64 from static zero-libc to dynamic PT_INTERP only when .ffi is active. |
| ADR-15 | Single-Binary Portable SDK & veko-lang.org / Decentralized HTTPS .vkp Registry | Embeds all 93 compressed lib/*.vk modules inside veko (stdlib_vfs.vk) with optional VEKO_HOME SDK override and ~/.veko_modules (VEKO_MODULES) content-addressed cache; resolves bare 'name@ver' specs from https://veko-lang.org/pkg (VEKO_REGISTRY) alongside decentralized https://... URLs pinned in homoiconic veko.lock with SHA-256 Merkle roots and Ed25519 / ML-DSA-65 signatures. |
| ADR-16 | Zero-FFI SQLite 3 (db/sqlite), .secret-Redacting DAP Debugger, Coverage & Pure-Veko EPUB 3.0 | Reads and writes genuine "SQLite format 3\0" 4096-byte slotted B-tree files + homoiconic ORM without C libraries; provides veko debug / --dap (redacting .secret as <secret>), veko test --coverage + testing/fuzz delta-debugging shrinking, interactive HTML handbooks (veko docs), and validated Light-Mode EPUB 3.0 books (veko book) in 100% pure Veko. |
3. System Requirements Matrix
3.1 Memory & Concurrency Invariants
- Zero Tracing GC: Every heap allocation is reclaimed deterministically at lexical scope exit (
_oro_live_slabs == 0on Wasm;RT-LIVE-SLABS == 0on native worker teardown) via 12-bucket power-of-two size-class free-lists (32 B..65536 B) and direct OS page release (VirtualFree/munmap) above64 KiB. - Shared-Nothing
spawnIsolation:spawn [ ... ]blocks reject outermutcaptures,mutloans, closures, and.secretvalues at both compile time and runtime, executing each worker with privateThreadStateand communicating strictly by ownership transfer over boundedchan/*queues (lib/conc/scope.vkstructured task groups). - End-to-End
.secretHygiene: Values markedsecretbypass inline 14-byte SSO, print as<secret>, zeroize full slab capacity on release, and are blocked statically and dynamically from crossingos/write-file,os/stderr,json/encode,net/*,http/*,chan/send,ui/present,ui/clipboard-set, andffi/*.
3.2 Self-Hosting & Cross-Target Convergence
- Fixed-Point Determinism: Compiling
src/main.vk(44compiler modules +90stdlib modules) produces bit-identicalS1 == S2native executables (SHA-256(S1) == SHA-256(S2)) and deterministic.vko/.wasmartifacts. - Monotonic Timing Stability: High-resolution monotonic clocks (
clock_gettime(CLOCK_MONOTONIC)on Linux/macOS, quotient-remainderQueryPerformanceCounterscaling on Windows) maintain nanosecond resolution across 292+ years of continuous server uptime without 64-bit integer overflow.