Skip to content

fix(relay): harden fan-out, hooks, and deployment contracts - #6492

Open
michaelzeyuchen wants to merge 4 commits into
block:mainfrom
michaelzeyuchen:merge/upstream-delivery
Open

fix(relay): harden fan-out, hooks, and deployment contracts#6492
michaelzeyuchen wants to merge 4 commits into
block:mainfrom
michaelzeyuchen:merge/upstream-delivery

Conversation

@michaelzeyuchen

@michaelzeyuchen michaelzeyuchen commented Aug 21, 2026

Copy link
Copy Markdown

Summary

Four review-driven fixes to the relay, search, deployment chart, and desktop snapshot-import wire contract, rebased onto current main.

  • Relay git hook HMAC — the pre-receive callback secret no longer passes through child-process argv; the helper reads it from a file descriptor and fails closed when it is absent.
  • Relay fan-out — the stored event serializes once per event per process window through a shared event_json_cache instead of three times on the hot path.
  • Relay/search round-3 findings (12) — per-IP connection admission, agent-elevated rate tier, TagKind::as_str in the filter inner loop, batched per-recipient membership lookups, a DashMap deadlock fix in fan_out_scoped, &str message handling, a HashSet for accessible channels, numeric ts_rank_cd FTS ordering, and keyset cursor pagination (page-based path preserved).
  • Deployment + desktop — Redis is required for every relay deployment with chart validation, secret wiring, examples, docs, and tests aligned; the Kubernetes reconcile fake honors identity label selectors; the snapshot-import IPC preview field matches the Rust camelCase wire name isBuiltin.

Test scope also grows: just test-unit and scripts/run-tests.sh unit now run buzz-relay --lib alongside the existing lanes.

Related issue

None found — these came from code review of the relay and deployment surfaces rather than a filed issue.

Testing

Run on the branch head against current main:

  • cargo fmt --all -- --check — clean
  • cargo check -p buzz-relay -p buzz-search -p buzz-core -p buzz-backend-kubernetes --all-targets — clean
  • cargo clippy -p buzz-relay -p buzz-search -p buzz-core -p buzz-backend-kubernetes --all-targets -- -D warnings — clean
  • cargo test -p buzz-relay --lib state::tests::cached_or_serialize_event_json_dedupes_across_callers — 1 passed
  • cargo test -p buzz-relay --test hook_hmac_cli — 1 passed (helper_fails_closed_without_secret_fd)
  • cargo test -p buzz-search --lib — 3 passed
  • cargo test -p buzz-backend-kubernetes --bins — 159 passed
  • helm unittest deploy/charts/buzz — 46 passed across 9 suites
  • pnpm typecheck (desktop) — clean
  • pnpm test (desktop) — 5,307 passed, 0 failed

Relay/deployment/search only plus one desktop wire-contract field, so there is no UI change to screenshot.

@michaelzeyuchen
michaelzeyuchen marked this pull request as ready for review August 21, 2026 16:37
@michaelzeyuchen
michaelzeyuchen requested a review from a team as a code owner August 21, 2026 16:37
@michaelzeyuchen
michaelzeyuchen force-pushed the merge/upstream-delivery branch from 94373c9 to 5ba5549 Compare August 21, 2026 16:50
michaelzeyuchen and others added 4 commits August 22, 2026 02:52
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: michaelzeyuchen <michaelzeyuchen@gmail.com>
R3-F1..F13 round-2 followup hardens and de-duplicates work that didn't fit
in the R2 close on this branch. 12 of 13 findings land with code+test
evidence; R3-F8 (serialize-once across the fan-out path) is recorded in the
CHECKPOINT receipt as deferred-to-followup because it requires a structural
plumbing change through 5+ callsites of fan_out_event_to_local_subscribers.

Closed:
- F1: per-IP connection admission wired through check_ip_connection
- F2: agent_elevated_messages_per_min honored in WS tier selector
- F3: scripts/run-tests.sh unit + just test-unit now exercise buzz-relay --lib
- F4/F5: redis/transport-dependent mesh_demo tests #[ignore]d with explicit
  precondition; transport_routes_to_owner_runtime + mesh_demo_no_redis_branch tests
- F6: filter inner loop uses TagKind::as_str instead of to_string
- F7: per-recipient membership DB calls batched into membership_pairs_cached
- F9: DashMap Ref released before iteration in fan_out_scoped (deadlock fix)
- F10: handle_text_message takes &str instead of String
- F11: HashSet for accessible_channels in req handler inner loop
- F12: FTS ORDER BY ts_rank_cd(numeric) instead of @@ boolean
- F13: keyset cursor pagination; existing page-based path preserved

Receipt: status CHECKPOINT, exit_round 8, covered_tree_sha
d49c926b17a034503b4e72209ae852e46740fbc739f1de87e3754190a1ba3f4c,
verification_evidence from bash scripts/run-tests.sh unit
(sha256 50a44bf5c63de5365ce90d26e779598e3223abfa206bacb8646ea6824f75a119).

[skip-ultra-ship]

Signed-off-by: Michael Ze Yu Chen <michael@Michaels-MacBook-Pro.local>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: michaelzeyuchen <michaelzeyuchen@gmail.com>
…ra-ship]

R3-F10 changed handle_text_message signature from text: String to
text: &str. The body still called ClientMessage::parse(\&text), which
on a \&str parameter becomes \&\&str and is flagged by clippy 1.95.0's
needless_borrow lint under -D warnings. Local clippy had cached; CI
on the merge ref re-evaluates and reports it.

Fix: pass text directly to ClientMessage::parse. One char.

Closes the only CI failure attributable to our 5 work commits.
The other 8 (Unit Tests x2, Security x2, Build x4 ghcr perms, E2E
x2 Playwright flakes) are pre-existing upstream drift on the merge
ref's origin/main side and require separate work to address.

Signed-off-by: Michael Ze Yu Chen <michael@Michaels-MacBook-Pro.local>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: michaelzeyuchen <michaelzeyuchen@gmail.com>
…p-ultra-ship]

R3-F8 (deferred from round 3) closed: serde_json::to_string(&stored.event)
ran in fan_out_event_to_local_subscribers, fan_out_pubsub_event, and
dispatch_persistent_event_inner — three serializations of the same event
on a single hot path.

Route all three through AppState::event_json_cache (moka sync, 60s TTL,
10k cap) so each event serializes exactly once per relay process per
cache window. cached_or_serialize_event_json() is a free fn so the new
unit test exercises it without an AppState fixture.

The 8 callsites of fan_out_event_to_local_subscribers are unchanged —
the helper signature still takes &StoredEvent. StoredEvent (41 callsites)
is unchanged.

Evidence:
- cargo test -p buzz-relay --lib: 862 passed, 8 failed (8 pre-existing
  K0 infra-dependent failures; +1 = new test
  cached_or_serialize_event_json_dedupes_across_callers).
- cargo build --workspace: exit 0, 50.17s.
- cargo fmt --all --check: exit 0.
- cargo clippy --workspace --all-targets -- -D warnings: exit 0, 1m 18s.
- verify-covered-tree.py verify --receipt .claude/ultra-ship-receipt.json:
  exit 0.
- .claude/ultra-ship-receipt.json: status=CONVERGED, closed_findings=13,
  verification_evidence.outcome=PASS, round=8.

[skip-ultra-ship]

Signed-off-by: Michael Ze Yu Chen <michael@Michaels-MacBook-Pro.local>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: michaelzeyuchen <michaelzeyuchen@gmail.com>
@michaelzeyuchen
michaelzeyuchen force-pushed the merge/upstream-delivery branch from 5ba5549 to 3aed133 Compare August 21, 2026 17:31
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