Skip to content

refactor(primitives): [#2823] remove unused AddAssign for AggregateActiveSwarmMetadata - #2827

Merged
josecelano merged 4 commits into
torrust:developfrom
josecelano-bot:2823-addassign-aggregate-swarm-metadata
Nov 11, 2026
Merged

josecelano merged 4 commits into
torrust:developfrom
josecelano-bot:2823-addassign-aggregate-swarm-metadata

Conversation

@josecelano-bot

@josecelano-bot josecelano-bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2823

Removes impl AddAssign for AggregateActiveSwarmMetadata from packages/primitives. Nothing uses it: the registry and the torrent-repository-benchmarking repositories sum the aggregate fields by hand.

This removes one unused copy of an unchecked u64 +=. The live summations keep the same behaviour (panic in debug, wrap in release); that is practically unreachable and out of scope. Removing a public impl is a breaking change for the publishable torrust-tracker-primitives crate (3.1.0): its next publish is already a major version because of the Peer: Ord removal (#2798).

Verification: with the impl removed, cargo check --workspace --all-targets --all-features and cargo test --doc --workspace pass (stable toolchain), and linter all passes. The PR also adds the issue spec and the addassign dictionary word.

Related to EPIC #1347.

🤖 Generated with Claude Code

…egateActiveSwarmMetadata

Nothing uses the impl: the registry and the benchmarking repositories sum the
aggregate fields by hand. Removing it also removes the silent release-mode
overflow wrap. Adds the issue spec for torrust#2823.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@da2ce7 da2ce7 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 80ac60d7c69be33d87f2f2ab79dabc5943f9ba30. Recomputed from the bytes at this head, against the merge base f8b0f26e9; git merge-tree against develop f2103c0ab writes a clean tree with no conflicts (develop's eight commits since the base change only documents, none of these three files).

Process: a refactor that carries its own issue spec, so create-issue (template docs/templates/ISSUE.md), commit-changes and open-pull-request govern it. Folder name, spec-path, branch and every frontmatter field fit the skill and the frontmatter validator's rules; Closes is the right keyword for a combined PR.

The change against its claim: the impl and its import go, nothing else in the code changes. No .rs file at this head or at f2103c0ab names AddAssign or add_assign, or adds one aggregate to another, so the removal should compile; the registry and the benchmarking get_metrics bodies sum the fields by hand, as stated. No profile sets overflow-checks. The new dictionary word is needed: it appears in lowercase in the folder and branch names, which the spell checker reads.

Consistency: the new file has no Markdown links; its related artifacts and skill link exist; the dictionary stays in LC_ALL=C order with no duplicates.

Hygiene: one commit, author = committer, Conventional subject with [#2823]; git diff --check is clean; the skill's PR-branch commit-id check prints nothing (every id the spec cites is on develop); the closing-keyword pattern matches only Closes #2823 in the description and nothing in the title or the commit message. The commit has one attribution footer line, which no rule in the tree forbids.

Findings: F1 (Major) the Risks bullet calls the crate internal, but it is published at 3.1.0, so the removal is a breaking change. F2 (Minor) two counts and one history statement are wrong. F3 (Minor) the spec's progress records lag what was delivered. F4 (Minor) the EPIC table has no row for this subissue. F5 (Minor) the live summation still wraps in release builds. F6 (Nit) a task addressed to a session rather than a record.

Checked, no finding: the v1 frontmatter shape, the open/ status, spec-path equal to the file path, the three history ids and their subjects, the debug-panic/release-wrap statement, the quoted registry line, the template section order, and the markdown rules (MD013 is off).

Checks

On the loop's compute node at this head, against the merge base f8b0f26e9 (receipt server-gates-kranich-701): the repository's pre-commit gate exit 0 (65 s), clippy-allow-reasons against the base exit 0, and the tree left clean; linter markdown, linter cspell, linter lychee (offline links) exit 0; this PR has no review threads, so no audit record is due. Package tests at this head: cargo test -p torrust-tracker-primitives exit 0 (6 s, 50 passed, none failed). F1 read at this head: packages/primitives/Cargo.toml sets publish.workspace = true and version = "3.1.0", the root sets publish = true, and the first-publish plan (2583-.../ISSUE.md:196) lists the crate as published at 3.0.0 with 4.0.0 owed; the spec's Risks (lines 153-155) call it internal. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-primitives): completed/success; Docker E2E: completed/skipped; Workspace Packaging: completed/success; Layer Boundary Bans: completed/success; Unit (nightly): completed/success; Documented Clippy Allows: completed/success; Shipped Features: completed/success; Unit (stable): completed/success; Test (Docker) (release): in_progress/pending; Build on macos-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on macos-latest (nightly): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (stable): completed/success; Docs Lint: completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: completed/success". At posting, develop is a83f3ef29.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the removal of the unused AddAssign implementation.

No open issues 🎉

What changed in this PR

Removes the unused AddAssign implementation for AggregateActiveSwarmMetadata, resolving #2823 under EPIC #1347. Existing field-by-field aggregation remains unchanged.

Changes:

  • Deletes the unused trait implementation and import, removing its unchecked overflow behavior.
  • Adds an issue specification recording the removal experiment, decision, and duplicated aggregation logic.
  • Adds addassign to the spelling dictionary.
File Description
project-words.txt Adds the addassign dictionary entry.
packages/​primitives/​src/​swarm_metadata.rs Removes the unused AddAssign implementation and import.
docs/​issues/​open/​2823-1347-addassign-aggregate-swarm-metadata/​ISSUE.md Documents the investigation, implementation plan, and verification results.

Review effort: Balanced

Record the breaking-change and major-version consequence, correct the
summation counts and the history, set epic to null like the sibling findings,
tick the checkpoints and acceptance criteria, add the Acceptance Verification
table, note that the live summation keeps the same release-mode wrap, and drop
the task addressed to a session.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

@da2ce7 da2ce7 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 2d9ab29955d0fb6f5f61fe4e8cbcf8072d8e96fb. Recomputed from the bytes at this head, against the previous round's head 80ac60d7c and the merge base f8b0f26e9; git merge-tree against develop f10959fff writes a clean tree with no conflicts (project-words.txt, which develop also changed, merges sorted).

What moved: one commit, 2d9ab2995, a fast-forward of 80ac60d7c. It renames the spec folder (dropping 1347-) and edits only that file; every other path is byte-identical to 80ac60d7c, so the previous round's code conclusions stand.

Previous findings: F1 fixed (Risks, lines 163-169, match the manifests and the Risks of the 2798 spec). F2 fixed (ten get_metrics in eight modules, eleven copies with the registry, plus the test; the history holds). F3 fixed (T1, ticks, related-pr, the table, stable toolchain). F4 fixed (epic: null, folder per create-issue, the old path referenced nowhere here or on develop). F5 partly fixed: the spec and the description now say the live summations keep the wrap, but the body of 80ac60d7c still says the removal removes it, and the merge keeps that commit. F6 fixed (T3 and its criterion dropped).

The new commit: every other claim it adds checks against the bytes.

Hygiene: author = committer, Conventional subject; the body omits the rename that follows from epic: null; one attribution footer line, which no rule in the tree forbids; git diff --check clean; the closing-keyword pattern matches only Closes #2823 in the description.

Findings: F7 (Minor) a progress-log claim the bytes contradict, without a time. F8 (Minor) a PR-branch commit id in the evidence table. F9 (Minor) threads resolved without the review audit record. F10 (Nit) two wording slips. None blocks; the verdict waits for the audit record.

Checked, no finding: the frontmatter against the validator, the ADR and sibling paths here and on develop, Peer without Ord, no += left in swarm_metadata.rs, the table header.

Checks

On the loop's compute node at this head, against the merge base f8b0f26e9 (receipt server-gates-kranich-718): the repository's pre-commit gate exit 0 (107 s), clippy-allow-reasons against the base exit 0, and the tree left clean; linter markdown, linter cspell, linter lychee (offline links) exit 0; no audit record exists at this head, so the repository's audit validator was not run. Package tests at this head: cargo test -p torrust-tracker-primitives exit 0 (50 passed, none failed). F9 read on the forge: all 6 review threads are answered and resolved, and docs/pr-reviews/pr-2827-review/PR-REVIEW.md does not exist at this head. GitHub checks at this head at posting time: "". At posting, develop is f10959fff.

josecelano-bot and others added 2 commits November 11, 2026 13:14
… wording

Fix the progress-log stamps and the claim about the commit body, replace a
branch commit id in the acceptance evidence with the commit subject, and fix
two wording slips (review findings F7, F8 and F10).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@josecelano

Copy link
Copy Markdown
Member

ACK d655b07

@josecelano
josecelano requested a review from da2ce7 November 11, 2026 13:29

@da2ce7 da2ce7 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 d655b07301c210c1a12e950c2638e0fde85093f6. Recomputed from the bytes at this head, against the previous round's head 2d9ab2995 and the merge base f8b0f26e9; git merge-tree against develop b8fac7f7f writes a clean tree with no conflicts.

What moved: two commits on top of 2d9ab2995, a fast-forward: 9d52cc963 edits the spec (+11/-10) and d655b0730 adds the audit record (+186). Every other path is byte-identical to 2d9ab2995.

Previous findings: F7 fixed (the stamps 11:21 and 12:46 are the commit times of 80ac60d7c and 2d9ab2995; the entry says the description was corrected). F8 fixed (the commit-id check prints nothing). F9 fixed: ten rows, each with its source review, its severity bracket, one reply on its own thread and a subject on the branch; the validator's logic, run offline on the capture, reports 0 failures. F10 fixed (spec lines 49, 58 and 180). F5 stays partly fixed, as the spec and the audit now say. F1 to F4 and F6 stay fixed.

The new commits: the five log entries match the forge times; it_should_get_metrics holds the hand sum (tests/repository/mod.rs, lines 410-413); the verification commands of F1, F4, F6 and F10 print what their rows say.

Hygiene: same identity as author and committer, Conventional subjects; d655b0730 holds only the audit, apart from the fixes, and has no body; one attribution footer line each, which no rule in the tree forbids; git diff --check clean.

Findings: F11 (Minor) three stamps run ahead of the commits that carry them. F12 (Minor) the record leaves out template text marked to be copied verbatim. F13 (Nit) three slips in the record. None blocks; all can be repaired after merge.

Checked, no finding: F5's row says FIXED while its Solution states what remains; the AC3 row padding (MD060 is off); the description, unchanged.

Checks

On the loop's compute node at this head, against the merge base f8b0f26e9 (receipt server-gates-kranich-727): the repository's pre-commit gate exit 0 (113 s), clippy-allow-reasons against the base exit 0, and the tree left clean; linter markdown, linter cspell, linter lychee (offline links) exit 0; the repository's audit validator on pr-2827-review exit 0 (10 rows, 5 log entries, no failures). This round's commits change only the spec and the audit record; the package tests of round 2 (cargo test -p torrust-tracker-primitives, 50 passed) stand for the unchanged code. Read on the forge: all 10 review threads are answered and resolved. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-primitives): completed/success; Build on windows-latest (stable): in_progress/pending; Build on windows-latest (nightly): in_progress/pending; Build on macos-latest (nightly): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on macos-latest (stable): completed/success; Build on ubuntu-latest (stable): completed/success; Docker E2E: completed/skipped; Discover Package Coverage: completed/success; Layer Boundary Bans: completed/success; Unit (stable): in_progress/pending; Documented Clippy Allows: completed/success; Unit (nightly): in_progress/pending; Generate Coverage Report: in_progress/pending; Workspace Packaging: completed/success; Shipped Features: completed/success; Docs Lint: completed/success; Test (Docker) (release): in_progress/pending". At posting, develop is 839adf5a0.


- 2026-11-11 11:21 UTC - Claude Code (Sonnet 5.5) - Drafted spec; ran removal experiment (check all targets/features + doctests: pass) and history check. Recommendation: delete.
- 2026-11-11 12:46 UTC - Claude Code (Sonnet 5.5) - Maintainer approved deletion; created #2823 and PR #2827; review round 1 of PR 2827 (da2ce7 F1-F6): recorded the breaking-change/major-version consequence, corrected counts and history, set `epic: null` like #2798/#2804, ticked the checkpoints and criteria, added the Acceptance Verification table, noted that the live summation keeps the same wrap, dropped the session-addressed task, corrected the PR description. The body of the first commit still has the old sentence about the release-mode wrap (not amended: no force-push).
- 2026-11-11 13:15 UTC - Claude Code (Sonnet 5.5) - Review round 2 of PR 2827 (da2ce7 F7-F10): corrected the stamps of the two log entries above, replaced the branch commit id in the AC3 evidence with the commit subject, fixed two wording slips, and added the review audit record `docs/pr-reviews/pr-2827-review/PR-REVIEW.md`.

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.

[Minor][F11] Three stamps run ahead of the commits that carry them

This entry and last-updated-utc (line 12) read 13:15, but 9d52cc963, which carries them, is 13:14:31 UTC, and the audit record the entry reports was authored at 13:17:38 and committed at 13:19:05. In the audit, last-updated-utc (docs/pr-reviews/pr-2827-review/PR-REVIEW.md, line 4) reads 13:25, six minutes after its commit and after the capture's last update of the PR (13:20:52). process-pr-review stamps an event only after it happened and lists a stamp later than its carrying commit as a hand check. Take each stamp from git log --format=%cI of the commit that carries it, and let the audit's own log record its commit.

- Follow-up PR URL: N/A
- Reply URL: https://github.com/torrust/torrust-tracker/pull/2827#discussion_r4538345161

## Processing Log

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.

[Minor][F12] The record leaves out template text marked to be copied verbatim

docs/templates/PR-REVIEW-TEMPLATE.md marks Status Values and Completion Rules "Copied verbatim into each audit record". This record has no ## Completion Rules section (template lines 120-137), and its Status Values (lines 18-27) drop the OPEN sentence and the outdated-thread and viewerCanResolve bullets (template lines 32-34 and 40-46). The Processing Log has no start entry (template line 113); develop b8fac7f7f now asks a record created after the first reply to log its late start. The validator checks none of this. Copy the two sections from the template and append an entry for the record's creation.

- Source URL: https://github.com/torrust/torrust-tracker/pull/2827#discussion_r4538183034
- Concern: The AC3 evidence cites a PR-branch commit id.
- Solution: Valid. The AC3 row cites the commit subject. A search of the spec for other 9-digit hex ids finds only the history commits that are on develop.
- Current-tree verification: grep -n -E "[0-9a-f]{9}" in the spec prints only `9a43815d0`, `144a338b9` and `3d6fc651d`.

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.

[Nit][F13] Three slips in the record

This line says grep -n -E "[0-9a-f]{9}" prints only the three history ids; it prints five lines, because the ADR file name 20260629000000_... matches on spec lines 90, 167 and 189. The conclusion holds: the only commit ids are the three on develop. Line 162 reads "exit code exit 0". Line 33 lists the bot review of 12:08 under round 2; it reviewed the round-1 head, as line 182 says.

@da2ce7

da2ce7 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

ACK d655b07 — the audit record's ten rows match the threads, replies, severities and commit subjects, and the validator's logic passes offline at this head

@josecelano

Copy link
Copy Markdown
Member

ACK d655b07

@josecelano
josecelano merged commit 0bb41a4 into torrust:develop Nov 11, 2026
20 checks passed
josecelano added a commit that referenced this pull request Nov 11, 2026
…ssues/closed

eb5d1ea chore(issues): archive closed issue #2823 spec to docs/issues/closed (josecelano-bot)

Pull request description:

  Related to #2823 (already closed by #2827).

  Archives the spec for issue #2823 from `docs/issues/open/` to `docs/issues/closed/`.

  - Verified #2823 is `CLOSED` on GitHub and PR #2827 is merged
  - Updated frontmatter (`status: done`, `spec-path`, `last-updated-utc`) and the workflow checkpoint
  - Added the archive entry to the progress log and recorded why no retrospective is needed
  - No other document links to the old path (the spec has `epic: null`)
  - Pre-commit hooks passed

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

ACKs for top commit:
  da2ce7:
    ACK eb5d1ea — the spec's move to `docs/issues/closed/`, its frontmatter, checkpoint and archive entry, and the absence of any live reference to the old path recomputed from the bytes at this head
  josecelano:
    ACK eb5d1ea

Tree-SHA512: fe3ba5e16e2a86215239d499b5b5aabf7485902cfae1c441b6a35fb59acdc2e194206fc1332f965d57093a061a94be25f87873ae3f52647b7785d2f2af57d449
josecelano added a commit that referenced this pull request Nov 11, 2026
7d97ede docs(pr-reviews): [#2824] record the review of PR 2834 round 2 (josecelano-bot)
2ea19f2 docs(pr-reviews): [#2824] name the PR 2834 heads by commit subject (josecelano-bot)
eabfece docs(pr-reviews): [#2824] record the review of PR 2834 round 1 (josecelano-bot)
eca4076 docs(issues): [#2824] record the prose-first AAA review of the PeerRole tests (josecelano-bot)
1336f57 docs(issues): [#2824] stamp the S1 records no later than their commits (josecelano-bot)
1fd6c86 docs(issues): [#2824] record the S1 coverage measurement and the EPIC update (josecelano-bot)
2830e77 docs(issues): [#2824] update the spec tracking state after S0 merged (josecelano-bot)
fa59efb docs(issues): [#2824] add the manual verification evidence for the S1 fix (josecelano-bot)
01eafe9 test(primitives): [#2824] compare the PeerRole JSON with its Display form (josecelano-bot)
0f785bb docs(issues): [#2824] record the S1 PeerRole fix in the spec (josecelano-bot)
fe6278f fix(primitives): [#2824] serialize PeerRole in lowercase (josecelano-bot)
17595ab test(primitives): [#2824] pin the lowercase JSON form of PeerRole (josecelano-bot)

Pull request description:

  ## Summary

  Slice S1 of #2824 (EPIC #1347): the one defect the maintainer decided to fix inside the `primitives` tests issue (finding F2).

  `PeerRole` derived `Serialize` with `#[serde(rename_all_fields = "lowercase")]`, an attribute that only applies to the fields of struct-like variants. The unit variants therefore serialized as `"Seeder"` and `"Leecher"`, while `Display` and the `peer_role` metric label use `seeder` and `leecher`. The attribute is now `rename_all = "lowercase"`.

  ## Commits

  Code and tests (`packages/primitives/src/peer.rs`):

  1. `test(primitives): [#2824] pin the lowercase JSON form of PeerRole` — two regression tests that fail on this commit (`"Seeder"` and `"Leecher"` instead of lowercase).
  2. `fix(primitives): [#2824] serialize PeerRole in lowercase` — the one-attribute fix; the tests pass.
  3. `test(primitives): [#2824] compare the PeerRole JSON with its Display form` — the tests also assert the JSON equals the `Display` string (review finding).

  Issue records (`docs/issues/open/2824-1347-add-tests-primitives/` and the EPIC):

  4. `docs(issues): [#2824] record the S1 PeerRole fix in the spec` — spec progress.
  5. `docs(issues): [#2824] add the manual verification evidence for the S1 fix` — `manual-verification-evidence.md` with the red, green and head runs.
  6. `docs(issues): [#2824] update the spec tracking state after S0 merged` — slice rows, F2 state, frontmatter.
  7. `docs(issues): [#2824] record the S1 coverage measurement and the EPIC update` — `coverage-evidence.md` and both EPIC "Latest" tables.
  8. `docs(issues): [#2824] stamp the S1 records no later than their commits` — restamp three records.
  9. `docs(issues): [#2824] record the prose-first AAA review of the PeerRole tests` — `test-refactor-plans/s1-peer-role-serialization.md`.

  Review audit (`docs/pr-reviews/pr-2834-review/PR-REVIEW.md`):

  10. `docs(pr-reviews): [#2824] record the review of PR 2834 round 1`
  11. `docs(pr-reviews): [#2824] name the PR 2834 heads by commit subject`
  12. `docs(pr-reviews): [#2824] record the review of PR 2834 round 2`

  ## Verification

  - `cargo test -p torrust-tracker-primitives`: 49 unit tests pass (47 before, plus the 2 new ones), 2 + 1 other tests pass; the red and green runs are in `manual-verification-evidence.md`.
  - Unit-only coverage of the package: lines 62.73%, regions 70.29%, functions 59.49% (`coverage-evidence.md`); part of the gain comes from #2811 and #2827 merging, not only this slice.
  - `validate-audit-record.py --pr-number 2834` reports 0 failures.
  - No other package serializes `PeerRole` to JSON (searched `packages` and `src`).

  ## Notes

  Related to #2824; this PR does not close it (only the last slice does).

  🤖 Generated with [Claude Code](https://claude.com/claude-code)

ACKs for top commit:
  da2ce7:
    ACK 7d97ede — the F9 and F10 fixes and the round 2 audit rows recomputed from the bytes at this head, over a tree otherwise byte-identical to the previously approved head.
  josecelano:
    ACK 7d97ede

Tree-SHA512: 8a1087db3d07ae26ce8b38ba89d9db53c97c705ced41cf4bb81eb46172a278b5d876056c81ef32b392c22e4927877d6559f6a21279314a055b7641de3050aa9e
josecelano-bot added a commit to josecelano-bot/torrust-tracker that referenced this pull request Nov 15, 2026
…gn impl in the F4 row

The F4 row of the Findings Register still said the unused AddAssign impl
of AggregateActiveSwarmMetadata was being deleted. PR torrust#2827 deleted it on
2026-11-11; the row now says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
coverage — d655b073 Deployed Nov 11, 2026 by josecelano-bot via Generate Coverage Report #3060
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.

Remove unused AddAssign impl for AggregateActiveSwarmMetadata

4 participants