Skip to content

Split GpgIdGeneration::accept and RealPass::finished - #2427

Merged
annejan merged 1 commit into
mainfrom
refactor/complexity-2157-b6
Dec 1, 2026
Merged

annejan merged 1 commit into
mainfrom
refactor/complexity-2157-b6

Conversation

@annejan

@annejan annejan commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #2157, batch 6. Only the structure changes: the extracted code is moved as it was, comments included.

Function CCN before after New
GpgIdGeneration::accept 23 4 acceptAgainstRecord() (14), conflictingList() (2)
RealPass::finished 23 11 finishRecipientRun() (13)
  • accept() keeps the header and folder checks. Then acceptAgainstRecord() checks the list against what this device accepted before (store ID, generation, digest).
  • The same-generation refusal moves to conflictingList(), next to staleList(), which already holds the older-generation refusal.
  • Transaction gets three small methods:
    • accepted(), which was the generation == last && t.digest(k) == bytes argument to ofThisStore();
    • noteOnce(), the generation-0 note;
    • pinOnFirstSight(), which replaces the pinHere lambda. It reads store(key) instead of the captured pinned, which is the same value: nothing pins between the two reads.
  • RealPass::finished() hands the pass init/mv/cp branch to finishRecipientRun().

Test plan

  • qmake6 -r CONFIG+=rnp && make -j12 && make check in a scratch HOME/GNUPGHOME: 37 suites, 2,079 passed, 0 failed
  • doxygen Doxyfile: no warnings
  • lizard -C 14 shows no new warnings in these two files

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Recipient-list updates are now checked against the recorded generation, contents, and store before acceptance, helping prevent stale or conflicting changes from being applied.
    • pass init, move, and copy operations now handle re-encryption and post-commit failures more consistently. Automatic pushes are held when an operation fails and deferred pushes are handled after completion.
    • Successful initialization releases its push hold, and scoped operations report changes that have not been recorded.

Part of #2157. Behaviour-preserving extractions, comments moved verbatim:

- GpgIdGeneration::accept (CCN 23 to 4) keeps the header and folder
  checks; acceptAgainstRecord() (14) checks the list against the record.
  The same-generation refusal moves to conflictingList(), next to
  staleList(). Transaction gains accepted(), noteOnce() and
  pinOnFirstSight(), which replaces the pinHere lambda.
- RealPass::finished (CCN 23 to 11): the pass init/mv/cp branch moves to
  finishRecipientRun() (13).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anne Jan Brouwer <[email protected]>
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add recorded-generation and store-identity checks to GPG ID acceptance. They also move init, move, and copy completion handling in RealPass into a private helper.

Changes: GPG ID generation acceptance

Layer / File(s) Summary
Recorded generation acceptance
src/gpgidgeneration.h, src/gpgidgeneration.cpp
GpgIdGeneration now checks recorded generations, digests, and store identity. It records generation 0 only once, pins an available store ID when none is pinned, and returns conflicts or RecordUnavailable when applicable.

Recipient-run completion

Layer / File(s) Summary
Recipient-run completion flow
src/realpass.h, src/realpass.cpp
RealPass::finished delegates init, move, and copy completion to finishRecipientRun. The helper handles re-encryption failures, push holds, successful init release, Git reporting, deferred pushes, and completion forwarding.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • Issue 2157 tracks reducing cyclomatic complexity in GpgIdGeneration::accept and RealPass::finished. This PR extracts helpers from both functions, matching that objective; the issue also lists other functions not changed here.

Suggested reviewers: nogeenhenk

Merge Risk: Minimal · up to 2c15d

This change splits two large functions into smaller helpers and is intended to preserve behavior. No actionable merge-blocking risk was found, and the reported test run passed.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Split GpgIdGeneration::accept and RealPass::finished" names the two functions that the PR refactors. The changeset moves record-based acceptance into acceptAgainstRecord and conflict report…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Split GpgIdGeneration::accept and RealPass::finished" names the two functions that the PR refactors. The changeset moves record-based acceptance into acceptAgainstRecord and conflict reporting into conflictingList in GpgIdGeneration, and it moves the pass init/mv/cp branch of RealPass::finished into finishRecipientRun. The title is specific and accurate, and it reflects the main structural change described in the PR objectives.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each generation with care,
And pins a store ID when one is there.
A clean init lets held pushes go,
While deferred changes find their flow.
Then hops away through fields of snow.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7ffb37a9-7dbb-4511-99e7-fb76a8775ab8
Commits

Reviewing files that changed from the base of the PR and between 30c9f40 and 2c15d9b.

Files selected for processing: 4

  • src/gpgidgeneration.cpp
  • src/gpgidgeneration.h
  • src/realpass.cpp
  • src/realpass.h

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.554% (+0.005%) from 94.549% — refactor/complexity-2157-b6 into main

@nogeenhenk nogeenhenk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 2c15d9b. GpgIdGeneration::accept is the rollback and store-pin check, so I compared it branch by branch with the old function:

  • accepted() is the old generation == last && t.digest(k) == bytes, the optional digest included (no digest is not accepted).
  • noteOnce() is the old known(k) || remember(k, 0, ...) for generation 0.
  • pinOnFirstSight() reads store(storeKey) where the lambda used the pinned read at the top. That is the same value: the pins live in entries->stores, and the only write before it in each branch, remember(), writes entries->lists. In the last branch the pin still comes before remember(), as the comment requires.
  • The order is unchanged: wrong store, stale, generation 0, same generation (conflict, then accept), new generation. conflictingList() has the old message and verdict.
  • RealPass::finishRecipientRun() is the old pass init/mv/cp branch as it was, holds and releases in the same order.

Nothing to add.


Generated by Claude Code

@annejan
annejan merged commit 5f3fa93 into main Dec 1, 2026
33 checks passed
@annejan
annejan deleted the refactor/complexity-2157-b6 branch December 1, 2026 03:44
@annejan annejan mentioned this pull request Dec 1, 2026
29 of 40 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants