Skip to content

Rename ProtocolVersion to StartupRequestCode - #12

Merged
DHUKK merged 2 commits into
mainfrom
rename-protocol-version-constant
Mar 17, 2026
Merged

Rename ProtocolVersion to StartupRequestCode#12
DHUKK merged 2 commits into
mainfrom
rename-protocol-version-constant

Conversation

@DHUKK

@DHUKK DHUKK commented Mar 17, 2026

Copy link
Copy Markdown
Owner

🦑 Description

Rename ProtocolVersion to StartupRequestCode

The startup packet's 4-byte field is a request code discriminator, not exclusively a protocol version. Renames the enum and updates version_code to request_code throughout registry, framing, and docs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the startup packet discriminator enum from ProtocolVersion to StartupRequestCode to reflect that the 4-byte startup field is a request-code discriminator (protocol versions + magic request codes), and updates framing/registry/tests/docs accordingly.

Changes:

  • Introduce StartupRequestCode (replacing ProtocolVersion) and update public exports.
  • Rename startup registry/framing discriminator terminology from version_code to request_code.
  • Update unit tests and documentation to use the new name/terminology.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/test_messages_startup.py Updates startup message tests to use StartupRequestCode.
tests/unit/test_framing.py Updates framing tests/error-message expectations to “request code”.
tests/unit/test_codec.py Updates codec tests to use StartupRequestCode.
src/pygwire/messages/_startup.py Switches startup message registrations/encoding to StartupRequestCode and request_code registration arg.
src/pygwire/messages/_registry.py Renames startup registry API from version_code to request_code and updates docs/comments.
src/pygwire/framing.py Renames parsed discriminator from version_code to request_code and updates error messages/docs.
src/pygwire/constants.py Replaces ProtocolVersion enum with StartupRequestCode and updates __all__.
src/pygwire/init.py Updates top-level re-export from ProtocolVersion to StartupRequestCode.
docs/reference/messages/startup.md Updates StartupMessage field description to “startup request code”.
docs/reference/messages/index.md Updates terminology/signature in lookup section to “request code”.
docs/reference/constants.md Renames constants doc section to StartupRequestCode.
Comments suppressed due to low confidence (1)

src/pygwire/init.py:42

  • pygwire no longer re-exports ProtocolVersion from the top-level package, which will break from pygwire import ProtocolVersion for existing users. If this is intended, it should be called out as a breaking change; otherwise consider re-exporting a deprecated alias for a transition period.
from pygwire.constants import ConnectionPhase, StartupRequestCode, TransactionStatus
from pygwire.exceptions import (
    DecodingError,
    FramingError,
    ProtocolError,
    PygwireError,
    StateMachineError,
)
from pygwire.state_machine import (
    BackendStateMachine,
    FrontendStateMachine,
)

__version__ = version("pygwire")

__all__ = [
    "BackendConnection",
    "BackendMessageDecoder",
    "BackendStateMachine",
    "Connection",
    "ConnectionPhase",
    "DecodingError",
    "FramingError",
    "FrontendConnection",
    "FrontendMessageDecoder",
    "FrontendStateMachine",
    "ProtocolError",
    "StartupRequestCode",
    "PygwireError",
    "StateMachineError",
    "TransactionStatus",
]

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread tests/unit/test_framing.py
Comment thread docs/reference/messages/index.md Outdated
Comment thread src/pygwire/constants.py
@DHUKK
DHUKK force-pushed the rename-protocol-version-constant branch from 37575a7 to 1cdc64d Compare March 17, 2026 18:33
@DHUKK
DHUKK requested a review from Copilot March 17, 2026 18:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the startup packet “ProtocolVersion” enum to StartupRequestCode to reflect that the first 4 bytes in startup framing are a discriminator for multiple startup-phase message types (protocol versions plus SSL/GSSENC/CANCEL magic codes), and updates related registry/framing naming and docs accordingly.

Changes:

  • Replace ProtocolVersion with StartupRequestCode across constants, startup message implementations, and tests/docs.
  • Rename startup registry API from version_code to request_code and propagate through framing and error messages.
  • Update documentation to reflect the new naming and semantics.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/test_messages_startup.py Updates startup-message unit tests to use StartupRequestCode and request-code wording.
tests/unit/test_framing.py Updates framing tests to expect request-code terminology and error messages.
tests/integration/test_malformed_payloads.py Updates integration malformed-payload test to use StartupRequestCode / request-code wording.
src/pygwire/messages/_startup.py Switches startup-phase message registrations and encodings to StartupRequestCode and request_code= registry args.
src/pygwire/messages/_registry.py Renames startup registry decorator/lookup parameter from version_code to request_code and updates docstrings.
src/pygwire/framing.py Renames parsed startup discriminator variable and error messages from version-code to request-code terminology.
src/pygwire/constants.py Introduces StartupRequestCode enum and exports it (replacing ProtocolVersion).
src/pygwire/init.py Re-exports StartupRequestCode from the package top-level.
docs/reference/messages/startup.md Updates reference docs to mention StartupRequestCode as the default for the startup discriminator field.
docs/reference/messages/index.md Removes outdated lookup-function docs that referenced version-code lookups.
docs/reference/constants.md Renames the constants reference section to StartupRequestCode and updates description.
CHANGELOG.md Notes the breaking rename (ProtocolVersionStartupRequestCode) and registry API rename (version_coderequest_code).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@DHUKK
DHUKK force-pushed the rename-protocol-version-constant branch from 852e29c to 8da1a81 Compare March 17, 2026 21:48
DHUKK added 2 commits March 17, 2026 21:49
The startup packet's 4-byte field is a request code discriminator,
not exclusively a protocol version. Renames the enum and updates
version_code to request_code throughout registry, framing, and docs.
@DHUKK
DHUKK force-pushed the rename-protocol-version-constant branch from 8da1a81 to 34abd44 Compare March 17, 2026 21:49
@DHUKK
DHUKK merged commit bf0e897 into main Mar 17, 2026
17 checks passed
@DHUKK
DHUKK deleted the rename-protocol-version-constant branch March 17, 2026 22:04
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.

2 participants