feat(natsmsg): add DeadLetter dead-letter capture

main

Commit

Andrea Nodari4mo ago

Lift DeadLetter + SubjectToken (with the Nats-Dlq-* provenance headers and the DLQPublisher surface) into go-nuts/natsmsg from entiredb — the last message-layer helper the services still kept locally (COR-929).

DeadLetter is the capture step a consumer runs before giving up on a poison message: it copies the payload + headers to a DLQ subject with provenance (reason, origin subject, delivery count, stream seq) so the give-up is auditable and replayable, and the caller then removes the original — a Term on final delivery (backoff.Policy.TermOnExhaustion, whose doc already points callers to "DLQ capture before calling NakOrTerm") or a plain Ack.

SubjectToken sanitizes a free-text reason into a valid NATS subject token so the DLQ subject is always publishable. Both are lifted verbatim (generic already — subject/reason/publisher are all caller-supplied), with the doc reworded to match backoff's WorkQueue framing. entiredb adopts these in a follow-up that retires its internal/natsmsg + internal/natsx.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Claude-Session: https://claude.ai/code/session_01SaRU2JqekvT4WdyXoqiCBx