Deferred code-shrink candidates from the 2026-06-18 full security-review + shrink pass. Held until after the 1.0 soak — these touch security-critical relay/pairing hot paths, and refactoring them now would reset soak confidence on exactly the files that matter most. All are behaviour-preserving extractions; ship them once 1.0 is out.
The low-risk peripheral dedups from that pass already landed in #337 (parse_body_arg, hex_exact::<N>). The relay DoS-ceiling fixes landed in #336.
Relay (src/relay_server.rs)
Pairing (src/pair_invite.rs)
Trivial single-use inlines (low value, evaluate individually)
These were skipped on "no single-use abstraction" grounds; only take the ones that genuinely improve clarity:
agent_card::max_schema_version (~20 LOC, one caller) — simplify or inline
agent_card::build_agent_card ↔ trust::add_self_to_trust JSON object overlap (~15)
signing.rs [u8;32] validate+copy pattern (~15)
enc/wire_x25519 context_info length-prefix framing helper (~6); nonce-init pattern (~5)
platform.rs line-matching parse helpers (~8); read_wire_home_from_pid env-line parse (~6); parent_pid parse (~5)
same_machine::local_fingerprint (~5); trust::now_iso inline (~4); org_membership::keypair test helper (~4)
config.rs atomic-write-with-lock / lock-path helpers (~8)
group.rs invalidate_signature (epoch++ / sig.clear) (~2)
Context
🤖 Generated with Claude Code
Deferred code-shrink candidates from the 2026-06-18 full security-review + shrink pass. Held until after the 1.0 soak — these touch security-critical relay/pairing hot paths, and refactoring them now would reset soak confidence on exactly the files that matter most. All are behaviour-preserving extractions; ship them once 1.0 is out.
The low-risk peripheral dedups from that pass already landed in #337 (
parse_body_arg,hex_exact::<N>). The relay DoS-ceiling fixes landed in #336.Relay (
src/relay_server.rs)post_event+handle_introshare identical size/quota/dedup/slot-insertion logic (~30 LOC). Extract a commonpost_event_internalhelper. Highest care — both are on the live relay ingest path.well_known_agent_card_a2a+well_known_agentshare nick-parse → handle-lookup → 404 (~25 LOC). Extract the shared lookup; the two differ only in response envelope shape.Pairing (
src/pair_invite.rs)send_pair_drop_ackrepeats the self relay/slot/token resolution-with-fallback logic also present inmaybe_consume_pair_dropandsend.rs::attempt_deliver(3 sites, ~40 LOC). Centralize into one resolver. Trust-adjacent — needs the pairing integration tests as the safety net.Trivial single-use inlines (low value, evaluate individually)
These were skipped on "no single-use abstraction" grounds; only take the ones that genuinely improve clarity:
agent_card::max_schema_version(~20 LOC, one caller) — simplify or inlineagent_card::build_agent_card↔trust::add_self_to_trustJSON object overlap (~15)signing.rs[u8;32]validate+copy pattern (~15)enc/wire_x25519context_infolength-prefix framing helper (~6); nonce-init pattern (~5)platform.rsline-matching parse helpers (~8);read_wire_home_from_pidenv-line parse (~6);parent_pidparse (~5)same_machine::local_fingerprint(~5);trust::now_isoinline (~4);org_membership::keypairtest helper (~4)config.rsatomic-write-with-lock / lock-path helpers (~8)group.rsinvalidate_signature(epoch++ / sig.clear) (~2)Context
🤖 Generated with Claude Code