Part II · Files, Codecs, Web & Zero-FFI SQLite
Chapter 4
Files, Streams, Archives, Compression & Regex
Polymorphic io/Stream testing, ReDoS-proof Thompson NFA regex, Zstandard compression, and ZIP/TAR archives
Pure-Veko Standard Library & Post-Quantum Cryptography Architecture
1,043 exported structs and functions across 79 modules — from core data structures to NIST FIPS 203/204/205 PQC.
| Component & Module | Architectural Role |
|---|---|
Core, Text, Math & CLIlib/fmt.vk + lib/cli.vk + lib/coll.vk | Provides formatting, subcommand CLI parsing, sets/rings/heaps/LRU, regex NFA, and UTF-8. |
Codecs, Wire & Archiveslib/codec/* + lib/archive/* | Encodes and decodes binary and text wire formats plus compressed TAR/ZIP archives. |
Streams, Reactor, DB & UIlib/reactor.vk + lib/web.vk + lib/durable.vk | Builds high-level networking, persistence, workflows, and UIs over the capability PAL. |
AEAD, Hashes & Curveslib/crypto/aes.vk + lib/crypto/x25519.vk | Constant-time symmetric AEADs, cryptographic Sponge/Merkle hashes, KDFs, and elliptic curves. |
NIST FIPS 203 / 204 / 205lib/crypto/mlkem.vk + lib/crypto/mldsa.vk | Quantum-resistant lattice KEMs, lattice signatures, and stateless hash signatures. |
crypto/seal & Auth Tokenslib/crypto/seal.vk + lib/auth/jwt.vk | Combines sealed AEAD envelopes with EdDSA/ML-DSA65 JWTs, OAuth2 PKCE, and RFC 6238 TOTP. |
Recipe 4.1: Polymorphic io/Stream Pipelines (Memory, Files & TLS Sockets)
Write protocol parsers and serializers against io/Stream so unit tests feed io/mem-stream in memory with zero capabilities while production code passes TCP or TLS 1.3 streams:
use [io]
write-netstring = fn [mut s io/Stream, msg str] i64 [
raw = bytes/from-str msg
frame = bytes/from-str `{(len raw)}:{msg},`
io/write-all mut s frame
]
// Test purely in memory with zero .fs or .net capabilities
mut mem = io/mem-stream (bytes/with-cap 0)
_ = write-netstring mut mem 'homoiconic'
wire_text = bytes/to-str (io/read-all mut mem) // '10:homoiconic,'Recipe 4.2: Linear-Time ReDoS-Proof Regex Capture Groups (lib/text/re.vk)
Veko's text/re compiles patterns to a Thompson NFA with guaranteed O(n * m) execution time — immune to catastrophic backtracking on untrusted user input:
use [re = text/re]
sem_rx = re/compile '([a-z0-9_]+)@([0-9]+\\.[0-9]+\\.[0-9]+)'
m = re/match sem_rx 'http_router@1.2.0'
if m.matched [
pkg_name = m.groups[1] // 'http_router'
pkg_ver = m.groups[2] // '1.2.0'
println `Resolved package {pkg_name} version {pkg_ver}`
]Recipe 4.3: Zstandard Compression & Deterministic TAR/ZIP Archives
Compress payloads with RFC 8878 Zstandard (compress/zstd) and bundle multi-file release archives in memory with archive/zip or archive/tar:
use [zstd = compress/zstd, zip = archive/zip]
pack-diagnostic-bundle = fn [readme_txt str, log_json str] bytes [
compressed_log = zstd/compress (bytes/from-str log_json)
zip/pack [
zip/ZipEntry { path = 'README.txt', data = (bytes/from-str readme_txt), compress = true }
zip/ZipEntry { path = 'events.json.zst', data = compressed_log, compress = false }
]
]