Skip to content

fix: SHIP handshake conformance (CMI/PROT/TERM abort behavior)#101

Open
andig wants to merge 1 commit into
enbility:devfrom
andig:fix/ship-handshake-conformance
Open

fix: SHIP handshake conformance (CMI/PROT/TERM abort behavior)#101
andig wants to merge 1 commit into
enbility:devfrom
andig:fix/ship-handshake-conformance

Conversation

@andig

@andig andig commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #98. Contributes to #95 (SHIP TestSpecification V1.0.0 compliance).

Fixes six non-conformances against the SHIP High-Level Test Specification, all in the handshake / connection-lifecycle abort paths. #98 covers PROT_003/004; this PR also resolves CMI_001, PROT_005/006 and TERM_001 in the same area.

TC Before After
CMI_001 server dropped an invalid CMI message with no reply sends CMI {0,0} reject before closing
PROT_003 server proto-handshake wait-timer expiry sent no frame sends protocolHandshakeError error=1 (timeout)
PROT_004 client wait-timer expiry sent error=2 sends error=1 (timeout)
PROT_005 server unexpected/malformed proposal sent no frame sends error=2 (unexpected message)
PROT_006 client valid-but-non-select sent error=3 sends error=2 (unexpected message); malformed select stays error=3 (selection mismatch)
TERM_001 announced close carried raw caller string (e.g. "User close") as reason maps free-form reasons to a valid ConnectionCloseReasonType (unspecific)

How

  • Timeouts are now handled in the handleState dispatch for the server/client protocol-handshake states before the message handler runs, so a nil-message timeout is not misclassified as an unexpected message.
  • The proposal/choice handlers use abortProtocolHandshake (which emits the error frame) instead of endHandshakeWithError (which does not) for message-rejection paths; genuine send errors still use endHandshakeWithError.
  • The client choice handler distinguishes "not a select at all" (unexpected message, error=2) from "a select with bad version/format" (selection mismatch, error=3).
  • validCloseReason sanitizes the announced close reason.

Tests

New/updated conformance tests assert the exact SHIP error codes on the sent frame (Test_ListenProposal_Timeout, Test_ListenProposal_Failure, Test_ListenChoice_Timeout, Test_ListenChoice_UnexpectedMessage, Test_ListenChoice_SelectionMismatch, Test_ServerWait_Invalid*, TestValidCloseReason). Every test is annotated with its TC id. Full module test suite passes.

🤖 Generated with Claude Code

Fixes six SHIP high-level test-spec non-conformances in the handshake
and connection lifecycle:

- TC_SHIP_CMI_001: as server, reject an invalid CMI message by sending a
  CMI message (MessageType=0, MessageValue=0) before closing.
- TC_SHIP_PROT_003: server protocol-handshake wait-timer expiry now sends
  protocolHandshakeError error=1 (timeout) instead of no frame.
- TC_SHIP_PROT_004: client wait-timer expiry now sends error=1 (timeout)
  instead of error=2 (unexpected message).
- TC_SHIP_PROT_005: server unexpected/malformed proposal now sends
  error=2 (unexpected message) instead of no frame.
- TC_SHIP_PROT_006: client valid-but-non-select message now sends error=2
  (unexpected message); malformed select remains error=3 (selection mismatch).
- TC_SHIP_TERM_001: the announced close message now carries a valid SHIP
  ConnectionCloseReasonType; free-form reasons map to "unspecific".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 92.88% (-0.1%) from 92.993% — andig:fix/ship-handshake-conformance into enbility:dev

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.

Test Compliance: TC_SHIP_PROT_003 / TC_SHIP_PROT_004 — Protocol handshake timeout sends no error frame

2 participants