Skip to content

Transport: validate fixture at place_call time to avoid partial session state #2

@brettheap

Description

@brettheap

Summary

FixtureDrivenTransport.event_stream() parses and validates the fixture JSON
after the orchestrator has already transitioned the session to in_flight
and incremented attempt_count. A malformed fixture (invalid JSON, a missing
events array, or an event missing type/event_id/timestamp) therefore
fails mid-stream.

As of PR #1 the failure is clean — event_stream() raises ValueError and
run-one converts it to an error: line + exit code 2 — but the SQLite state
store is left with a partially-progressed session row and a consumed
attempt
. For recoverable operator input (a typo'd fixture path/JSON) the run
is therefore not idempotent at the workflow level.

Proposed fix

Parse and structurally validate the fixture in FixtureDrivenTransport.place_call()
— before the orchestrator mutates any session state — so a malformed fixture is
rejected with no session row created and no attempt consumed. event_stream()
can then assume a well-formed fixture.

Context

  • Source: Codex review of commit 5e15f5b (finding 5); deferred from PR Slice 1 — Mock Call, Mock CRM (feature 001) #1.
  • Affected: src/opencloser/transport/mock.pyplace_call() / event_stream().
  • Severity: P2 — the error already surfaces cleanly; the gap is the leftover partial state.
  • Likely Slice 2 scope, but small enough to land standalone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions