You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support global and node-level env variables (#108)
## Summary
- Adds three-layer `env` inheritance (project → node → variant) to
`veld.json`, matching the existing layering pattern used by
`url_template`, `features`, and `client_log_levels`
- For each key, the most specific layer wins; keys from parent layers
that are not overridden are preserved
- Adds `resolve_env()` in config.rs, updates all three `build_env` call
sites in the orchestrator, extends the JSON schema with a shared
`EnvMap` definition, and documents the feature
## Test plan
- [x] 5 new unit tests for `resolve_env()` covering: no layers,
project-only, node overrides project, variant overrides all,
variant-only
- [x] All 68 existing veld-core tests pass
- [ ] Manual: create a veld.json with project-level `env`, verify vars
are inherited by all variants
- [ ] Manual: add node-level `env` override, verify node-level wins for
that key while project keys are preserved
- [ ] Manual: add variant-level `env` override, verify variant wins
Closes#107
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+21-1Lines changed: 21 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,7 +198,27 @@ Control which Veld capabilities are injected into `start_server` nodes' HTML res
198
198
}
199
199
```
200
200
201
-
Available features: `feedback_overlay` (toolbar/comments UI), `client_logs` (browser log collector). All default to `true`.
201
+
Available features: `feedback_overlay` (toolbar/comments UI), `client_logs` (browser log collector), `inject` (auto-inject bootstrap scripts). All default to `true`.
202
+
203
+
### Environment variables
204
+
205
+
Declare `env` at the project, node, or variant level. Variables cascade: variant > node > project (per-key merge, most specific wins). Values support `${...}` variable substitution.
|`client_logs`| boolean |`true`| Inject the client-side log collector |
122
+
|`inject`| boolean |`true`| Auto-inject bootstrap scripts into HTML responses. When `false`, `/__veld__/*` routes are still available for manual `<script>` tags. |
121
123
122
124
```json
123
125
{
@@ -139,6 +141,35 @@ Controls which Veld capabilities are injected into `start_server` nodes' HTML re
139
141
140
142
In this example, the project disables the feedback overlay by default, and the `api` node also disables client logs. But the `api:local` variant re-enables the feedback overlay.
141
143
144
+
### `env`
145
+
146
+
Global environment variables inherited by all node variants. Values support Veld variable substitution. The same override hierarchy applies: variant > node > project. For each key, the most specific layer wins; keys from parent layers that are not overridden are preserved.
147
+
148
+
```json
149
+
{
150
+
"env": {
151
+
"FEATURE_FLAG_X": "1",
152
+
"SHARED_CONFIG": "value"
153
+
},
154
+
"nodes": {
155
+
"api": {
156
+
"env": {
157
+
"SHARED_CONFIG": "api-override"
158
+
},
159
+
"variants": {
160
+
"local": {
161
+
"env": {
162
+
"PORT": "${veld.port}"
163
+
}
164
+
}
165
+
}
166
+
}
167
+
}
168
+
}
169
+
```
170
+
171
+
In this example, `api:local` inherits `FEATURE_FLAG_X=1` from the project, gets `SHARED_CONFIG=api-override` from the node (overriding the project value), and adds `PORT` at the variant level.
172
+
142
173
---
143
174
144
175
## Nodes
@@ -391,7 +422,9 @@ Extra environment variables injected into the process. Values support Veld varia
391
422
}
392
423
```
393
424
394
-
**Precedence:** The `env` block takes strict precedence over the inherited shell environment. Shell variables not overridden by `env` are passed through unchanged.
425
+
**Layering:** Environment variables cascade from project to node to variant. For each key, the most specific layer wins. Keys from parent layers that are not overridden are preserved. See the project-level [`env`](#env) section for a full example.
426
+
427
+
**Precedence:** The merged `env` block takes strict precedence over the inherited shell environment. Shell variables not overridden by `env` are passed through unchanged.
Copy file name to clipboardExpand all lines: schema/v1/veld.schema.json
+17-5Lines changed: 17 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,10 @@
50
50
"$ref": "#/$defs/FeaturesConfig",
51
51
"description": "Feature toggles (project-level defaults). Overridable at node and variant level."
52
52
},
53
+
"env": {
54
+
"$ref": "#/$defs/EnvMap",
55
+
"description": "Global environment variables inherited by all node variants. Overridable at node and variant level."
56
+
},
53
57
"nodes": {
54
58
"type": "object",
55
59
"description": "The dependency graph nodes. Each key is a node name, and the value defines its variants.",
@@ -87,6 +91,10 @@
87
91
"$ref": "#/$defs/FeaturesConfig",
88
92
"description": "Feature toggles override for all variants of this node."
89
93
},
94
+
"env": {
95
+
"$ref": "#/$defs/EnvMap",
96
+
"description": "Extra environment variables inherited by all variants of this node. Overrides project-level env. Overridable at variant level."
97
+
},
90
98
"cwd": {
91
99
"type": "string",
92
100
"description": "Working directory for all variants of this node. Relative paths are resolved from the project root. Overridable at variant level. Supports Veld variable substitution."
@@ -132,11 +140,8 @@
132
140
}
133
141
},
134
142
"env": {
135
-
"type": "object",
136
-
"description": "Extra environment variables injected into the process.",
137
-
"additionalProperties": {
138
-
"type": "string"
139
-
}
143
+
"$ref": "#/$defs/EnvMap",
144
+
"description": "Extra environment variables injected into the process. Overrides node-level and project-level env."
140
145
},
141
146
"outputs": {
142
147
"description": "Output declarations. For command steps: an array of output names captured from $VELD_OUTPUT_FILE (preferred) or VELD_OUTPUT stdout lines (legacy). For start_server steps: an object mapping output names to template strings.",
@@ -250,6 +255,13 @@
250
255
"default": ["log", "warn", "error"],
251
256
"uniqueItems": true
252
257
},
258
+
"EnvMap": {
259
+
"type": "object",
260
+
"description": "A map of environment variable names to values. Values support Veld variable substitution (e.g. ${veld.port}, ${nodes.backend.url}).",
261
+
"additionalProperties": {
262
+
"type": "string"
263
+
}
264
+
},
253
265
"HealthCheck": {
254
266
"type": "object",
255
267
"description": "Health check configuration for a start_server variant.",
0 commit comments