Skip to content

Require clean shutdown before protocol completion - #74

Merged
Taz33m merged 1 commit into
mainfrom
codex/stdio-close-contract
Aug 5, 2026
Merged

Require clean shutdown before protocol completion#74
Taz33m merged 1 commit into
mainfrom
codex/stdio-close-contract

Conversation

@Taz33m

@Taz33m Taz33m commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • close the engine exactly once before emitting the terminal complete frame
  • emit one ADAPTER_ERROR and exit 2 when shutdown fails
  • preserve an earlier protocol error when shutdown also fails
  • verify the behavior through direct transcripts and a real child-process adapter

Observable change

Only the previously dishonest close-failure path changes: complete is omitted and ADAPTER_ERROR is emitted. Normal and protocol-error transcripts remain byte-for-byte identical.

Verification

  • full pytest suite
  • black, flake8, mypy, bandit, compileall
  • baseline transcript byte comparison
  • built-wheel metadata check and isolated qualification smoke: 3/3 fixed, 25/25 traces, 5,000 events, 10/10 capabilities

Summary by cubic

Enforces a clean shutdown contract for the stdio protocol: complete is sent only after a successful adapter.close(). If shutdown fails, the server sends a single ADAPTER_ERROR, omits complete, and exits with code 2, while preserving any earlier PROTOCOL_ERROR.

  • Bug Fixes
    • Close the engine exactly once before emitting complete; on close() failure, emit ADAPTER_ERROR and exit 2.
    • Preserve a prior PROTOCOL_ERROR if close() also fails; don’t overwrite the terminal error.
    • Centralize error writes via _write_error and update docs/tests; normal and protocol-error transcripts remain unchanged.

Written for commit 927a330. Summary will update on new commits.

Review in cubic

@Taz33m
Taz33m merged commit 2c8bf63 into main Aug 5, 2026
8 checks passed
@Taz33m
Taz33m deleted the codex/stdio-close-contract branch August 5, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant