Skip to content

feature: env-all builtin for full process env map#408

Merged
danieljohnmorris merged 3 commits into
mainfrom
feature/env-all
May 18, 2026
Merged

feature: env-all builtin for full process env map#408
danieljohnmorris merged 3 commits into
mainfrom
feature/env-all

Conversation

@danieljohnmorris
Copy link
Copy Markdown
Collaborator

Summary

env-all > R (M t t) t snapshots the full process environment as a Map[Text, Text] wrapped in R, mirroring the existing env key shape so env-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. A M t t returning all env vars closes that gap in two lines:

overrides>R (M t t) t;m=env-all!;~m

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:

$ ilo 'f>R t t;env-all' f
ILO-T004 undefined variable 'env-all'

After:

$ ILO_ENV_ALL_TEST_CANARY=42 ilo 'f>R t t;m=env-all!;~mget m "ILO_ENV_ALL_TEST_CANARY"' f
42

What's in the diff

  • builtins: add env-all for full process env mapBuiltin::EnvAll variant + name registration in from_name/name/ALL. Interpreter implementation snapshots std::env::vars into a Value::Map wrapped in Value::Ok. Tree-bridge eligible at (EnvAll, 0) and marked Result-returning so env-all! auto-unwraps. Verifier returns Ty::Result(Map(Text, Text), Text). Parser learns the zero-arg auto-expansion alongside now/now-ms/mmap so bare env-all parses as a Call.
  • tests: cross-engine regression coverage for env-all — 6 cross-engine cases in tests/regression_env_all.rs (canary present, value parity with env key, empty-env Ok-not-Err, mkeys round-trip, bare zero-arg parse, arity guard). examples/env-all.ilo pins 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. Modular skills/ilo/ilo-builtins.md picks up the one-line entry next to env.

Test plan

  • cargo test --release --features cranelift — full suite green
  • cargo test --release --features cranelift --test regression_env_all — 6/6 pass on tree / VM / Cranelift
  • cargo test --release --features cranelift --test examples_enginesenv-all.ilo runs through every engine
  • cargo fmt --check
  • cargo clippy --release --features cranelift --all-targets -- -D warnings

Follow-ups

  • ilo-lang/site (separate repo, not on local disk) needs the same env-all addition to src/content/docs/docs/builtins/data-io.md. I will follow up there once the site repo is cloned locally.
  • The Err arm of R (M t t) t is 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.

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
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@danieljohnmorris danieljohnmorris merged commit e508082 into main May 18, 2026
5 checks passed
@danieljohnmorris danieljohnmorris deleted the feature/env-all branch May 18, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant