refactor(message): name the envelope-managed header keys#143
Merged
Conversation
content-type and correlation_id were duplicated as bare string literals across three modules: envelope.py writes them, parser.py reads them back, and the subscriber's relay header-propagation strips them. Define them once in message.py (alongside the sibling DLQFailureReason wire contract) and repoint all five sites. - CONTENT_TYPE_HEADER / CORRELATION_ID_HEADER for the per-key read/write sites - ENVELOPE_MANAGED_HEADERS frozenset for the relay strip loop Behavior-preserving; adding a managed key is now a one-line edit instead of three. Full suite green (599 passed, coverage 100%), lint + ty clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
content-typeandcorrelation_idwere duplicated as bare string literals across three modules that share an unnamed contract:envelope.py(_encode_payload) writes them, with conflict detectionparser.py(OutboxParser.parse_message) reads them backsubscriber/usecase.py(_maybe_propagate_inbound_headers) strips them on the relay pathFrom the architecture-deepening review (candidate #6). Defines the managed-key set once in
message.py— the neutral wire-contract home, alongside the siblingDLQFailureReason— and repoints all five literal sites.Changes
message.py—CONTENT_TYPE_HEADER,CORRELATION_ID_HEADER, andENVELOPE_MANAGED_HEADERS(frozenset).envelope.py— per-key read/write sites use the constants (descriptive error-message prose left as-is); adds amessageimport (leaf → model, no cycle).parser.py— the twoheaders.get(...)reads use the constants.subscriber/usecase.py— the relay strip loop iteratesENVELOPE_MANAGED_HEADERS.Adding a managed key is now a one-line edit instead of three. Behavior-preserving; the constants are internal (not exported).
Verification
just test— 599 passed, Postgres 17, coverage 100.00%just lint— ruff + ty clean🤖 Generated with Claude Code