Skip to content

refactor(message): name the envelope-managed header keys#143

Merged
lesnik512 merged 1 commit into
mainfrom
refactor/name-envelope-managed-headers
Jul 17, 2026
Merged

refactor(message): name the envelope-managed header keys#143
lesnik512 merged 1 commit into
mainfrom
refactor/name-envelope-managed-headers

Conversation

@lesnik512

Copy link
Copy Markdown
Member

What

content-type and correlation_id were duplicated as bare string literals across three modules that share an unnamed contract:

  • envelope.py (_encode_payload) writes them, with conflict detection
  • parser.py (OutboxParser.parse_message) reads them back
  • subscriber/usecase.py (_maybe_propagate_inbound_headers) strips them on the relay path

From the architecture-deepening review (candidate #6). Defines the managed-key set once in message.py — the neutral wire-contract home, alongside the sibling DLQFailureReason — and repoints all five literal sites.

Changes

  • message.pyCONTENT_TYPE_HEADER, CORRELATION_ID_HEADER, and ENVELOPE_MANAGED_HEADERS (frozenset).
  • envelope.py — per-key read/write sites use the constants (descriptive error-message prose left as-is); adds a message import (leaf → model, no cycle).
  • parser.py — the two headers.get(...) reads use the constants.
  • subscriber/usecase.py — the relay strip loop iterates ENVELOPE_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 test599 passed, Postgres 17, coverage 100.00%
  • just lint — ruff + ty clean

🤖 Generated with Claude Code

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>
@lesnik512
lesnik512 merged commit 44bb459 into main Jul 17, 2026
7 checks passed
@lesnik512
lesnik512 deleted the refactor/name-envelope-managed-headers branch July 17, 2026 10: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