Forward wire payloads to clients verbatim #28
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
posta/server!28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "forward-wire-payloads-to-clients"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
internal/payloadtranslation entirely (~190 LOC + tests).(
{"kind":"posta.text/v1","body":...},{"kind":"posta.link/v1","url":...})directly. The server treats payload bytes opaquely in both
directions — what clients send is what gets signed on the wire;
what arrives on the wire is what clients see in the DTO.
posta.link/v1must carry an https URL(SPEC §13.3), inlined in
messages.go.CLIENT_API.mdupdated to describe the new contract and pointat SPEC §13 / §13.1.3 for kind discrimination.
Why
The translation was renaming
body→textand wrapping link fieldsin
image: {...}. Clients already had to handle unknown kinds viathe passthrough fallback, so making them handle all kinds the same
way is more honest. It also means new spec-defined kinds work
without server changes, and removes the failure mode where wrap/
unwrap drifts from the spec.
Client follow-up
The TUI (and future iOS) needs to discriminate on `kind` and read
`body`/`url` directly. Not in this repo.
Test plan
The client API previously translated between ergonomic shapes ({"text":"hi"}, {"image":{...}}) and the canonical wire kinds from SPEC §13. Drop the translation entirely: clients now POST and receive spec-canonical payloads ({"kind":"posta.text/v1","body":"hi"}, {"kind":"posta.link/v1","url":"https://..."}) directly. The server treats payload bytes opaquely in both directions. This removes ~190 lines from internal/payload, eliminates the failure mode where wrap/unwrap shape drifts from the spec, and makes new spec-defined kinds work without server changes — clients already had to handle unknown kinds via the passthrough fallback, so making them handle all kinds the same way is more honest. The one ingress check kept is the https-URL invariant for posta.link/v1 (SPEC §13.3), inlined into messages.go. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>Tighten validateWirePayload to reject payloads missing a kind, and also reject posta.link/v1 with an empty url. SPEC §13.1 makes kind a SHOULD, but at our own boundary we make it MUST — the spec-canonical shape is the only shape we'll sign, so receivers never have to fall back to opaque rendering for payloads we produced. Drops the lingering escape hatch where a client could send legacy {"text":"hi"} or any other kind-less blob and have us sign it verbatim. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>