Skip to content

Swift runtime: complete driver/channel state-machine redesign #256

@fasterthanlime

Description

@fasterthanlime

Context

We landed a targeted Swift runtime hardening patch to stabilize CI, but this did not complete the full redesign we discussed.

This issue tracks the full Swift redesign needed for correctness-by-construction under resume/retry/channel concurrency.

Required redesign scope

  1. Single explicit driver phase state machine with serialized ownership.
    • Phases such as connected, resuming, disconnected.
    • Atomic transition boundaries for resume.
  2. Single outbound writer/sequencer path.
    • No side sends that can bypass queued backlog ordering.
  3. Explicit channel lifecycle FSM.
    • open/closing/closed (or equivalent) with guarded transitions.
    • Eliminate ambiguous buffer/close races.
  4. Retry/channel rebinding ownership.
    • Generation-aware rebinding and finalize semantics owned by a single state authority.

Constraints

  • Preserve current protocol semantics.
  • Keep strict schema behavior (no duplicate-schema spec relaxation).
  • Keep retry behavior consistent with spec tests.

Validation plan

  • Repeated local stress loops for:
    • lang_swift_transport_tcp::direction_harness_to_subject::channel_retry_idem_reruns_with_fresh_channels
    • lang_swift_transport_tcp::direction_harness_to_subject::channel_retry_non_idem_fails_closed
  • Repeated full lang_swift_transport_tcp:: matrix runs before merge.

Motivation

Current hardening reduced flakiness and got CI green, but architectural debt remains. This redesign should move Swift runtime behavior from “stabilized by patches” to “provably sequenced by design”.

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