Repository navigation
fix(primitives): [#2824] serialize PeerRole in lowercase - #2834
josecelano merged 12 commits into
Conversation
The two tests fail on purpose: PeerRole serializes as "Seeder" and "Leecher" while its Display and the peer_role metric label use lowercase. The fix follows in the next commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
serde's rename_all_fields only applies to the fields of struct-like
variants, so the unit variants of PeerRole serialized as "Seeder" and
"Leecher". Use rename_all so the JSON form matches Display and the
peer_role metric label ("seeder" and "leecher").
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 0f785bbdf26691353150bd2f21ec7062956b5e51. Recomputed from the bytes at this head, against the merge base efdaf87c9; git merge-tree against develop 815146669 writes a clean merged tree with no conflict (the one change on develop since the base renames the #2823 spec into docs/issues/closed/, disjoint from this diff and not cited by it).
Process: a bug fix inside a test issue, governed by .github/skills/dev/debugging/fix-bug/SKILL.md, .github/skills/dev/testing/write-unit-test/SKILL.md, .github/skills/dev/git-workflow/commit-changes/SKILL.md and .github/skills/dev/git-workflow/open-pull-request/SKILL.md, plus the spec's own Bug-Fix Process. The sequence (red test commit, separate fix commit, spec update) matches T2a; the evidence file both the skill and the spec require is missing (F1).
The change against its claim: rename_all_fields to rename_all on PeerRole makes serde rename the variant names, so the unit variants serialize as "seeder" and "leecher", matching Display (peer.rs lines 56-63) and the peer_role labels hard-coded in swarm-coordination-registry handler.rs lines 204 and 206. Both tests fail at 17595ab, where the old attribute is still present, and pass after fe6278f. Unit tests recompute from 47 to 49; the doctests are two no_run and one compile_fail. No struct in the workspace holds a PeerRole and nothing serializes one, as the description says.
Consistency: the diff adds no link, moves nothing and adds no dictionary word; the three edited table rows keep their header's column count. The slice table, frontmatter and EPIC row are left stale (F2, F3).
Hygiene: three Conventional subjects carrying [#2824]; author equals committer on each; each body matches its diff (the docs commit has none). Each commit ends with one attribution footer naming a model co-author, which no rule in the tree forbids. git diff --check is clean, the skill's PR-branch commit-id check prints nothing, and the closing-keyword scan of the description, title and commit messages finds nothing; Related to #2824 follows the spec's slice rule.
Findings: F1 Major (missing evidence file); F2 and F3 Minor; F4 and F5 Nit. Details inline.
Checked, no finding: the T2a row cites commits by subject, not by id; the test module follows the file's import grouping and it_should_ naming; serde_json is already a dev-dependency.
Checks
On the loop's compute node at this head, against the merge base efdaf87c9 (receipt server-gates-kranich-740): the repository's pre-commit gate exit 0 (80 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 (3 s, 52 passed, none failed). F1 read at this head: the spec (lines 169-172 and 245-246) requires S1 to record its reproduction, regression results and recheck in manual-verification-evidence.md before it merges; the folder holds only ISSUE.md and coverage-evidence.md. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-primitives): completed/success; Docs Lint: completed/success; Test (Docker) (release): queued/pending; Build on macos-latest (nightly): completed/success; Build on windows-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (stable): completed/success; Build on macos-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: completed/failure; Docker E2E: completed/skipped; Unit (stable): in_progress/pending; Layer Boundary Bans: completed/success; Unit (nightly): in_progress/pending; Shipped Features: completed/success; Documented Clippy Allows: completed/success; Workspace Packaging: completed/success". At posting, develop is 815146669.
…isplay form The two tests named "like its display format" compared against a literal, so a change to Display alone left them green. Also assert the JSON value equals the Display string. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The slice lacks required manual-verification evidence, coverage updates, and recorded prose-first AAA design reviews for both new tests.
3 open issues
What changed in this PR
This PR delivers slice S1 of #2824, correcting PeerRole serialization in the primitives package so JSON values match the lowercase display format and metric labels.
Changes:
- Replace
rename_all_fieldswithrename_allfor the enum’s unit variants. - Add regression tests for
"seeder"and"leecher"serialization. - Update the issue specification to record S1 progress, leaving the broader testing work open.
| File | Description |
|---|---|
packages/primitives/src/peer.rs |
Correct serialization casing and add two regression tests. |
docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md |
Record the fix, task status, and reported test results. |
Review effort: Balanced
… the S1 fix Record the red run on the test commit, the green run on the fix commit and the head recheck, with timestamps and toolchain. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…merged Set the S0 and S1 slice rows, the F2 register state, the frontmatter and the checkpoint, and restamp the S1 log entry with the time it was written. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…he EPIC update Measured unit-only lines 62.73 percent, regions 70.29 percent, functions 59.49 percent; the EPIC Latest values and the row status are updated. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… commits Three records written for the previous commits carried times later than the commits themselves (14:40 and 14:35 against commits at 14:31 and 14:32). Restamp them. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… PeerRole tests Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at eabfeceea82b9bca66ef115b33ef1ba7f0dc0e98. Recomputed from the bytes at this head, against the previous round's head 0f785bbdf and the merge base efdaf87c9; git merge-tree against develop 815146669 writes a clean merged tree with no conflict (develop's one change since the base archives the #2823 spec, disjoint from this diff).
What moved: seven commits fast-forward 0f785bbdf (01eafe9, fa59efb, 2830e77, 1fd6c86, 1336f57, eca4076, eabfece), seven files, +383/-13; every other path is byte-identical to 0f785bbdf.
Previous findings, all fixed. F1: manual-verification-evidence.md records the reproduction, red on the test commit, green after the fix and the recheck, with toolchain and subjects. F2: slice rows, checkpoint, register and frontmatter. F3: S1 measurement and both EPIC rows; 468/746, 743/1,057 and 94/158 recompute to the stated figures. F4: 14:07 against the 14:07:54 commit. F5: both tests also compare with to_string().
The new commits: claims on #2811, #2827, #2828 and the PeerRole call sites match the tree; every stamp is now no later than its file's last content commit; the prose-first review matches the test code. The audit follows the template, and its 16 comment ids, review ids, severities, subjects, thread states and log times match the capture; the validator's logic passes offline. It cites two branch commit ids (F9); the description lists three of ten commits (F10).
Hygiene: Conventional subjects with [#2824], author equals committer, bodies match their diffs; each ends with one attribution footer naming a model co-author, which no rule in the tree forbids. git diff --check is clean.
Findings: F9 Minor and F10 Nit, numbered after the audit's F6 to F8; neither blocks. Details inline.
Checked, no finding: re-raises recorded FIXED/RESOLVED, as in earlier audits; the bare source URL matches earlier audits; the new doc-type is outside the strict profiles.
Checks
On the loop's compute node at this head, against the merge base efdaf87c9 (receipt server-gates-kranich-746): the repository's pre-commit gate exit 0 (50 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-2834-review exit 0 (8 rows, 3 log entries, no failures). Package tests at 1fd6c86ee, the last commit that changes code: cargo test -p torrust-tracker-primitives exit 0 (52 passed, none failed); the later commits change documentation only. F1 read at this head: manual-verification-evidence.md now exists in the spec folder. Read on the forge: all 8 review threads are answered and resolved. GitHub checks at this head at posting time: "". At posting, develop is 815146669.
|
ACK eabfece — the lowercase PeerRole serialization fix, its regression tests, evidence, coverage and tracking records and the review audit recomputed from the bytes at this head, with no blocking finding. |
…ject The audit cited two branch commits by id, which a rebase rewrites. Name each head by the subject of its last commit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
F10 (review 5860726992, inline comment 4539438702): fixed by editing the PR description, which is outside the repository tree. It now lists all commits of the PR by subject, grouped as code and tests, issue records and review audit, and names the files touched and the validation run. The two commits that are not pushed yet (the one that names the audit heads by subject and the round 2 audit) come with the next push. |
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 7d97ede3c0529400bcdf97dcefcf3cb5c54f5c58. Recomputed from the bytes at this head, against the previous round's head eabfeceea and the merge base efdaf87c9; git merge-tree against develop 815146669 writes a clean merged tree that differs from this head only by develop's archive of the #2823 spec, disjoint from this diff.
What moved: two commits fast-forward eabfeceea (2ea19f2, 7d97ede), one file, PR-REVIEW.md, +31/-2. The other 2,519 files are byte-identical to eabfeceea, so the previous round's conclusions on them stand.
Previous findings: F1 to F8 stay fixed on unchanged bytes. F9 fixed: both branch ids are replaced by head subjects (lines 44 and 194), and the open-pull-request commit-id check prints nothing here. F10 fixed outside the tree: the description lists all 12 commits by subject, the same set as the history, and the conversation comment the audit cites states the edit.
The new commits: the round 2 sentence, both rows, both detail entries and the 14:59 entry match the capture: review id, source comments, replies on their own threads, severities, subjects, resolved threads. Stamps fit: replies 14:58:44 and 14:58:46, commit 14:59:41, and the push came later (the stale-approval dismissal at 15:02:08 names this head). The validator's logic passes offline (10 rows, 4 log entries, no failure).
Hygiene: Conventional subjects with [#2824], author equals committer; the first body matches its diff and the second commit has none, which commit-changes makes optional. Each ends with one attribution footer naming a model co-author, which no rule in the tree forbids. git diff --check is clean.
Findings: none.
Checked, no finding: the 14:36 entry is edited in place, but the 14:59 entry names the edit, and restoring it would bring back the branch id that open-pull-request forbids; the description numbers commits within its area groups, so item 3 precedes item 4 though it landed later.
Checks
On the loop's compute node at this head, against the merge base efdaf87c9 (receipt server-gates-kranich-749): the repository's pre-commit gate and lint roster exit 0 and the tree left clean; the repository's audit validator on pr-2834-review exit 0 (10 rows, 4 log entries, no failures). This push changes only docs/pr-reviews/pr-2834-review/PR-REVIEW.md, so the package tests at 1fd6c86ee from the previous round stand. F9 read at this head: lines 44 and 194 name the earlier heads by commit subject, where line 44 at eabfeceea gave a commit id. Read on the forge: all 10 review threads are answered and resolved. GitHub checks at this head at posting time: "". At posting, develop is 815146669.
|
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. |
|
ACK 7d97ede |

Summary
Slice S1 of #2824 (EPIC #1347): the one defect the maintainer decided to fix inside the
primitivestests issue (finding F2).PeerRolederivedSerializewith#[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", whileDisplayand thepeer_rolemetric label useseederandleecher. The attribute is nowrename_all = "lowercase".Commits
Code and tests (
packages/primitives/src/peer.rs):test(primitives): [#2824] pin the lowercase JSON form of PeerRole— two regression tests that fail on this commit ("Seeder"and"Leecher"instead of lowercase).fix(primitives): [#2824] serialize PeerRole in lowercase— the one-attribute fix; the tests pass.test(primitives): [#2824] compare the PeerRole JSON with its Display form— the tests also assert the JSON equals theDisplaystring (review finding).Issue records (
docs/issues/open/2824-1347-add-tests-primitives/and the EPIC):docs(issues): [#2824] record the S1 PeerRole fix in the spec— spec progress.docs(issues): [#2824] add the manual verification evidence for the S1 fix—manual-verification-evidence.mdwith the red, green and head runs.docs(issues): [#2824] update the spec tracking state after S0 merged— slice rows, F2 state, frontmatter.docs(issues): [#2824] record the S1 coverage measurement and the EPIC update—coverage-evidence.mdand both EPIC "Latest" tables.docs(issues): [#2824] stamp the S1 records no later than their commits— restamp three records.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):docs(pr-reviews): [#2824] record the review of PR 2834 round 1docs(pr-reviews): [#2824] name the PR 2834 heads by commit subjectdocs(pr-reviews): [#2824] record the review of PR 2834 round 2Verification
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 inmanual-verification-evidence.md.coverage-evidence.md); part of the gain comes from fix(primitives): [#2798] remove the Ord impl of Peer that disagreed with Eq #2811 and refactor(primitives): [#2823] remove unused AddAssign for AggregateActiveSwarmMetadata #2827 merging, not only this slice.validate-audit-record.py --pr-number 2834reports 0 failures.PeerRoleto JSON (searchedpackagesandsrc).Notes
Related to #2824; this PR does not close it (only the last slice does).
🤖 Generated with Claude Code