Skip to content

workflows: persisted-state normalization fails open — unknown/missing states become completed/done #118

Closed

Description

@tt-a1i

Description

Verified by read-only audit (seal/gpt-5.6-sol subagent, verdict: CONFIRMED).

Mechanism

workflow.json is read exclusively through normalization (dashboard.ts:147-160):

  • Agent states (dashboard.ts:285-296): error|failed→error, uncertain→uncertain, running→running — everything else, including missing/new values, → done.
  • Run statuses (dashboard.ts:412-419): running|failed|aborted|uncertain survive; everything else, including missing/new values, → completed.
  • Stale recovery (dashboard.ts:479-516) only handles normalized running; unknown statuses already converted to completed bypass recovery.

The writer is enum-controlled (index.ts:1140-1148, 1240-1280, 1350-1405, 1637-1644, 1855-1863, 2005-2046), so the realistic trigger is forward-version artifacts, malformed files, or safeStringify replacing an oversized workflow with a status-less truncation object.

Consumer impact (all read the fail-open value; none read raw status)

  • Human dashboard / saved report (dashboard.ts:538-566, 759-768, 1028-1240)
  • Non-TUI /workflows (index.ts:673-738, 1061-1097)
  • Model-facing workflow_status(runId) (index.ts:2198-2318, prompt.ts:263-281) — the model can make wrong decisions on a corrupt run reported as completed.
  • workflow_stop treats malformed persisted runs as already completed.
  • Session recovery (index.ts:970-990) bypasses recovery for unknown status; with valid pending delivery it can even restore/deliver the falsely completed result.

Why this is a bug, not just compat

Comments do describe lenient old-tool compatibility (dashboard.ts:141-145, 272), and legacy tests include explicit valid statuses — there is no workflow schema version or evidence that old valid artifacts omitted these fields. Compatibility may justify aliases like failed→error, but not defaulting every future/malformed value to success, especially with model-facing status, recovery, stopping, and delivery decisions trusting the normalized result.

Suggested fix

Fail closed: map unknown/missing values to uncertain (or an explicit invalid marker), and validate cross-field consistency (e.g. a completed run containing running agents) before exposing status via dashboard, workflow_status, or recovery surfaces.

Found by automated workflow audit (run wf_56028a5b018b).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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