Skip to content

[Task] Refactor TCP/UDP to per-operation completion context for concurrency safety #10

@crrow

Description

@crrow

Goal

Refactor TCP/UDP operation state handling to support safe concurrent operations by using per-operation completion/context instead of single shared mutable completion state.

Scope

In scope:

  • pkg/xev/tcp.go
  • pkg/xev/udp.go
  • pkg/cxev/tcp.go
  • pkg/cxev/udp.go
  • related tests

Out of scope:

  • changing the overall package split (xev/cxev)
  • adding new network protocol features

Problem Statement

TCPConn/UDPConn currently reuse single completion/callback fields across operations, which can cause callback ID overwrites and race-prone behavior under overlapping read/write/close sequences.

Definition of Done

  • Introduce per-op state object for TCP/UDP similar to robust file-op pattern.
  • Ensure read/write/close overlap is either safely supported or explicitly rejected with deterministic errors.
  • Add tests for overlapping operations and callback correctness.
  • just check passes.
  • just test-quick passes.

Verification Commands

just check
just test-quick
go test ./pkg/xev -run 'TCP|UDP' -race -count=1

Performance and Latency Budget

  • Throughput regression <= 3%.
  • p99 latency regression <= 5%.

Worktree Branch Name

codex/issue-2-per-op-completion-tcp-udp

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: important for MVP qualitymvpTracks current MVP milestone scopeperformanceThroughput and CPU efficiency workstabilityReliability and correctness improvementssubagentSubagent execution tasktoken-LLarge token budget taskwave-2Execution wave 2

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions