Skip to content

Flow validator should check step data dependency ordering #91

@ameet

Description

@ameet

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions