feature: env-all builtin for full process env map#408
Merged
Conversation
env-all > R (M t t) t snapshots the full process environment as a Map[Text, Text] wrapped in Result, mirroring env key's shape so env-all! auto-unwraps inside a Result-returning function. Closes the env-config rerun1 friction where agents had to hardcode key lists for merge-env-over-config patterns. Routed via the tree-bridge for VM/Cranelift dispatch: zero-arg enumeration is not perf-sensitive and Map[Text, Text] round-trips through NanVal heap_map cleanly, so a dedicated opcode would only add three near-identical implementations. Parser learns the zero-arg auto-expansion for env-all alongside now/now-ms/mmap so bare env-all parses as a Call rather than a Ref to an undefined variable. Non-UTF-8 env vars are silently skipped, matching std::env::vars's policy, so the Result is always Ok today. The Err arm stays reserved for future failure modes (sandboxed envs, etc).
Six cross-engine cases exercise the tree / VM / Cranelift dispatch paths via a canary env var set on the child process. Coverage: - env-all returns Ok(map) and exposes the canary - mget(env-all, k) matches env(k) for the same k (value parity) - env-all returns Ok even when the canary is removed (Ok-not-Err) - mkeys(env-all) contains the canary as a t (MapKey -> Text round-trip) - bare env-all (no !) parses as a zero-arg Call - env-all with an extra arg errors at verify/arity time examples/env-all.ilo runs through the existing examples_engines harness, pinning the has-path / path-matches contract across every engine so agents loading the example see the canonical usage.
SPEC.md picks up the builtins table row plus a prose section under 'env' covering the merge-env-over-config use case and the non-UTF-8 skip policy. ai.txt and skills/ilo/SKILL.md regenerate from SPEC.md via build.rs. skills/ilo/ilo-builtins.md (modular skill) picks up the same one-line entry next to env.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
env-all > R (M t t) tsnapshots the full process environment as aMap[Text, Text]wrapped inR, mirroring the existingenv keyshape soenv-all!auto-unwraps inside a Result-returning function.Why
env-config rerun1 (
ilo_assessment_feedback.md, 2026-05-18) flagged that ilo can read a single env var by name but cannot enumerate the environment, forcing agents to hardcode key lists for "merge env over config" patterns. AM t treturning all env vars closes that gap in two lines:Manifesto framing: removes a repeating retry tax for every config-shaping persona, with no new short name reserved (env-all is 7 chars, falls under the "4+ chars are always safe" forecast).
Repro
Before:
After:
What's in the diff
builtins: add env-all for full process env map—Builtin::EnvAllvariant + name registration infrom_name/name/ALL. Interpreter implementation snapshotsstd::env::varsinto aValue::Mapwrapped inValue::Ok. Tree-bridge eligible at(EnvAll, 0)and marked Result-returning soenv-all!auto-unwraps. Verifier returnsTy::Result(Map(Text, Text), Text). Parser learns the zero-arg auto-expansion alongsidenow/now-ms/mmapso bareenv-allparses as a Call.tests: cross-engine regression coverage for env-all— 6 cross-engine cases intests/regression_env_all.rs(canary present, value parity withenv key, empty-env Ok-not-Err, mkeys round-trip, bare zero-arg parse, arity guard).examples/env-all.ilopins has-path / path-matches via the examples_engines harness across tree/VM/Cranelift.docs: env-all in SPEC, ai.txt, SKILL.md, ilo-builtins.md— SPEC.md table + prose. ai.txt and skills/ilo/SKILL.md regenerate from SPEC.md via build.rs. Modularskills/ilo/ilo-builtins.mdpicks up the one-line entry next toenv.Test plan
cargo test --release --features cranelift— full suite greencargo test --release --features cranelift --test regression_env_all— 6/6 pass on tree / VM / Craneliftcargo test --release --features cranelift --test examples_engines—env-all.iloruns through every enginecargo fmt --checkcargo clippy --release --features cranelift --all-targets -- -D warningsFollow-ups
ilo-lang/site(separate repo, not on local disk) needs the same env-all addition tosrc/content/docs/docs/builtins/data-io.md. I will follow up there once the site repo is cloned locally.R (M t t) tis reserved for future failure modes (non-UTF-8 vars, sandboxed envs). std::env::vars silently skips non-UTF-8 today, so the snapshot is always Ok in the current implementation.