veko-lang.org
Download Free EPUB 3.0

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.

COMPILE-TIME POLICY & SUPPLY CHAIN veko.vk + types.vk + pkg/vkp.vk RUNTIME SANDBOXES & SINK FIREWALLS oro_vm.vk + vvm + native PAL Static audit .secret blocked Verified deps Cap mask Sink checks Manifest Policyveko.vk allow-caps.fs .clocks .env .net .exec .ui FFI IsolationDefault-Deny .ffi Gate--allow-ffi / VEKO_ALLOW_FFI=1 Supply ChainSigned VKP1 BundlesMerkle SHA-256 + Ed25519/ML-DSA Taint FirewallCompile + Runtime .secretZero Leakage Across Sinks Runtime IsolationVM & Wasm HostSandbox--allow-* + fuel + SSRF block
Component & ModuleArchitectural Role
veko.vk allow-caps
types.vk + main.vk
Declares the exact OS capabilities permitted inside the workspace module graph.
Default-Deny .ffi Gate
lib/ffi.vk + types.vk
Keeps foreign C-ABI shared libraries disabled by default and banned in Wasm.
Signed VKP1 Bundles
lib/pkg/vkp.vk
Verifies cryptographic package signatures against pinned trust-keys before compilation.
Compile + Runtime .secret
types.vk + runtime.vk
Blocks secret-tagged values from leaving process memory in cleartext.
VM & Wasm HostSandbox
oro_vm.vk + runtime_pal*.vk
Enforces defense-in-depth host policies at runtime for scripts and plugins.
ADRDecisionArchitectural Rationale
ADR-01Unshifted Kebab-Case + Load-Bearing WhitespaceKeeps 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 & ListsEliminates syntactic ambiguity between local assignment blocks [ x = 1 ] and map literals { x = 1 }, while keeping nested configuration and UI layouts visually distinct.
ADR-03Slash Refinements, Universal /or, Templates & interfaceUser-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-041024-Based Size Literals & Nanosecond Duration LiteralsSystems 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 DisciplineEliminates 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-0616-Byte Value Cell + 14-Byte Inline SSOPacks 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-07One 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-08Gradual & 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

ADRDecisionArchitectural Rationale
ADR-09Three 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-10Fixed-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-11Strict Zero-JIT (W^X) Policy & CPUID Hardware IntrinsicsNever 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-12OS-Native Readiness Reactor Over Colored async/awaitImplements 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-13Zero-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-14Default-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-15Single-Binary Portable SDK & veko-lang.org / Decentralized HTTPS .vkp RegistryEmbeds 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-16Zero-FFI SQLite 3 (db/sqlite), .secret-Redacting DAP Debugger, Coverage & Pure-Veko EPUB 3.0Reads 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

  1. Zero Tracing GC: Every heap allocation is reclaimed deterministically at lexical scope exit (_oro_live_slabs == 0 on Wasm; RT-LIVE-SLABS == 0 on native worker teardown) via 12-bucket power-of-two size-class free-lists (32 B..65536 B) and direct OS page release (VirtualFree / munmap) above 64 KiB.
  2. Shared-Nothing spawn Isolation: spawn [ ... ] blocks reject outer mut captures, mut loans, closures, and .secret values at both compile time and runtime, executing each worker with private ThreadState and communicating strictly by ownership transfer over bounded chan/* queues (lib/conc/scope.vk structured task groups).
  3. End-to-End .secret Hygiene: Values marked secret bypass inline 14-byte SSO, print as <secret>, zeroize full slab capacity on release, and are blocked statically and dynamically from crossing os/write-file, os/stderr, json/encode, net/*, http/*, chan/send, ui/present, ui/clipboard-set, and ffi/*.

3.2 Self-Hosting & Cross-Target Convergence

  • Fixed-Point Determinism: Compiling src/main.vk (44 compiler modules + 90 stdlib modules) produces bit-identical S1 == S2 native executables (SHA-256(S1) == SHA-256(S2)) and deterministic .vko / .wasm artifacts.
  • Monotonic Timing Stability: High-resolution monotonic clocks (clock_gettime(CLOCK_MONOTONIC) on Linux/macOS, quotient-remainder QueryPerformanceCounter scaling on Windows) maintain nanosecond resolution across 292+ years of continuous server uptime without 64-bit integer overflow.