veko-lang.org
Download Free EPUB 3.0

Part I · Mental Model & Rosetta Stone

Chapter 2

Workspaces, CLI Subcommands, Config & Secrets

Scaffolding zero-flag veko.vk workspaces, declarative subcommands, TOML config, and .secret hygiene

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.

Recipe 2.1: Zero-Flag Workspaces & Automatic Capability Tightening (veko init & veko mod sync)

Scaffold a workspace with a veko.vk manifest and let the compiler audit and lock down the exact minimal OS capability bitmask ([.fs .clocks .env .net]):

POWERSHELL
# Scaffold a web, CLI, GUI, or library workspace
veko init sync-agent --cli
cd sync-agent

# Run, type-check, test, and compile directly from veko.vk
veko .
veko check --strict-types src/main.vk
veko test
veko compile --native src/main.vk -o dist/sync-agent.exe

# Scan all transitive imports and tighten allow-caps in veko.vk to the exact minimum
veko mod sync

For quick one-off scripts outside a workspace, grant capabilities explicitly on the CLI:

POWERSHELL
veko -C fs,net tools/ping_health.vk
veko run -e 'println `SHA-256 ready: {1 << 8}`'

Recipe 2.2: Declarative Subcommand & Flag CLI (lib/cli.vk)

Build structured multi-subcommand CLIs with typed flags, defaults, and automatic --help rendering:

VEKO
use [cli]

build-cli = fn [] cli/App [
    mut app = cli/new-app 'deploy-ctl' '1.0.0' 'Pure-Veko release rollout utility'
    mut ship = cli/new-cmd 'ship' 'Roll out a signed release bundle'
    cli/add-flag mut ship (cli/FlagSpec { name = 'env',     short = 'e', kind = .string,  default_val = 'staging', help = 'Target environment' })
    cli/add-flag mut ship (cli/FlagSpec { name = 'workers', short = 'w', kind = .int,     default_val = 4,         help = 'Parallel rollout workers' })
    cli/add-flag mut ship (cli/FlagSpec { name = 'dry-run', short = 'n', kind = .boolean, default_val = false,     help = 'Validate without mutating' })
    cli/add-cmd mut app ship
    app
]

main = fn [] any [
    app = build-cli
    parsed = cli/parse/or app os/args [e ->
        println (cli/help-text app)
        return e
    ]
    if parsed.cmd == 'ship' [
        env_name = cli/get-str parsed 'env' 'staging'
        n_work   = cli/get-int parsed 'workers' 4
        dry      = cli/get-bool parsed 'dry-run' false
        println `Rolling out to {env_name} with {n_work} workers (dry_run={dry})`
    ]
    .ok
]

Recipe 2.3: Layered TOML + Environment Configuration with .secret Hygiene

Load human-friendly codec/toml configuration files while keeping API tokens and signing keys quarantined inside Veko's .secret type firewall (zeroized deterministically when scope exits):

VEKO
use [toml = codec/toml]

pub ServiceConfig = struct {
    host       str        = '127.0.0.1'
    port       i64        = 8080
    api_secret secret str = ''
}

pub load-config = fn [path str] ServiceConfig [
    raw = os/read-file/or path [ '' ]
    doc = if raw != '' [ toml/decode/or raw [ {} ] ] else [ {} ]

    host = str/append '' (map/get/or doc 'host' [ os/getenv/or 'APP_HOST' [ '127.0.0.1' ] ])
    port = as-i64 (map/get/or doc 'port' [ str/to-i64/or (os/getenv/or 'APP_PORT' [ '8080' ]) [ 8080 ] ])

    // Secret environment variable is tainted as `secret` and wiped on scope exit
    tok = os/getenv/secret/or 'APP_API_SECRET' [ secret '' ]
    println `Loaded config on {host}:{port} (token={tok})`  // prints token=<secret>

    ServiceConfig {
        host       = host
        port       = port
        api_secret = tok
    }
]