Repository navigation
Closed
Description
Summary
Build actions can read declared environment inputs through
BuildCtx.env_input and ActionCtx.env_input. The original blocker was already
implemented when this issue was filed. Remaining work is diagnostics and
effect enforcement for raw environment reads, documentation, and removal of a
stale build comment.
Current state (revalidated 2026-07-15)
The blessed path works end to end:
let enabled = ctx.env_input("WITH_TEST_NETWORK")
The value is recorded as a build input, and changing it invalidates the cached
action.
Three gaps remain:
- A natural raw call wrapped in unsafe { ... } reaches
NK_UNSAFE_BLOCK, which the comptime evaluator does not handle, and produces
the generic “expression kind 70 is not comptime-evaluable yet” error instead
of steering the user to ctx.env_input. - A direct raw with_getenv_str call gets the useful undeclared-input
diagnostic under strict effects, but default mode currently permits the
ambient read without recording it. That violates the declared-input model
unless the evaluator records it as a discovered input. - §17.1b describes environment capabilities but the public env_input APIs are
not documented in repository docs.
build/selfhost.w also still says a raw-getenv opt-in is unavailable beside the
disabled zlib case. The raw form should remain discouraged, but the comment
must point at env_input rather than claiming no API exists.
Work
- Evaluate unsafe block structure far enough to emit the targeted declared-
input diagnostic, or reject the block directly with that guidance. - In ordinary mode, never silently consume an unrecorded raw environment value:
require ctx.env_input or explicitly record a discovered input according to
§17.1a/§17.1b. - Document BuildCtx.env_input and ActionCtx.env_input with examples and cache
invalidation semantics. - Update the stale Restore hermetic with-get gate coverage and add a content-addressed cache #624 comment in build/selfhost.w.
Acceptance criteria
- Declared env_input reads work in graph construction and action execution.
- Changing a declared variable invalidates the correct cached node.
- Raw direct and unsafe-wrapped environment reads cannot silently affect build
output; diagnostics name ctx.env_input. - Default and strict-effects behavior are explicitly specified and tested.
- The API and its declared-input semantics are documented.
- Full build, fixpoint, and test gates pass.
Traceability
- Specification §17.1a, Declared vs discovered inputs
- Specification §17.1b, Capability-bearing comptime
Activity
test: skip the flaky get-zlib network case (unconditional)
[-]comptime evaluation can't read env vars (extern getenv) — build actions can't gate on the environment[/-][+]Build-action environment inputs: diagnostics, default effects, and docs[/+]ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): still reproduces, and the first gap's diagnostic is now worse than the issue records. A raw getenv in a build file reports a return-type error instead of steering toctx.env_input:pre-release: a misleading diagnostic in the build file every project writes; the fix is a targeted refusal naming
ctx.env_input.Sema: a build file's environment read is refused with a pointer to ct…
ehartford commentedon Oct 26, 2026
Fixed on main by 21c4a21 (#2727), merged through stack 9 whose seed-driven battery was green on its top (gate, uat and survey all green). Regression test:
test/behavior/behav_649_build_env_read_names_env_input.w.