Description
`one --agent flow validate` checks for undefined step references (e.g., `$.steps.X` where step X doesn't exist), but does NOT check that step X executes before the step that references it.
This causes silent bugs when:
- A cache write step (`buildCacheEntry`) references a result step (`buildResult`) that comes after it in the step array
- The cache entry is written as `null` because the result hasn't been computed yet
Reproduction
{
"steps": [
{"id": "buildCacheEntry", "type": "code", "code": {"source": "return $.steps.buildResult.output;"}},
{"id": "buildResult", "type": "code", "code": {"source": "return {data: 'hello'};"}}
]
}
`one --agent flow validate` returns `{"valid": true}` even though `buildCacheEntry` references `buildResult` which hasn't run yet.
Impact
Cache entries get written as `null` or `undefined`, causing downstream cache hits to return empty data. The bug is silent — no error, no warning. Subsequent runs read the poisoned cache and produce empty results.
Suggested Fix
During validation, build a dependency graph from step references (`$.steps.X`). Flag any step that references a step with a higher index in the steps array (i.e., a forward reference).
Description
`one --agent flow validate` checks for undefined step references (e.g., `$.steps.X` where step X doesn't exist), but does NOT check that step X executes before the step that references it.
This causes silent bugs when:
Reproduction
{ "steps": [ {"id": "buildCacheEntry", "type": "code", "code": {"source": "return $.steps.buildResult.output;"}}, {"id": "buildResult", "type": "code", "code": {"source": "return {data: 'hello'};"}} ] }`one --agent flow validate` returns `{"valid": true}` even though `buildCacheEntry` references `buildResult` which hasn't run yet.
Impact
Cache entries get written as `null` or `undefined`, causing downstream cache hits to return empty data. The bug is silent — no error, no warning. Subsequent runs read the poisoned cache and produce empty results.
Suggested Fix
During validation, build a dependency graph from step references (`$.steps.X`). Flag any step that references a step with a higher index in the steps array (i.e., a forward reference).