Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(plans): update socket client ownership responsibilities

Steven Enamakeld9311b5b3cb4
diff --git a/docs/plans/socket-client-ownership.md b/docs/plans/socket-client-ownership.md
index bd07eac3d8..ee375e4b81 100644
--- a/docs/plans/socket-client-ownership.md
+++ b/docs/plans/socket-client-ownership.md
@@ -31,7 +31,7 @@ need for a second generic protocol implementation.
| Owner | Owns | Must not own |
| --- | --- | --- |
-| `tinyhumans-sdk` | Socket.IO and Engine.IO framing, namespace connect acknowledgement and rejection, JSON/binary payload conversion, acknowledgement wire behavior, close/error events, bounded one-attempt connect, and redirect mechanics. Its public connection API must support a single-attempt mode so an embedding host can supervise reconnects. | OpenHuman status enums, its retry schedule, session-store reads, Sentry policy, or event-bus mapping. |
+| `tinyhumans-sdk` | Socket.IO and Engine.IO framing, namespace connect acknowledgement and rejection, server-assigned namespace id, JSON/binary payload conversion, acknowledgement wire behavior, close/error events, bounded one-attempt connect, and redirect mechanics. Its public connection API must support a single-attempt mode so an embedding host can supervise reconnects. | OpenHuman status enums, its retry schedule, session-store reads, Sentry policy, or event-bus mapping. |
| `openhuman-tinyhumans` | The SDK adapter and registration in `register_all`; translates the SDK connection into the core's generic port contract. It enables the SDK `socket` feature explicitly because its Cargo dependency currently disables SDK defaults and therefore omits the socket module (`crates/openhuman-tinyhumans/Cargo.toml`). | OpenHuman's RPC schemas, `DomainEvent` types, or policy decisions about user-visible connection status. |
| `openhuman-core` | The generic port contract and registry, `SocketManager` facade, consumer-facing RPC and event-bus routing, live credential-provider callback, lifecycle/reconnect policy, queue/ack waiter rules, status and diagnostics, and the existing consumer API. The connection driver calls only the registered port and knows no TinyHumans SDK types or hosted strings. | Socket.IO packet parsing, Engine.IO ping/pong, TinyHumans hostnames/routes, SDK imports, or an SDK workaround copied into core. |
@@ -99,8 +99,10 @@ The public registry shape remains in core; the SDK adapter lives under
report `Connected`: the core currently waits for the Socket.IO namespace
connect acknowledgement and treats its connect-error packet separately.
The SDK port contract must expose namespace-ready and namespace-rejected
- outcomes before the host accepts emits. This status boundary also prevents
- a silent server from leaving the manager permanently `Connecting`.
+ outcomes, plus the server-assigned namespace id, before the host accepts
+ emits. `SocketConnection` currently has no id accessor, while
+ `SocketState.socket_id` is public RPC state. This status boundary also
+ prevents a silent server from leaving the manager permanently `Connecting`.
- The SDK owns generic Engine.IO heartbeat behavior. The host observes its
terminal close/error outcome and applies its reconnect policy. Preserve the
user-visible status, failure classifier, and useful outage duration/count
@@ -152,11 +154,11 @@ TinyHumans adapter smoke test through the SDK.
| `ws_loop_reconnect_tests.rs`: `ws_loop_calls_provider_before_each_attempt`, `ws_loop_escalates_immediately_on_invalid_token_no_refresh`, `ws_loop_retries_with_fresh_token_on_invalid_token`, `ws_loop_bounds_fresh_token_retries_with_rotating_provider`, `decide_after_invalid_token_fresh_token_returns_retry`, `decide_after_invalid_token_same_token_escalates`, `decide_after_invalid_token_provider_error_escalates`, `decide_after_invalid_token_empty_token_escalates` | Keep in core port/supervisor tests. Inject a fake connector that returns structured credential rejection; assert fresh provider reads, exactly one immediate changed-token retry, no retry for unchanged/missing credentials, and no SDK retry behind the supervisor. |
| `ws_loop_reconnect_tests.rs`: `sio_connect_error_invalid_token_classifies_correctly` | Split: SDK verifies it preserves a namespace rejection as a structured error; core test verifies the generic credential-rejected outcome follows terminal/fresh-token policy. Do not match SDK display text in core. |
| `ws_loop_reconnect_tests.rs`: `draining_reports_and_discards_everything_still_queued`, `draining_an_empty_channel_reports_nothing_dropped` | Keep as core manager queue/teardown tests; ensure queued emits from a dead connection are never replayed on a new session. |
-| `ws_loop_reconnect_tests.rs`: `parsed_attempt_fraction_reads_the_reported_bug_shape`, `attempt_line_never_reports_more_attempts_than_its_maximum`, `attempt_line_past_the_threshold_drops_the_denominator_for_the_outage`, `sustained_outage_escalates_exactly_once_across_a_long_streak`, `offline_user_outage_does_not_arm_the_recovery_report`, `reproduces_the_6417_outage_without_either_reported_symptom` | Keep as core observability/reconnect-policy tests. |
+| `ws_loop_reconnect_tests.rs`: `attempt_fraction_parser_reads_the_reported_bug_shape`, `attempt_line_never_reports_more_attempts_than_its_maximum`, `attempt_line_past_the_threshold_drops_the_denominator_for_the_outage`, `sustained_outage_escalates_exactly_once_across_a_long_streak`, `offline_user_outage_does_not_arm_the_recovery_report`, `reproduces_the_6417_outage_without_either_reported_symptom` | Keep as core observability/reconnect-policy tests. |
| `ws_loop_dispatch_and_redirect_tests.rs`: `redirect_warning_is_recorded_once_and_pinned_to_first_hop`, `log_connection_failure_does_not_panic_below_threshold`, `log_connection_failure_does_not_panic_at_and_above_threshold`, `fail_escalate_threshold_is_five`, `sustained_outage_for_network_unreachable_classifies_as_expected`, `sustained_outage_for_tls_handshake_eof_classifies_as_expected`, `sustained_outage_for_actionable_server_error_does_not_classify` | Keep in core host-policy tests, with redirect outcome supplied by the port and the same expected-error classifier inputs. |
| `event_handlers_tests.rs`: `parse_sio_event_accepts_bare_array`, `parse_sio_event_strips_ack_id_prefix`, `parse_sio_event_defaults_data_to_null_when_missing`, `parse_sio_event_returns_none_for_garbage`, `parse_sio_event_returns_none_when_first_element_is_not_string`, `parse_sio_event_returns_none_when_json_invalid` | Move payload argument conversion tests to SDK. Delete the OpenHuman raw-string parser. |
-| `event_handlers_tests.rs`: all remaining tests (`base64_encode_*`; `handle_sio_event_*`) | Keep in core. These cover webhook response payload encoding, status/event policy, channel validation, and safe/redacted application logging, independent of the protocol library. |
-| `manager_tests.rs`: all tests | Keep in core as generic `SocketManager`/port tests. Preserve no-plaintext-remote rejection, disconnected/connected state, emit readiness and teardown serialization, ACK timeout/cancellation, idempotent stop, loop join deadline, identity rebind, event bridge safety, webhook-router attachment, and empty-token validation. Replace test-only assumptions about encoded SIO wire strings with fake-port calls. |
+| `event_handlers_tests.rs`: `base64_encode_round_trips_ascii`, `base64_encode_handles_empty_string`, `base64_encode_handles_json_body`, `handle_sio_event_ready_sets_connected`, `handle_sio_event_error_sets_error_status`, `handle_sio_event_debug_truncation_respects_utf8_boundary`, `handle_sio_event_unknown_event_is_noop_on_status`, `handle_sio_event_channel_message_missing_channel_is_dropped`, `handle_sio_event_channel_message_empty_text_is_dropped`, `handle_sio_event_payload_redacted_no_panic_on_multibyte_boundary` | Keep in core. These cover webhook response payload encoding, status/event policy, channel validation, and safe/redacted application logging, independent of the protocol library. |
+| `manager_tests.rs`: `connection_rejects_plaintext_remote_socket_before_starting_loop`, `new_manager_is_disconnected_with_no_sid`, `default_impl_matches_new`, `is_connected_tracks_status_transitions`, `get_state_reflects_stored_sid_and_status`, `get_state_surfaces_stored_error_to_callers`, `emit_without_connection_errors_without_panic`, `emit_while_connecting_errors_even_with_emit_channel_present`, `emit_when_connected_queues_the_encoded_event`, `emit_does_not_land_on_a_reconnects_pre_handshake_channel`, `emit_still_succeeds_after_server_error_on_live_connection`, `emit_cannot_send_past_a_concurrent_teardown_drain`, `emit_with_ack_without_connection_errors_without_waiting`, `emit_with_ack_uses_emit_queue_while_connecting`, `disconnect_on_fresh_manager_is_idempotent`, `a_timed_out_socket_loop_is_aborted_and_joined`, `identity_rebind_transactions_are_serialized`, `emit_state_change_is_safe_to_call_on_empty_shared`, `emit_server_event_is_safe_without_subscribers`, `set_webhook_router_populates_the_shared_slot`, `set_webhook_router_overwrites_previous_router`, `emit_after_disconnect_errors_not_connected`, `connect_rejects_empty_token_and_returns_err` | Keep in core as generic `SocketManager`/port tests. Preserve no-plaintext-remote rejection, disconnected/connected state, emit readiness and teardown serialization, ACK timeout/cancellation, idempotent stop, loop join deadline, identity rebind, event bridge safety, webhook-router attachment, and empty-token validation. Replace test-only assumptions about encoded SIO wire strings with fake-port calls. |
| `ops_tests.rs`: `a_redundant_session_connect_reuses_the_live_socket`, `a_token_refreshed_mid_loop_updates_the_recorded_identity`, `a_session_connect_with_a_different_token_still_rebinds`, `is_live_for_is_scoped_to_url_and_token_and_cleared_on_disconnect`, `a_session_connect_during_the_boot_handshake_does_not_restart_it`, `a_connecting_status_with_no_live_loop_is_not_treated_as_serving` | Keep in core port tests with a fake connector that can pause before ready and count attempts. Preserve identity serialization and no duplicate live connection. |
| `url_tests.rs`, `token_provider_tests.rs`, `types_tests.rs`, `schemas_tests.rs`, `platform/connectivity/rpc_tests.rs`, `services_tests.rs` | Keep and update only where the port changes. These pin endpoint safety/resolution, credential callback semantics, stable renderer event names, controller/RPC contract, connectivity diagnostics, and `ServiceSet::socketio` boot policy. |