Drop over-length values from the peer envelope instead of refusing the record #180

Merged
piers merged 1 commit from fix/179-long-address-invalid into main 2026-11-04 02:10:55 +00:00

Summary

One envelope value over 320 characters blocked the Mail peer v1 snapshot on mailmind-piers for good. The operator ruled direction 3 on #179: such a value is not an address.

 _peer_envelope(from, to, cc)            # write: new add events and the projection
   filter each field with _PEER_ADDRESS
-  oversize if any address > 320 chars, > 1,024 addresses or > 32,768 bytes
+  drop any value > 320 chars, like any other invalid address
+  oversize only if > 1,024 addresses or > 32,768 bytes

 peer_changes / peer_snapshot            # read
-  oversize row: envelope NULL, so record_too_large
+  oversize row up to 131,072 chars: re-filter its stored envelope
+    servable now: serve it (feed and snapshot get the same value)
+    still oversize, or past the bound: record_too_large, as before
  • peer_events is immutable, so rows stored under the old rule stay as written. The re-filter reads only the stored envelope, never messages rows (#152 criterion 2).
  • contracts/mind-v1/README.md and ADR 0012 rule 3 now state the rule. The wire schema is unchanged: every served address is still at most 320 characters.

Evidence

  • Before: a projection row stored oversize for one 361-character To address returns record_too_large on every snapshot page call. The cursor never advances.
    After: test_legacy_long_address_row_is_served_without_it serves that row with the value dropped, and the snapshot completes. test_legacy_long_address_event_is_served_without_it reads one legacy entity through the feed and the snapshot, and both return the same envelope.
  • test_peer_envelope_drops_long_address: 320 characters kept, 321 and 361 dropped, from from, to and cc.
  • test_legacy_oversize_row_past_read_bound_stays_refused: a stored envelope over 131,072 characters stays record_too_large.
  • make check: 1395 passed, 18 deselected; ruff, mypy --strict and pip-audit clean.

Merge Danger

Door: two-way

No schema change and no stored row is rewritten. A revert restores the old refusal.

Blast Radius: peer-consumers

People Mind receives envelopes with an over-length value removed, where it used to get record_too_large. People Mind's copy of the contract README still states the old 320-character rule.

Closes #179

🤖 Generated with Claude Code

## Summary One envelope value over 320 characters blocked the Mail peer v1 snapshot on mailmind-piers for good. The operator ruled direction 3 on #179: such a value is not an address. ```diff _peer_envelope(from, to, cc) # write: new add events and the projection filter each field with _PEER_ADDRESS - oversize if any address > 320 chars, > 1,024 addresses or > 32,768 bytes + drop any value > 320 chars, like any other invalid address + oversize only if > 1,024 addresses or > 32,768 bytes peer_changes / peer_snapshot # read - oversize row: envelope NULL, so record_too_large + oversize row up to 131,072 chars: re-filter its stored envelope + servable now: serve it (feed and snapshot get the same value) + still oversize, or past the bound: record_too_large, as before ``` - `peer_events` is immutable, so rows stored under the old rule stay as written. The re-filter reads only the stored envelope, never `messages` rows (#152 criterion 2). - `contracts/mind-v1/README.md` and ADR 0012 rule 3 now state the rule. The wire schema is unchanged: every served address is still at most 320 characters. ## Evidence - **Before:** a projection row stored oversize for one 361-character To address returns `record_too_large` on every snapshot page call. The cursor never advances. **After:** `test_legacy_long_address_row_is_served_without_it` serves that row with the value dropped, and the snapshot completes. `test_legacy_long_address_event_is_served_without_it` reads one legacy entity through the feed and the snapshot, and both return the same envelope. - `test_peer_envelope_drops_long_address`: 320 characters kept, 321 and 361 dropped, from `from`, `to` and `cc`. - `test_legacy_oversize_row_past_read_bound_stays_refused`: a stored envelope over 131,072 characters stays `record_too_large`. - `make check`: 1395 passed, 18 deselected; ruff, mypy --strict and pip-audit clean. ## Merge Danger **Door:** two-way No schema change and no stored row is rewritten. A revert restores the old refusal. **Blast Radius:** peer-consumers People Mind receives envelopes with an over-length value removed, where it used to get `record_too_large`. People Mind's copy of the contract README still states the old 320-character rule. Closes #179 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Drop over-length values from the peer envelope instead of refusing the record
All checks were successful
ci/woodpecker/pr/validation Pipeline was successful
54919565a7
A value over 320 characters is not an address. The peer envelope now drops it like any other invalid address, so only the 1,024-address and 32,768-byte field caps make a record oversize. One such value blocked the Mail peer v1 snapshot on mailmind-piers for good.

Rows stored oversize under the old rule stay as written: peer_events is immutable. The feed and snapshot reads re-filter them from the stored envelope, up to 131,072 characters, so both serve the same value and a page stays bounded.

Amend the contract cap paragraph and ADR 0012 rule 3 to match.

Refs #179

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
piers merged commit fad5553321 into main 2026-11-04 02:10:55 +00:00
piers deleted branch fix/179-long-address-invalid 2026-11-04 02:10:55 +00:00
Sign in to join this conversation.
No description provided.