← Back to Official Package Registry
Tier 5: Cloud-Native, Noise, IaC & Wasm • Homoiconic IaC & DAG Provisionerv1.0.0 • 42 KB • Ed25519 Verified

iac_fleet@1.0.0

Declarative quote [...] desired-state infrastructure graph, Kahn topological DAG sorter, idempotent plan diffing, and .secret-redacted scripts.

use [iac_fleet]
veko pkg add iac_fleet@1.0.0
Run in Browser PlaygroundDownload 1.0.0.vkpRaw demo.vk

iac_fleet

Pure-Veko homoiconic Infrastructure-as-Code (quote [...]) resource DSL, Kahn topological DAG sorter, desired-vs-observed convergence planner, hardened systemd unit compiler, and secret-scrubbed POSIX fleet provisioner (iac_fleet).

Overview

iac_fleet brings declarative, deterministic server and fleet configuration management to Veko without YAML templating engines or external agents:

  • Homoiconic Declarative Resource DSL (compile-stack): Compiles Veko quote [...] blocks directly into validated Stack graphs supporting 8 core infrastructure resource types: .pkg, .file, .dir, .systemd_service, .user, .ufw_rule, .sysctl, and .exec_check with explicit needs = [...] dependency edges.
  • Topological Kahn DAG Sorter (sort-dag): Computes a deterministic execution order respecting all needs edges and rejects circular dependencies with an err naming the exact cycle nodes.
  • Idempotent Convergence Planner (plan-changes): Diffs a desired Stack against observed HostFacts snapshots to emit topologically ordered .create, .update (with unified field diffs via diff/format-unified), .noop, and .delete actions. Converged hosts deterministically produce 0 changes (has_changes == false).
  • Hardened systemd & Secret-Redacted POSIX Compiler: Generates sandboxed systemd units (NoNewPrivileges=yes, ProtectSystem=strict, PrivateTmp=yes) and idempotent sh -eu scripts while tracking secrets via truncated SHA-256 fingerprints so secret plaintext never enters plan summaries, unified diffs, or audit logs.

Installation

powershell
veko pkg add iac_fleet@1.0.0

Import the package in .vk source files:

rebol
use [iac = iac_fleet]

Architecture

text
+-------------------------+      compile-stack       +------------------------+
| Homoiconic quote [...]  | -----------------------> | Validated Stack + DAG  |
| .user / .dir / .file    |                          | Kahn sort-dag          |
| .systemd_service / ...  |                          +-----------+------------+
+-------------------------+                                      |
                                                                 v
+-------------------------+       plan-changes       +------------------------+
| Observed HostFacts      | -----------------------> | Deterministic Plan     |
| attrs + secret_digests  |                          | +create ~update -del   |
+-------------------------+                          | <redacted> audit log   |
                                                     +-----------+------------+
                                                                 |
                                                                 v
                                                     +------------------------+
                                                     | render-systemd-unit    |
                                                     | render-action-script   |
                                                     +------------------------+

Complete API Reference

SymbolSignatureDescription
compile-stackfn [stack_name str, spec block] StackCompiles a homoiconic quote [...] resource stack
sort-dagfn [stack Stack] block[Resource]Topologically orders resources via Kahn's algorithm or returns cycle err
new-host-factsfn [hostname str /os_family os_fam str = 'debian'] HostFactsCreates an empty HostFacts state snapshot
record-factfn [mut facts HostFacts, resource_id str, attrs map /secret_digests sdigests map[str] = {}] enumRecords observed resource state on a host
plan-changesfn [stack Stack, facts HostFacts] PlanComputes ordered .create, .update, .noop, and .delete steps
apply-plan-factsfn [facts HostFacts, plan Plan] HostFactsApplies plan to facts in memory to yield the converged snapshot
render-systemd-unitfn [res Resource /redact scrub_secrets bool = true] strRenders a hardened .service unit file
render-action-scriptfn [action PlanAction /redact scrub_secrets bool = true] strCompiles one PlanAction into idempotent POSIX sh commands
render-plan-scriptfn [plan Plan /redact scrub_secrets bool = true] strCompiles a complete Plan into an executable #!/bin/sh script
scrub-textfn [text str, secret_values block[str]] strReplaces any occurrence of secret_values with '<redacted>'

Idiomatic Veko Usage

rebol
use [iac = iac_fleet]

stack = iac/compile-stack 'prod-api' (quote [
    .user 'veko' [
        uid   = 990
        shell = '/usr/sbin/nologin'
    ]
    .dir '/etc/veko' [
        owner = 'veko'
        mode  = '0750'
        needs = ['user:veko']
    ]
    .file '/etc/veko/api.conf' [
        owner   = 'veko'
        mode    = '0640'
        content = 'port = 8080\n'
        needs   = ['dir:/etc/veko']
    ]
    .systemd_service 'veko-api' [
        user       = 'veko'
        exec_start = '/usr/local/bin/veko-api -c /etc/veko/api.conf'
        secret_env = [ 'API_SECRET' = 'rotate-me-2026' ]
        harden     = true
        needs      = ['user:veko' 'file:/etc/veko/api.conf']
    ]
])

facts = iac/new-host-facts 'api-01.internal'
plan  = iac/plan-changes stack facts
println plan.audit_log
println (iac/render-plan-script plan)
packages/iac_fleet/examples/demo.vkSelf-contained runnable example & assertion suite
Raw .vk
// packages/iac_fleet/examples/demo.vk
// Self-contained verification suite & runnable example for `iac_fleet`.

use [
	fs
	iac = iac_fleet
]

assert-true = fn [cond bool, label str] enum [
	if not cond [
		println (str/join ['[FAIL] ' label] '')
		os/exit 1
	]
	println (str/join ['[PASS] ' label] '')
	.ok
]

index-of-id = fn [ordered block, target_id str] i64 [
	mut i = 0
	while i < (len ordered) [
		if ordered[i].id == target_id [ return i ]
		i = i + 1
	]
	-1
]

// --- 1. Compile Homoiconic `quote [...]` Production Server Stack (All 8 Resource Kinds) ---
// Declared intentionally out-of-order (`exec_check` and `systemd_service` before `file`/`dir`/`user`/`pkg`)
// to exercise Kahn topological DAG sorting!
prod_stack = iac/compile-stack 'veko-prod-edge' (quote [
	.exec_check 'edge-readiness' [
		check_cmd = 'curl -fsS http://127.0.0.1:8443/healthz'
		apply_cmd = 'systemctl restart veko-edge'
		needs     = ['systemd_service:veko-edge']
	]
	.systemd_service 'veko-edge' [
		description = 'Veko Production TLS Edge Service'
		user        = 'veko'
		working_dir = '/var/lib/veko'
		exec_start  = '/usr/local/bin/veko-edge --config /etc/veko/edge.conf'
		env         = [ 'VEKO_ENV' = 'production', 'VEKO_LOG' = 'info' ]
		secret_env  = [
			'DB_PASSWORD'  = 'VekoProdDbSecret!2026#99'
			'API_HMAC_KEY' = 'HmacSuperSecretKey!887766'
		]
		harden = true
		needs  = ['user:veko' 'file:/etc/veko/edge.conf' 'sysctl:net.ipv4.tcp_fastopen' 'ufw_rule:https-8443']
	]
	.file '/etc/veko/edge.conf' [
		owner   = 'veko'
		group   = 'veko'
		mode    = '0640'
		content = 'listen = 0.0.0.0:8443\nworkers = 4\n'
		secrets = [ 'INLINE_TOK' = 'InlineSecretToken!5544' ]
		needs   = ['dir:/etc/veko' 'pkg:ca-certificates']
	]
	.dir '/etc/veko' [
		owner = 'veko'
		group = 'veko'
		mode  = '0750'
		needs = ['user:veko']
	]
	.user 'veko' [
		uid    = 990
		shell  = '/usr/sbin/nologin'
		home   = '/var/lib/veko'
		system = true
	]
	.pkg 'ca-certificates' [
		state = 'present'
	]
	.sysctl 'net.ipv4.tcp_fastopen' [
		value = '3'
	]
	.ufw_rule 'https-8443' [
		port   = 8443
		proto  = 'tcp'
		action = 'allow'
	]
])

ordered = iac/sort-dag prod_stack
pos_user = index-of-id ordered 'user:veko'
pos_pkg  = index-of-id ordered 'pkg:ca-certificates'
pos_dir  = index-of-id ordered 'dir:/etc/veko'
pos_file = index-of-id ordered 'file:/etc/veko/edge.conf'
pos_sys  = index-of-id ordered 'sysctl:net.ipv4.tcp_fastopen'
pos_ufw  = index-of-id ordered 'ufw_rule:https-8443'
pos_svc  = index-of-id ordered 'systemd_service:veko-edge'
pos_chk  = index-of-id ordered 'exec_check:edge-readiness'

dag_ok = (len ordered) == 8 and pos_user < pos_dir and pos_dir < pos_file and pos_pkg < pos_file and pos_file < pos_svc and pos_sys < pos_svc and pos_ufw < pos_svc and pos_svc < pos_chk
_ = assert-true dag_ok 'compile-stack (all 8 resource kinds) and Kahn sort-dag topological ordering'

// --- 2. Cycle Detection Naming Exact Cycle Participants ---
cyclic_stack = iac/compile-stack 'cyclic-test' (quote [
	.dir '/etc/app' [
		needs = ['systemd_service:app']
	]
	.file '/etc/app/app.conf' [
		needs = ['dir:/etc/app']
	]
	.systemd_service 'app' [
		exec_start = '/usr/bin/app'
		needs      = ['file:/etc/app/app.conf']
	]
])

cycle_err = iac/sort-dag/or cyclic_stack [e ->
	msg = mold e
	if (str/contains? msg 'cycle') and (str/contains? msg 'dir:/etc/app') and (str/contains? msg 'systemd_service:app') [
		[
			iac/Resource { id = '__cycle_caught__', kind = .dir, kind_name = 'dir', name = '/etc/app' }
		]
	] else [
		[]
	]
]
_ = assert-true ((len cycle_err) == 1 and cycle_err[0].id == '__cycle_caught__') 'sort-dag detects dependency cycles and names cycle nodes cleanly'

// --- 3. Deterministic `plan-changes` (Create, Update with Unified Diff, Delete) & Idempotency ---
mut initial_facts = iac/new-host-facts 'edge-01.prod.veko'

// Pre-populate 1 outdated resource (`sysctl` has `value = '1'` instead of `'3'`)
// and 1 orphan legacy resource (`file:/etc/veko/legacy.conf` to be deleted)
_ = iac/record-fact mut initial_facts 'sysctl:net.ipv4.tcp_fastopen' {
	key          = 'net.ipv4.tcp_fastopen'
	persist_file = '/etc/sysctl.d/99-veko.conf'
	value        = '1'
}
_ = iac/record-fact mut initial_facts 'file:/etc/veko/legacy.conf' {
	path    = '/etc/veko/legacy.conf'
	content = 'deprecated = true\n'
}

plan1 = iac/plan-changes prod_stack initial_facts

// Locate the `.update` action on `sysctl:net.ipv4.tcp_fastopen` to inspect its unified diff
mut sysctl_diff = ''
mut ai = 0
while ai < (len plan1.actions) [
	act = plan1.actions[ai]
	if act.resource_id == 'sysctl:net.ipv4.tcp_fastopen' and act.op == .update [
		sysctl_diff = act.diff_text
	]
	ai = ai + 1
]

plan1_ok = plan1.has_changes and plan1.creates == 7 and plan1.updates == 1 and plan1.deletes == 1 and plan1.noops == 0 and (str/contains? sysctl_diff '-value = \'1\'') and (str/contains? sysctl_diff '+value = \'3\'')
_ = assert-true plan1_ok 'plan-changes computes .create (7), .update with unified diff (1), and .delete (1)'

// Converge host state and re-run `plan-changes` -> MUST yield 0 changes and 8 `.noop` actions!
converged_facts = iac/apply-plan-facts initial_facts plan1
plan2 = iac/plan-changes prod_stack converged_facts

idemp_ok = (not plan2.has_changes) and plan2.creates == 0 and plan2.updates == 0 and plan2.deletes == 0 and plan2.noops == 8
_ = assert-true idemp_ok 'idempotency verified: second plan-changes against converged HostFacts yields 0 changes (all .noop)'

// --- 4. Hardened `systemd` Unit Generation & Secret Redaction Proof ---
svc_res   = map/get prod_stack.by_id 'systemd_service:veko-edge'
unit_safe = iac/render-systemd-unit svc_res
script_sh = iac/render-plan-script plan1

tmp_dir = str/join [(os/temp-dir) '/veko_iac_fleet_demo_' (mold (time/unix))] ''
_ = fs/mkdir-all tmp_dir
defer [ _ = fs/remove-all tmp_dir ]
script_path = str/join [tmp_dir '/converge.sh'] ''
_ = fs/write-atomic script_path (bytes/from-str script_sh)
disk_script = os/read-file script_path

systemd_ok = (str/contains? unit_safe '[Unit]') and (str/contains? unit_safe 'ExecStart=/usr/local/bin/veko-edge --config /etc/veko/edge.conf') and (str/contains? unit_safe 'NoNewPrivileges=yes') and (str/contains? unit_safe 'ProtectSystem=strict') and (str/contains? unit_safe 'PrivateTmp=yes')
_ = assert-true systemd_ok 'render-systemd-unit emits hardened sandboxing directives and service configuration'

// Verify ZERO leakage of raw secret values across audit logs, systemd previews, and rendered shell scripts!
no_leak_audit  = (not (str/contains? plan1.audit_log 'VekoProdDbSecret!2026#99')) and (not (str/contains? plan1.audit_log 'HmacSuperSecretKey!887766')) and (not (str/contains? plan1.audit_log 'InlineSecretToken!5544'))
no_leak_unit   = (not (str/contains? unit_safe 'VekoProdDbSecret!2026#99')) and (str/contains? unit_safe 'Environment="DB_PASSWORD=<redacted>"')
no_leak_script = (not (str/contains? disk_script 'VekoProdDbSecret!2026#99')) and (not (str/contains? disk_script 'HmacSuperSecretKey!887766')) and (str/contains? disk_script 'install -d -m')

// Also verify rotating a secret triggers `.update` without exposing either old or new secret value in `diff_text`!
rotated_stack = iac/compile-stack 'veko-prod-edge' (quote [
	.exec_check 'edge-readiness' [
		check_cmd = 'curl -fsS http://127.0.0.1:8443/healthz'
		apply_cmd = 'systemctl restart veko-edge'
		needs     = ['systemd_service:veko-edge']
	]
	.systemd_service 'veko-edge' [
		description = 'Veko Production TLS Edge Service'
		user        = 'veko'
		working_dir = '/var/lib/veko'
		exec_start  = '/usr/local/bin/veko-edge --config /etc/veko/edge.conf'
		env         = [ 'VEKO_ENV' = 'production', 'VEKO_LOG' = 'info' ]
		secret_env  = [
			'DB_PASSWORD'  = 'RotatedDbSecret!2027#NEW'
			'API_HMAC_KEY' = 'HmacSuperSecretKey!887766'
		]
		harden = true
		needs  = ['user:veko' 'file:/etc/veko/edge.conf' 'sysctl:net.ipv4.tcp_fastopen' 'ufw_rule:https-8443']
	]
	.file '/etc/veko/edge.conf' [
		owner   = 'veko'
		group   = 'veko'
		mode    = '0640'
		content = 'listen = 0.0.0.0:8443\nworkers = 4\n'
		secrets = [ 'INLINE_TOK' = 'InlineSecretToken!5544' ]
		needs   = ['dir:/etc/veko' 'pkg:ca-certificates']
	]
	.dir '/etc/veko' [
		owner = 'veko'
		group = 'veko'
		mode  = '0750'
		needs = ['user:veko']
	]
	.user 'veko' [
		uid    = 990
		shell  = '/usr/sbin/nologin'
		home   = '/var/lib/veko'
		system = true
	]
	.pkg 'ca-certificates' [ state = 'present' ]
	.sysctl 'net.ipv4.tcp_fastopen' [ value = '3' ]
	.ufw_rule 'https-8443' [ port = 8443, proto = 'tcp', action = 'allow' ]
])
plan_rot = iac/plan-changes rotated_stack converged_facts
mut rot_diff = ''
mut ri = 0
while ri < (len plan_rot.actions) [
	ra = plan_rot.actions[ri]
	if ra.resource_id == 'systemd_service:veko-edge' and ra.op == .update [
		rot_diff = ra.diff_text
	]
	ri = ri + 1
]
no_leak_rot = plan_rot.updates == 1 and (not (str/contains? rot_diff 'RotatedDbSecret!2027#NEW')) and (not (str/contains? rot_diff 'VekoProdDbSecret!2026#99')) and (str/contains? rot_diff 'secret.DB_PASSWORD')

_ = assert-true (no_leak_audit and no_leak_unit and no_leak_script and no_leak_rot) 'secret values are strictly redacted across audit logs, systemd previews, shell scripts, and rotation diffs'

println 'iac_fleet: all verification checks passed'
Cryptographic Provenance

Ed25519 Signature & Merkle Integrity

Registry URL: https://veko-lang.org/pkg/iac_fleet/1.0.0.vkp
Archive SHA-256: 921e71a68ab0c1659967cdb914502ed0b5407f960c38df981d3780f63ebc80bb
Merkle Root: bc60188047fe4f2f2c96077a5b34b25ee4a4108b0f08f9ed24538372000fc155
Signer Trust Key: ed25519:27406074d8681da1d4e6420f5d887cac15c313334c249ac047ba9d4e2df72b70
Embedded VKP1 Manifest

manifest.json

{"name":"iac_fleet","version":"1.0.0","tier":5.0,"tier_label":"Tier 5: Cloud-Native, Noise, IaC & Wasm","category":"Homoiconic IaC & DAG Provisioner","description":"Declarative quote [...] desired-state infrastructure graph, Kahn topological DAG sorter, idempotent plan diffing, and .secret-redacted scripts.","modules":["iac_fleet"],"homepage":"https://veko-lang.org/packages/iac_fleet"}
Bundle Entry PathSizeLeaf SHA-256 Digest
README.md5 KB67747d46ada52b668354ca6c2255cad06f1e1e688825f417dc08ae69211ab6a2
examples/demo.vk9 KBa57c357051e0655530d1dff469c5ad8f8c63a9a68cc88726648bd637b7f9fd0a
mod.vk27 KBe87019727ad087a1d59ad1a82d595af7d933c59825329bf7b236f87be3c973b7