Parent epic: #921
Problem
Host currently exposes identity/topology fields that can be mutated after construction, especially endpoint and host_id. That makes it easy for internal dictionaries, sets, policies, and pools to observe broken identity semantics.
Freezing these fields too early would only hide existing mutation sites. The endpoint replacement flow must exist first, then Host can become immutable for identity/topology from normal driver code.
Desired behavior
Host.host_id is assigned once and is the stable identity.
Host.endpoint is not mutated directly by general driver code.
Host.__eq__ and Host.__hash__ are stable and do not depend on mutable endpoint state.
- Runtime health fields remain mutable: up/down state, conviction policy, reconnection handler, and related connection health state.
- Any remaining topology changes happen through explicit metadata/topology APIs rather than ad hoc field assignment.
Scope
- Remove or guard direct mutation of
Host.host_id and Host.endpoint.
- Update code paths that previously changed host topology fields directly.
- Revisit
Host.__lt__ so ordering is compatible with host-id identity.
- Decide compatibility behavior for legacy
Host == address comparisons.
- Update generated C artifacts if required by Python/Cython source changes.
Acceptance criteria
- Driver code cannot casually mutate
Host.host_id or Host.endpoint.
hash(host) remains stable for the lifetime of the Host object.
- Equality and hash semantics are internally consistent.
- Existing health state mutation continues to work.
- Unit tests cover immutability/guard behavior and compatibility decisions.
Part of #921. Depends on #922 and #923. Related to #867.
Parent epic: #921
Problem
Hostcurrently exposes identity/topology fields that can be mutated after construction, especiallyendpointandhost_id. That makes it easy for internal dictionaries, sets, policies, and pools to observe broken identity semantics.Freezing these fields too early would only hide existing mutation sites. The endpoint replacement flow must exist first, then
Hostcan become immutable for identity/topology from normal driver code.Desired behavior
Host.host_idis assigned once and is the stable identity.Host.endpointis not mutated directly by general driver code.Host.__eq__andHost.__hash__are stable and do not depend on mutable endpoint state.Scope
Host.host_idandHost.endpoint.Host.__lt__so ordering is compatible with host-id identity.Host == addresscomparisons.Acceptance criteria
Host.host_idorHost.endpoint.hash(host)remains stable for the lifetime of theHostobject.Part of #921. Depends on #922 and #923. Related to #867.