You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[deep-review][duplication] D4: _useV2Signature fallback state machine duplicated across operator and node clients #367
The v3→v2 signature fallback (see also C10) is implemented twice — once in OpenClawGatewayClient, once in WindowsNodeClient — with the same three-piece state (flag declaration, set-on-error, read-on-connect).
The base class WebSocketClientBase exists and is the natural home for shared connection state, but currently only owns the WS transport and reconnect backoff.
Why it matters
Three concrete problems:
Future drift risk. If C10 (reset-after-N-successes) is implemented in one client but not the other, the operator and node would have different downgrade behaviours for the same gateway. The two clients share an identity directory and a v2 flag in GatewayConnectionManager._gatewayNeedsV2Signature, so a divergent client implementation introduces subtle staleness.
Test surface is doubled. Every signature-fallback test currently covers one client; the other might silently drift.
Audit cost. A security reviewer looking at the v3-to-v2 fallback has to read both implementations and verify they agree.
Proposed fix
Lift the state to WebSocketClientBase (or a small SignatureNegotiationState helper):
protectedboolUseV2Signature{get;privateset;}protectedvoidOnSignatureRejected();// bumps state machineprotectedvoidOnHandshakeSucceeded();// resets counters, may probe v3 again
Both OpenClawGatewayClient and WindowsNodeClient call the protected method on error / success. The state machine (including C10's reset-after-N-successes) lives in one place.
Make the migration in two PRs:
Land the helper; have both clients call it without changing behaviour.
Implement C10's reset-after-N-successes inside the helper. Both clients get the fix.
Severity
Low — duplication that becomes Medium when C10 is addressed (because the fix would have to be done twice otherwise).
The pull request was not created — a fallback review issue was created instead due to protected file changes: #431
🤖 This is an automated response from Repo Assist.
Good analysis. A two-step migration is the right call here — it avoids introducing risk before the behaviour is proven stable.
A concrete sketch for step 1 using an inner type in WebSocketClientBase:
// WebSocketClientBase.csprotectedsealedclassSignatureNegotiationState{privatevolatilebool_useV2;publicboolUseV2=>_useV2;/// Call when the gateway rejects the v3 signature.publicvoidOnRejected()=>_useV2=true;/// Call on each successful authenticated handshake./// Returns true when the state was reset (useful for logging).publicboolOnHandshakeSucceeded(){if(!_useV2)returnfalse;_useV2=false;returntrue;}}protectedreadonlySignatureNegotiationStateSignatureNegotiation=new();
Both OpenClawGatewayClient and WindowsNodeClient can replace their _useV2Signature field with SignatureNegotiation.UseV2 / .OnRejected() / .OnHandshakeSucceeded(). The state machine is now in one place.
One thing to be aware of: _useV2Signature currently lives as a per-instance bool, but GatewayConnectionManager._gatewayNeedsV2Signature is a separate field that acts as a persistent memo across reconnects. Make sure step 1 doesn't silently drop that cross-reconnect persistence — the per-instance state in SignatureNegotiationState should be re-seeded from GatewayConnectionManager on each reconnect, the same way the existing booleans are today.
For step 2 (C10: reset-after-N-successes), the OnHandshakeSucceeded method is the natural place to add a counter.
Closing during the post-refactor deep-review cleanup. This duplicates the v3/v2 fallback concern tracked by #350 and #372. This keeps the signal while reducing stale one-off issue noise.
Activity
github-actions commentedon May 17, 2026
Note
The pull request was not created — a fallback review issue was created instead due to protected file changes: #431
🤖 This is an automated response from Repo Assist.
Good analysis. A two-step migration is the right call here — it avoids introducing risk before the behaviour is proven stable.
A concrete sketch for step 1 using an inner type in
WebSocketClientBase:Both
OpenClawGatewayClientandWindowsNodeClientcan replace their_useV2Signaturefield withSignatureNegotiation.UseV2/.OnRejected()/.OnHandshakeSucceeded(). The state machine is now in one place.One thing to be aware of:
_useV2Signaturecurrently lives as a per-instance bool, butGatewayConnectionManager._gatewayNeedsV2Signatureis a separate field that acts as a persistent memo across reconnects. Make sure step 1 doesn't silently drop that cross-reconnect persistence — the per-instance state inSignatureNegotiationStateshould be re-seeded fromGatewayConnectionManageron each reconnect, the same way the existing booleans are today.For step 2 (C10: reset-after-N-successes), the
OnHandshakeSucceededmethod is the natural place to add a counter.shanselman commentedon May 18, 2026
Closing during the post-refactor deep-review cleanup. This duplicates the v3/v2 fallback concern tracked by #350 and #372. This keeps the signal while reducing stale one-off issue noise.