Repository navigation
Extract NodeState join outcome handlers - #8560
Merged
Amaury Chamayou (achamayou) merged 3 commits intoOct 16, 2026
Merged
Conversation
Move the four join-task outcome branches into private NodeState helpers while retaining scheduling, locking, exception boundaries and terminal returns. Remove the join cognitive-complexity suppressions without changing the checker configuration. Refs #7358 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The extraction preserves behavior, no blocking issues were identified, and CI succeeded at the stated PR head.
0 open findings
What changed in this PR
Refactors NodeState join-response handling to reduce cognitive complexity as part of #7358, without intended behavior changes.
Changes:
- Extracts four private helpers for transport errors, client errors, redirects/unexpected statuses, and trusted completion.
- Removes complexity suppressions while preserving locking, exception handling, and state-transition ordering.
Custom instructions used
Applied .github/copilot-instructions.md and .github/instructions/reviewing.instructions.md as supplied in the review context.
| File | Description |
|---|---|
| src/node/node_state.h | Extracts join-outcome helpers and removes complexity suppressions. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 12, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Max (maxtropets)
approved these changes
Oct 16, 2026
Amaury Chamayou (achamayou)
deleted the
achamayou-join-outcome-extraction
branch
October 16, 2026 10:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
NodeState::initiate_join_unsafescores 125 onreadability-function-cognitive-complexity, against a threshold of 50, with its response callback and processing task at 89 and 61. All three carry baseline suppressions. This PR moves the response-handling branches into helpers so the suppressions can be removed without changing behaviour.Related to #7358. The remaining suppressions are handled in #8561 and #8562.
Implementation summary
Move the interiors of the four outcome branches in the join response task into private
_unsafemembers, verbatim:handle_join_transport_error_unsafe: retryable transport errors, oversize response body, and fatal TLS/protocol failures.handle_join_client_error_unsafe:ODataErrorResponseparsing, theStartupSeqnoIsOldsnapshot-fetch path, and the fatal 4xx path.handle_join_unexpected_status_unsafe: redirect following and the generic non-200 log.complete_join_unsafe: theTRUSTEDcompletion, including snapshot installation, consensus and snapshotter setup, state transitions, and join-timer cancellation.The callback and task lambdas, lock, readiness gate, outer
catch, andTRUSTED/PENDINGdispatch stay in place. Each call site keeps its originalreturn, so early returns inside the helpers have the same effect as before..clang-tidyis unchanged.Measured with clang-tidy 21.1.8 and
IgnoreMacros=true; the repository threshold stays at 50:initiate_join_unsafecomplete_join_unsafehandle_join_client_error_unsafehandle_join_transport_error_unsafehandle_join_unexpected_status_unsafeSafety and compatibility
Internal refactor with no API, wire-format, ledger, or snapshot-format impact. A token comparison against
mainshows the only differences are the removed suppression comments, the four helper signatures, and their call sites. The ledger-secret move, lock scope, exception boundaries, log messages, and the order of all state transitions and side effects are unchanged. A failed snapshot install still cannot reach backup initialization orReady.Validation:
ccf_launchertranslation unit that includesnode_state.hon the merged tree.scripts/ci-checks.shpassed without auto-fix.CLANG_TIDY=ONbuild, unit tests, and the bucket-b recovery and join e2e tests. Required CI must pass again on the current head.