From 81cf0fece3e0657a01393e6314358166400b7b99 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 15:57:32 +0000 Subject: [PATCH 01/16] docs(issues): [#2876] record the maintainer's answers to Q1-Q7 Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index e3990df398..e01023c8a5 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -2,14 +2,14 @@ schema-version: 1 doc-type: issue issue-type: task -status: planned +status: in-progress priority: p2 epic: 1347 github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md -branch: "2876-peer-id-test-helper-spec" +branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 09:41" +last-updated-utc: "2026-11-16 15:57" semantic-links: skill-links: - create-issue @@ -182,6 +182,18 @@ by project conventions. Each question has a recommendation. Nothing is implemented until the maintainer answers them. +**Answers (the maintainer, in chat, 2026-11-16).** Every recommendation was accepted: + +| Q | Decision | +| --- | --- | +| Q1 | (a) The helper lives in `primitives`, in `peer::fixture` next to `PeerBuilder`. | +| Q2 | Yes. `peer::fixture` moves behind a `testing` feature of `primitives`. | +| Q3 | (a) Remove `Id::new`, guarded by a `compile_fail` doctest. | +| Q4 | (b) The helper takes a `u32`; the `-1` sentinel becomes a named constant outside the made range, and the `0..408` loops iterate over `u32` and convert only where an `i32` is needed. | +| Q5 | Gate `impl Default for Peer` and `impl Default for Id` with the module. | +| Q6 | Yes, the three fixture ids become realistic (built with the helper); literals in other packages stay out of scope. | +| Q7 | Amend the test-support ADR. | + **Q1. Where does the realistic-id helper live?** - (a) In `primitives`, next to `PeerBuilder` in `peer::fixture` (behind `testing` if Q2 says so). @@ -323,7 +335,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | ID | Status | Task | Notes / Expected Output | | --- | ------ | ---- | ----------------------- | -| T0 | TODO | Get the maintainer's answers to Q1-Q7 | Answers recorded in this spec; later tasks adjusted. | +| T0 | DONE | Get the maintainer's answers to Q1-Q7 | Answers recorded in this spec; later tasks adjusted. | | T1 | TODO | Re-run the caller inventory and the compile proof | Tables above updated if `develop` moved; evidence in `manual-verification-evidence.md`. | | T2 | TODO | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | | T3 | TODO | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | @@ -368,9 +380,9 @@ with the narrow affected scope, and sign every commit with GPG. - [x] Folder-style spec drafted in `docs/issues/drafts/peer-id-test-helper/ISSUE.md` - [x] Draft spec reviewed and merged through #2865 (filing approved by the maintainer in chat, 2026-11-16) -- [ ] Open design questions Q1-Q7 answered by the maintainer (before T0) +- [x] Open design questions Q1-Q7 answered by the maintainer (before T0) - [x] GitHub issue created (#2876) and issue number added to this spec -- [ ] (Optional, recommended for complex issues) Spec-only PR merged into `develop` before implementation +- [x] (Optional, recommended for complex issues) Spec-only PR merged into `develop` before implementation - [ ] Implementation completed - [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) - [ ] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` @@ -413,6 +425,10 @@ with the narrow affected scope, and sign every commit with GPG. two re-raises): `branch` is now the `-spec` branch, the parent EPIC line is under the title, the approval checkpoint is split from the Q1-Q7 answers, and the F5 owner cells of EPIC row 11 and the closed #2824 spec point at #2876. +- 2026-11-16 15:57 UTC - Claude Code (Opus 5.5) - The spec-only PR #2878 merged and the maintainer + answered Q1-Q7 in chat, accepting every recommendation (Q4 (b): `u32` with a named sentinel). + Answers recorded under Open Design Decisions; status `in-progress` on branch + `2876-peer-id-test-helper`. T0 done. ## Acceptance Criteria From 85c63418fed4d2b3aaa6495a9a7cd6fc2c67e472 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:01:54 +0000 Subject: [PATCH 02/16] docs(issues): [#2876] re-run the caller inventory, compile proof and coverage baseline (T1) Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 13 ++- .../coverage-evidence.md | 51 ++++++++++ .../manual-verification-evidence.md | 97 +++++++++++++++++++ 3 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md create mode 100644 docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index e01023c8a5..7a3ca7fbdc 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 15:57" +last-updated-utc: "2026-11-16 15:59" semantic-links: skill-links: - create-issue @@ -82,7 +82,9 @@ test data in a production API, with ids no tracker ever receives. ### Caller inventory (`develop` at `abd7a10ff`, 2026-11-15) Searched with `grep -rn --include=*.rs` over `packages/`, `src/` and `tests/`, then checked by -compiling (below). +compiling (below). Re-run at implementation start (T1) on `develop` at `c8b1477ad` (2026-11-16): +every table below is unchanged, and the compile proof again exited 0 with no warnings +(`manual-verification-evidence.md`, V1). **`peer::Id::new`**: three calls, all in the integration tests of one package, which has `publish = false`. @@ -336,7 +338,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | ID | Status | Task | Notes / Expected Output | | --- | ------ | ---- | ----------------------- | | T0 | DONE | Get the maintainer's answers to Q1-Q7 | Answers recorded in this spec; later tasks adjusted. | -| T1 | TODO | Re-run the caller inventory and the compile proof | Tables above updated if `develop` moved; evidence in `manual-verification-evidence.md`. | +| T1 | DONE | Re-run the caller inventory and the compile proof | Tables above updated if `develop` moved; evidence in `manual-verification-evidence.md`. | | T2 | TODO | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | | T3 | TODO | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | | T4 | TODO | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | @@ -429,6 +431,11 @@ with the narrow affected scope, and sign every commit with GPG. answered Q1-Q7 in chat, accepting every recommendation (Q4 (b): `u32` with a named sentinel). Answers recorded under Open Design Decisions; status `in-progress` on branch `2876-peer-id-test-helper`. T0 done. +- 2026-11-16 15:59 UTC - Claude Code (Opus 5.5) - T1 on `develop` at `c8b1477ad`: the caller + inventory is unchanged and the compile proof exited 0 with no warnings (V1); a scratch test + reproduced the finding, every fixture and `Id::new` id gives `get_client_name() == None` (V0); the + coverage baseline is 1,075 / 1,143 lines, with the 68 uncovered lines all in `peer.rs` + (`coverage-evidence.md`). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md new file mode 100644 index 0000000000..dba6690c26 --- /dev/null +++ b/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md @@ -0,0 +1,51 @@ +--- +doc-type: coverage-evidence +issue: 2876 +package: torrust-tracker-primitives +measured-commit: c8b1477ad +measured-utc: 2026-11-16 +--- + +# Coverage Evidence - `torrust-tracker-primitives` (#2876) + +## Baseline (T1) + +Measured on 2026-11-16 at `develop` commit `c8b1477ad` (the merge of #2878), with +`cargo-llvm-cov 0.6.16` and stable Rust 1.99.1, from a clean workspace, with a separate +`CARGO_LLVM_COV_TARGET_DIR`: + +```console +cargo llvm-cov clean --workspace +cargo llvm-cov -p torrust-tracker-primitives --all-features --lib --json --output-path .json +cargo llvm-cov -p torrust-tracker-primitives --all-features --json --output-path .json +``` + +Totals are filtered to `packages/primitives/src/`. The package has no `tests/` folder and no +examples, so the aggregate run (without `--lib`) ran the same 108 unit tests and gave the same +numbers. + +| Scope | Tests | Lines | Regions | Functions | +| --- | ---: | ---: | ---: | ---: | +| Unit-only (`--lib`) | 108 unit | 1,075 / 1,143 (94.05%) | 1,694 / 1,778 (95.28%) | 210 / 223 (94.17%) | +| Aggregate | 108 unit | 1,075 / 1,143 (94.05%) | 1,694 / 1,778 (95.28%) | 210 / 223 (94.17%) | + +The final measurement of #2824 was 1,078 / 1,146 lines; `develop` moved since then. As in #2824, every +uncovered line of the package is in `peer.rs`: 504 / 572 lines covered, 68 uncovered. + +### Uncovered `peer.rs` lines and their owners + +Line numbers are those of `develop` at `c8b1477ad`. + +| Lines | Code | Owner | +| --- | --- | --- | +| 369-382 | `Id::new` | #2876 (T4 removes it) | +| 413 | `Display for Id`, the `None` branch | #2824 (recorded there as a dead branch); not F5 | +| 547-605 | `PeerBuilder` methods `with_peer_id` to `with_event_completed` | #2876 (T7) | +| 619-629 | `impl Default for Peer` | #2876 (T7) | +| 633-636 | `impl Default for Id` | #2876 (T7) | + +`PeerBuilder::seeder`, `leecher`, `build` and `into` are already covered by #2824's tests. + +## Final Measurement (T9) + +Pending. diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md new file mode 100644 index 0000000000..14630c7b64 --- /dev/null +++ b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md @@ -0,0 +1,97 @@ +--- +doc-type: manual-verification-evidence +issue-spec: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +last-updated-utc: 2026-11-16 15:59 +--- + +# Manual Verification Evidence + +## Purpose + +Record real, human-oriented verification of the completed behavior. This is +evidence from commands or interactions actually performed against the artifact; +do not invent commands, output, logs, or results. + +## Environment and Prerequisites + +- Date and time (UTC): 2026-11-16 15:59 +- Artifact under test: `develop` at `c8b1477ad` (the merge of #2878), before any change of this + issue (T1 baseline). +- Operating system / environment: Linux 7.0.0-43-generic; stable Rust toolchain, rustc 1.99.1, + cargo 1.99.1. +- Prerequisites and setup performed: none beyond a checkout of `develop`. + +## Verification Processes + +### V1 - Production builds need no test support (M1, baseline) + +- Goal: show that no library or binary target of the workspace uses `Id::new`, `peer::fixture` + (`PeerBuilder`) or the `Default` impls of `Peer` and `Id`. +- Initial state: clean checkout of `develop` at `c8b1477ad`. +- Status: `IN_PROGRESS` (the baseline is done; the final run on the finished code is pending, T9) + +#### Steps Performed + +The steps ran in this order in one shell, each after the previous one finished: + +1. 15:59:03.559 - 15:59:03.737 UTC: throwaway gate in `packages/primitives/src/peer.rs`: + `#[cfg(test)]` added above `impl Id {` (the block that holds `new`, line 367) and above + `pub mod fixture {`. `git diff -U0` showed exactly the two added `#[cfg(test)]` lines. +2. 15:59:03.757 - 15:59:04.680 UTC: `cargo check --workspace --lib --bins` (stable Rust toolchain, + cargo 1.99.1). +3. 15:59:04.691 UTC: `git checkout -- packages/primitives/src/peer.rs`, then + `git diff --quiet HEAD -- packages/primitives/src/peer.rs` exited 0 after the restore. + +A first run of the same three steps a minute earlier (without the timestamps) also exited 0; it did +the full compile, so the timed run above finished quickly from the build cache. + +#### Observed Result + +```text +exit=0 warnings=0 + Finished `dev` profile [optimized + debuginfo] target(s) in 1.55s +``` + +#### Conclusion + +Met (baseline). With `Id::new` and the fixture module (which holds the `Default` impls) compiled +only under `cfg(test)`, every library and binary target of the workspace still compiles, with no +warnings. Code outside this workspace that depends on the published 3.0.0 is not covered. + +### V0 - Reproduction: today's test ids name no client (M3, baseline) + +- Goal: show that the ids the fixture and `Id::new` make today are not ids a real client sends. +- Initial state: `develop` at `c8b1477ad`. +- Status: `DONE` (baseline half of M3; the comparison with the new helper's ids follows in V3) + +#### Steps Performed + +1. Created a temporary, untracked integration test `packages/primitives/tests/scratch_2876.rs` + (the package has no `tests/` folder; it was created for this run) that prints + `to_hex_string()` and `get_client_name()` for `Id::default()`, the ids of + `PeerBuilder::seeder()` and `PeerBuilder::leecher()`, `Id::new(1)`, `Id::new(-1)`, and, as the + control, `-qB4650-abcdefghijkl` (the id #2824's tests use). +2. `cargo test -q -p torrust-tracker-primitives --test scratch_2876 -- --nocapture` (stable Rust + toolchain, cargo 1.99.1), exit 0. +3. `rm -r packages/primitives/tests`; `git status -s` was empty afterwards. + +#### Observed Result + +```text +Id::default() hex=0x2d71423030303030303030303030303030303030 client=None +PeerBuilder::seeder() hex=0x2d71423030303030303030303030303030303031 client=None +PeerBuilder::leecher() hex=0x2d71423030303030303030303030303030303032 client=None +Id::new(1) hex=0x0000000001000000000000000000000000000000 client=None +Id::new(-1) hex=0x00000000ffffffffffffffffffffffffffffffff client=None +-qB4650-abcdefghijkl hex=0x2d7142343635302d6162636465666768696a6b6c client=Some("qBittorrent") +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s +``` + +#### Conclusion + +The finding is reproduced: the three fixture ids (`-qB000...`) and the `Id::new` ids give +`get_client_name() == None`; the Azureus-style control id gives `Some("qBittorrent")`. + +## Failures and Follow-up + +None so far. From edddf5878b1df524d7b8b8e7738b402b51186c74 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:05:54 +0000 Subject: [PATCH 03/16] test(primitives): [#2876] add qbittorrent_peer_id, a fixture helper for realistic peer ids The helper builds -qB4650- followed by the number as 12 zero-padded decimal digits, so the client registry names qBittorrent and distinct numbers give distinct ids. Three unit tests, each seen to fail under a mutation. Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 8 +- .../test-plans/qbittorrent-peer-id.md | 89 +++++++++++++++++++ packages/primitives/src/peer.rs | 67 +++++++++++++- 3 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 7a3ca7fbdc..68b50d8413 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 15:59" +last-updated-utc: "2026-11-16 16:05" semantic-links: skill-links: - create-issue @@ -339,7 +339,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | --- | ------ | ---- | ----------------------- | | T0 | DONE | Get the maintainer's answers to Q1-Q7 | Answers recorded in this spec; later tasks adjusted. | | T1 | DONE | Re-run the caller inventory and the compile proof | Tables above updated if `develop` moved; evidence in `manual-verification-evidence.md`. | -| T2 | TODO | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | +| T2 | DONE | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | | T3 | TODO | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | | T4 | TODO | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | | T5 | TODO | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | @@ -436,6 +436,10 @@ with the narrow affected scope, and sign every commit with GPG. reproduced the finding, every fixture and `Id::new` id gives `get_client_name() == None` (V0); the coverage baseline is 1,075 / 1,143 lines, with the 68 uncovered lines all in `peer.rs` (`coverage-evidence.md`). +- 2026-11-16 16:05 UTC - Claude Code (Opus 5.5) - T2: `peer::fixture::qbittorrent_peer_id(u32) -> Id` + (`const fn`, `-qB4650-` + 12 zero-padded decimal digits) with three unit tests, red first, each + guarded by a mutation; the maintainer approved its name, signature and format at the design-review + checkpoint (`test-plans/qbittorrent-peer-id.md`). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md new file mode 100644 index 0000000000..d6403b22f3 --- /dev/null +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -0,0 +1,89 @@ +--- +doc-type: file-test-plan +issue: 2876 +package: torrust-tracker-primitives +target-file: packages/primitives/src/peer.rs +status: done +last-updated-utc: "2026-11-16 16:05" +--- + +# `peer::fixture::qbittorrent_peer_id` Test Plan (T2) + +The realistic-id helper decided in Q1 (in `peer::fixture`) and Q4 (`u32` input). + +## The Helper + +```rust +pub const fn qbittorrent_peer_id(number: u32) -> Id +``` + +It returns the Azureus-style prefix `-qB4650-` (qBittorrent 4.6.5, the id #2824's tests use) +followed by `number` as 12 zero-padded decimal digits: `qbittorrent_peer_id(42)` is +`-qB4650-000000000042`. `u32::MAX` needs 10 digits, so every input fits. + +- It returns `Id`, like `Id::new` did, so the callers keep passing `&id` to + `PeerBuilder::with_peer_id(&PeerId)` through `Deref`. +- It is a `const fn`, so the fixture's `const fn` builders (`seeder`, `leecher`) can use it for + their own ids (Q6, T6). + +## Behaviors and Tests + +All three are unit tests in the `peer::test::qbittorrent_peer_id` module of `peer.rs`; the helper +decides each behavior itself. + +| Behavior | Test | +| --- | --- | +| Exact format: prefix, then 12 zero-padded decimal digits | `it_should_write_the_number_as_twelve_zero_padded_decimal_digits_after_the_qbittorrent_prefix` (0, 42, `u32::MAX`) | +| The client registry knows every id as qBittorrent | `it_should_make_ids_that_the_client_registry_knows_as_qbittorrent` (quickcheck, any `u32`) | +| Distinct numbers give distinct ids | `it_should_make_distinct_ids_from_distinct_numbers` (quickcheck, any two different `u32`) | + +## Red, Green and Mutations + +Stable Rust toolchain, cargo 1.99.1, `cargo test -q -p torrust-tracker-primitives --lib qbittorrent_peer_id`. + +- **Red 1:** tests written first, no helper: `error[E0432]: unresolved import + crate::peer::fixture::qbittorrent_peer_id`. +- **Red 2:** a stub that returned `Id::new(number)` (today's ids): the format test failed + (`peer id made from 0: "\0\0..."`) and the client test failed (`[quickcheck] TEST FAILED. + Arguments: (0)`); 1 passed, 2 failed. The distinctness test passed: `Id::new` is distinct too, so + its guard is shown by mutation M3. +- **Green:** 3 passed. The whole package: 111 passed (108 before). + +Each mutation was applied to the working tree, checked to compile (no `error[` line; the only +`error:` line is cargo's "test failed"), and the file was restored with `cmp` against a saved copy. + +| Mutation | Breaks | Failed tests | +| --- | --- | --- | +| M1: digits written from byte 8 onwards, least significant first (`42` gives `-qB4650-240000000000`) | the format only; still distinct and still qBittorrent | format | +| M2: prefix `-ZZ4650-` | the client name (and so the exact bytes) | client, format | +| M3: digit loop never runs (every number gives `-qB4650-000000000000`) | distinctness (and the bytes of 42 and `u32::MAX`) | distinct, format | + +A first run of M1 did not compile (it left `PEER_ID_BYTES_LEN` unused, which `-D warnings` +rejects); it was rewritten to keep the constant in use and re-run, with the result above. + +## Prose-First AAA Review + +Format test: + +- Arrange: three numbers that differ in how they are written: zero (no digit to write, all + padding), an ordinary number, and the widest `u32` (ten digits); each with the exact id expected, + written out by hand. +- Act: build the id from the number. +- Assert: the id is exactly the expected bytes; on failure the message shows the number and the id + made. + +The table did not say why these three numbers; a short comment on each case now does, and +`// Arrange`, `// Act`, `// Assert` mark the sections. The expected ids are literals, not derived +from the helper. + +Property tests: each is one expression with the Act and the expected result in view (`Some("qBittorrent")`; +`!=` on the bytes, with equal inputs discarded). Prose added nothing, so none was kept. + +Smells checked: no complex Arrange, no hidden Act, no production-derived expectation. The format +test asserts in a loop, but every assertion checks the same behavior and its message names the case. + +## Maintainer Design Review + +Approved by the maintainer in chat on 2026-11-16 ("Approve, continue"): the name +`qbittorrent_peer_id`, the signature `const fn(u32) -> Id` and the `-qB4650-` + 12-digit format, +before the callers move to it (T3). diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index 7e62748682..b1327ef6d8 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -500,7 +500,7 @@ pub mod fixture { use torrust_clock::DurationSinceUnixEpoch; - use super::{Id, Peer, PeerId}; + use super::{Id, PEER_ID_BYTES_LEN, Peer, PeerId}; use crate::{AnnounceEvent, NumberOfBytes}; #[derive(PartialEq, Eq, Debug, Default)] @@ -615,6 +615,29 @@ pub mod fixture { } } + /// Builds a peer id that a real qBittorrent client could send, numbered so tests can make many + /// distinct peers. + /// + /// The id is the Azureus-style client prefix `-qB4650-` (qBittorrent 4.6.5) followed by + /// `number` as 12 zero-padded decimal digits, so `qbittorrent_peer_id(42)` is + /// `-qB4650-000000000042`. Distinct numbers give distinct ids, and the client registry knows + /// every id as qBittorrent ([`Id::get_client_name`]). + #[must_use] + pub const fn qbittorrent_peer_id(number: u32) -> Id { + const DECIMAL_DIGITS: &[u8; 10] = b"0123456789"; + + let mut bytes = *b"-qB4650-000000000000"; + let mut remaining = number; + let mut position = PEER_ID_BYTES_LEN; + while remaining > 0 { + position -= 1; + bytes[position] = DECIMAL_DIGITS[(remaining % 10) as usize]; + remaining /= 10; + } + + Id { data: PeerId(bytes) } + } + impl Default for Peer { fn default() -> Self { Self { @@ -1030,6 +1053,48 @@ pub mod test { } } + mod qbittorrent_peer_id { + use quickcheck::TestResult; + use quickcheck_macros::quickcheck; + + use crate::peer::fixture::qbittorrent_peer_id; + + #[test] + fn it_should_write_the_number_as_twelve_zero_padded_decimal_digits_after_the_qbittorrent_prefix() { + // Arrange + for (number, expected) in [ + (0, b"-qB4650-000000000000"), // no digit to write: all padding + (42, b"-qB4650-000000000042"), // an ordinary number + (u32::MAX, b"-qB4650-004294967295"), // the widest number, ten digits + ] { + // Act + let id = qbittorrent_peer_id(number); + + // Assert + assert_eq!( + id.0, + *expected, + "peer id made from {number}: {:?}", + String::from_utf8_lossy(&id.0) + ); + } + } + + #[quickcheck] + fn it_should_make_ids_that_the_client_registry_knows_as_qbittorrent(number: u32) -> bool { + qbittorrent_peer_id(number).get_client_name().as_deref() == Some("qBittorrent") + } + + #[quickcheck] + fn it_should_make_distinct_ids_from_distinct_numbers(number: u32, other_number: u32) -> TestResult { + if number == other_number { + return TestResult::discard(); + } + + TestResult::from_bool(qbittorrent_peer_id(number).0 != qbittorrent_peer_id(other_number).0) + } + } + mod peer_collection { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; From 51b8de27371f10b923b085a8ff5d90c9684c386a Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:07:57 +0000 Subject: [PATCH 04/16] test(torrent-repository-benchmarking): [#2876] build peer ids with qbittorrent_peer_id The peer builders take a u32; the -1 sentinel is the named OTHER_PEER, a number no scenario makes, and the 0..408 loops iterate over u32. Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 8 ++++-- .../test-plans/qbittorrent-peer-id.md | 26 ++++++++++++++++++- .../tests/common/torrent_peer_builder.rs | 14 ++++++---- .../tests/entry/mod.rs | 11 ++++---- .../tests/repository/mod.rs | 10 ++++--- 5 files changed, 52 insertions(+), 17 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 68b50d8413..4edb1ea405 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:05" +last-updated-utc: "2026-11-16 16:07" semantic-links: skill-links: - create-issue @@ -340,7 +340,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T0 | DONE | Get the maintainer's answers to Q1-Q7 | Answers recorded in this spec; later tasks adjusted. | | T1 | DONE | Re-run the caller inventory and the compile proof | Tables above updated if `develop` moved; evidence in `manual-verification-evidence.md`. | | T2 | DONE | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | -| T3 | TODO | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | +| T3 | DONE | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | | T4 | TODO | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | | T5 | TODO | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | | T6 | TODO | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | @@ -440,6 +440,10 @@ with the narrow affected scope, and sign every commit with GPG. (`const fn`, `-qB4650-` + 12 zero-padded decimal digits) with three unit tests, red first, each guarded by a mutation; the maintainer approved its name, signature and format at the design-review checkpoint (`test-plans/qbittorrent-peer-id.md`). +- 2026-11-16 16:07 UTC - Claude Code (Opus 5.5) - T3: the `torrent-repository-benchmarking` + tests use `qbittorrent_peer_id`; `-1` is the named `OTHER_PEER` (1000) and the `0..408` loops + iterate over `u32`. Same tests pass (17 and 1,468); with `OTHER_PEER` set to a made number, the + cutoff test fails (`test-plans/qbittorrent-peer-id.md`, Caller Migration). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index d6403b22f3..4cdde787e7 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:05" +last-updated-utc: "2026-11-16 16:07" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -87,3 +87,27 @@ test asserts in a loop, but every assertion checks the same behavior and its mes Approved by the maintainer in chat on 2026-11-16 ("Approve, continue"): the name `qbittorrent_peer_id`, the signature `const fn(u32) -> Id` and the `-qB4650-` + 12-digit format, before the callers move to it (T3). + +## Caller Migration (T3) + +`torrent-repository-benchmarking` moved from `peer::Id::new` to the helper (Q4 (b)): + +- `tests/common/torrent_peer_builder.rs`: `a_completed_peer` and `a_started_peer` take a `u32` and + build the id with `qbittorrent_peer_id`. A new `pub const OTHER_PEER: u32 = 1000` names the peer + that no scenario makes (the scenarios number their peers from 0 to 407). +- `tests/entry/mod.rs`: the three `-1` arguments are `OTHER_PEER`; the scrape-limit loop builds its + 75 ids with `qbittorrent_peer_id(peer_number)`. +- `tests/repository/mod.rs`: the `-1` argument is `OTHER_PEER`; the two fixtures iterate over + `0..408_u32` and convert to `i32` only for `InfoHash::from(&i32)` and `write_i32`, so the info + hashes are the same as before. + +`grep -rn 'peer::Id::new' --include=*.rs packages src tests` finds no caller left. +`cargo test -q -p torrust-tracker-torrent-repository-benchmarking` (stable Rust toolchain, cargo +1.99.1): 17 and 1,468 passed, the same tests as before the change (no test added or removed), and +`cargo clippy -p torrust-tracker-torrent-repository-benchmarking --all-targets --all-features -- -D warnings` +is clean. + +Sentinel check: with `OTHER_PEER` changed to `1` (a number the scenarios make), 10 cases failed, +all of `entry::it_should_remove_inactive_peers_beyond_cutoff` for the `started` and `three` +scenarios (the ones that make peer 1) over the five entry types; 1,458 passed. The constant was +restored to `1000`. diff --git a/packages/torrent-repository-benchmarking/tests/common/torrent_peer_builder.rs b/packages/torrent-repository-benchmarking/tests/common/torrent_peer_builder.rs index 48aa981cd0..af7d7c1b5f 100644 --- a/packages/torrent-repository-benchmarking/tests/common/torrent_peer_builder.rs +++ b/packages/torrent-repository-benchmarking/tests/common/torrent_peer_builder.rs @@ -1,11 +1,15 @@ -use torrust_tracker_primitives::peer::fixture::PeerBuilder; +use torrust_tracker_primitives::peer::fixture::{PeerBuilder, qbittorrent_peer_id}; use torrust_tracker_primitives::peer::{self}; +/// The number of a peer that no test scenario makes: the scenarios number their peers from 0 to +/// 407, so this peer is always a new one. +pub const OTHER_PEER: u32 = 1000; + /// A torrent seeder is a peer with 0 bytes left to download which /// has not announced it has stopped #[must_use] -pub fn a_completed_peer(id: i32) -> peer::Peer { - let peer_id = peer::Id::new(id); +pub fn a_completed_peer(number: u32) -> peer::Peer { + let peer_id = qbittorrent_peer_id(number); PeerBuilder::default() .with_bytes_left_to_download(0) .with_event_completed() @@ -16,8 +20,8 @@ pub fn a_completed_peer(id: i32) -> peer::Peer { /// A torrent leecher is a peer that is not a seeder. /// Leecher: left > 0 OR event = Stopped #[must_use] -pub fn a_started_peer(id: i32) -> peer::Peer { - let peer_id = peer::Id::new(id); +pub fn a_started_peer(number: u32) -> peer::Peer { + let peer_id = qbittorrent_peer_id(number); PeerBuilder::default() .with_bytes_left_to_download(1) .with_event_started() diff --git a/packages/torrent-repository-benchmarking/tests/entry/mod.rs b/packages/torrent-repository-benchmarking/tests/entry/mod.rs index e06ad358b8..d4521e2445 100644 --- a/packages/torrent-repository-benchmarking/tests/entry/mod.rs +++ b/packages/torrent-repository-benchmarking/tests/entry/mod.rs @@ -5,6 +5,7 @@ use rstest::{fixture, rstest}; use torrust_clock::clock::stopped::Stopped as _; use torrust_clock::clock::{self, Time as _}; use torrust_tracker_primitives::peer::Peer; +use torrust_tracker_primitives::peer::fixture::qbittorrent_peer_id; use torrust_tracker_primitives::{AnnounceEvent, NumberOfBytes, TrackerPolicy, peer}; const MAX_PEERS: usize = 74; @@ -14,7 +15,7 @@ use torrust_tracker_torrent_repository_benchmarking::{ use crate::CurrentClock; use crate::common::torrent::Torrent; -use crate::common::torrent_peer_builder::{a_completed_peer, a_started_peer}; +use crate::common::torrent_peer_builder::{OTHER_PEER, a_completed_peer, a_started_peer}; #[fixture] fn single() -> Torrent { @@ -189,7 +190,7 @@ async fn it_should_update_a_peer(#[values(single(), mutex_std(), mutex_tokio())] make(&mut torrent, makes).await; // Make and insert a new peer. - let mut peer = a_started_peer(-1); + let mut peer = a_started_peer(OTHER_PEER); torrent.upsert_peer(&peer).await; // Get the Inserted Peer by Id. @@ -230,7 +231,7 @@ async fn it_should_remove_a_peer_upon_stopped_announcement( make(&mut torrent, makes).await; - let mut peer = a_started_peer(-1); + let mut peer = a_started_peer(OTHER_PEER); torrent.upsert_peer(&peer).await; @@ -399,7 +400,7 @@ async fn it_should_limit_the_number_of_peers_returned( // We add one more peer than the scrape limit for peer_number in 1..=74 + 1 { let mut peer = a_started_peer(1); - peer.peer_id = *peer::Id::new(peer_number); + peer.peer_id = *qbittorrent_peer_id(peer_number); torrent.upsert_peer(&peer).await; } @@ -424,7 +425,7 @@ async fn it_should_remove_inactive_peers_beyond_cutoff( let peers = make(&mut torrent, makes).await; - let mut peer = a_completed_peer(-1); + let mut peer = a_completed_peer(OTHER_PEER); let now = clock::Working::now(); clock::Stopped::local_set(&now); diff --git a/packages/torrent-repository-benchmarking/tests/repository/mod.rs b/packages/torrent-repository-benchmarking/tests/repository/mod.rs index a8469413a7..7518e62674 100644 --- a/packages/torrent-repository-benchmarking/tests/repository/mod.rs +++ b/packages/torrent-repository-benchmarking/tests/repository/mod.rs @@ -14,7 +14,7 @@ use torrust_tracker_torrent_repository_benchmarking::repository::rw_lock_tokio:: use torrust_tracker_torrent_repository_benchmarking::repository::skip_map_mutex_std::CrossbeamSkipList; use crate::common::repo::Repo; -use crate::common::torrent_peer_builder::{a_completed_peer, a_started_peer}; +use crate::common::torrent_peer_builder::{OTHER_PEER, a_completed_peer, a_started_peer}; #[fixture] fn standard() -> Repo { @@ -135,10 +135,11 @@ fn three() -> Entries { fn many_out_of_order() -> Entries { let mut entries: HashSet<(InfoHash, EntrySingle)> = HashSet::default(); - for i in 0..408 { + for i in 0..408_u32 { let mut entry = EntrySingle::default(); entry.upsert_peer(&a_started_peer(i)); + let i = i32::try_from(i).expect("0..408 fits in an i32"); entries.insert((InfoHash::from(&i), entry)); } @@ -150,10 +151,11 @@ fn many_out_of_order() -> Entries { fn many_hashed_in_order() -> Entries { let mut entries: BTreeMap = BTreeMap::default(); - for i in 0..408 { + for i in 0..408_u32 { let mut entry = EntrySingle::default(); entry.upsert_peer(&a_started_peer(i)); + let i = i32::try_from(i).expect("0..408 fits in an i32"); let hash: &mut DefaultHasher = &mut DefaultHasher::default(); hash.write_i32(i); @@ -545,7 +547,7 @@ async fn it_should_remove_inactive_peers( let hash = &mut DefaultHasher::default(); hash.write_u8(255); info_hash = InfoHash::from(&hash.clone()); - peer = a_completed_peer(-1); + peer = a_completed_peer(OTHER_PEER); } // Set the last updated time of the peer to be 121 seconds ago. From 88f9d2cf7ef0aa640330e4c3e8528c9b9069498d Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:09:28 +0000 Subject: [PATCH 05/16] refactor(primitives)!: [#2876] remove peer::Id::new Its only callers, in torrent-repository-benchmarking tests, now use peer::fixture::qbittorrent_peer_id. A compile_fail doctest guards the removal. BREAKING CHANGE: peer::Id::new is removed from the public API of torrust-tracker-primitives. Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 7 +++- .../test-plans/qbittorrent-peer-id.md | 22 ++++++++++- packages/primitives/src/peer.rs | 39 ++++++++++--------- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 4edb1ea405..3a77794979 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:07" +last-updated-utc: "2026-11-16 16:09" semantic-links: skill-links: - create-issue @@ -341,7 +341,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T1 | DONE | Re-run the caller inventory and the compile proof | Tables above updated if `develop` moved; evidence in `manual-verification-evidence.md`. | | T2 | DONE | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | | T3 | DONE | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | -| T4 | TODO | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | +| T4 | DONE | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | | T5 | TODO | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | | T6 | TODO | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | | T7 | TODO | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | @@ -444,6 +444,9 @@ with the narrow affected scope, and sign every commit with GPG. tests use `qbittorrent_peer_id`; `-1` is the named `OTHER_PEER` (1000) and the `0..408` loops iterate over `u32`. Same tests pass (17 and 1,468); with `OTHER_PEER` set to a made number, the cutoff test fails (`test-plans/qbittorrent-peer-id.md`, Caller Migration). +- 2026-11-16 16:09 UTC - Claude Code (Opus 5.5) - T4: `Id::new` removed. A `compile_fail,E0599` + doctest on `peer::Id`, with a companion that builds an id from 20 bytes, fails when `Id::new` is + put back (stable and nightly). The break adds to the 4.0.0 that `primitives` already owes (#2583). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index 4cdde787e7..e58c06f129 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:07" +last-updated-utc: "2026-11-16 16:09" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -111,3 +111,23 @@ Sentinel check: with `OTHER_PEER` changed to `1` (a number the scenarios make), all of `entry::it_should_remove_inactive_peers_beyond_cutoff` for the `started` and `three` scenarios (the ones that make peer 1) over the five entry types; 1,458 passed. The constant was restored to `1000`. + +## `Id::new` Removal (T4) + +`Id::new` is removed (Q3 (a)). The doc comment of `peer::Id` now has two doctests, following the +`write-unit-test` rule for compile-time guarantees: + +- a companion that compiles: `Id::from(PeerId(*b"-qB4650-000000000042"))`, whose client name is + `Some("qBittorrent")`; +- `compile_fail,E0599`: `Id::new(1)`. + +`cargo test -q -p torrust-tracker-primitives` (stable Rust toolchain, cargo 1.99.1): 111 unit tests +and the doctests pass; `cargo +nightly test -q -p torrust-tracker-primitives --doc` (nightly Rust +toolchain, which checks the error code) passes too. + +Mutation: an `Id::new(number: i32)` put back into `impl Id`. With both `cargo test --doc` and +`cargo +nightly test --doc`, `peer::Id (line 359)` failed with "Test compiled successfully, but +it's marked `compile_fail`"; 3 passed, 1 failed. The file was restored (`cmp` against a saved copy). + +Removing a public item is a breaking change for the published `torrust-tracker-primitives` 3.0.0. +The crate already owes a major release (4.0.0, for #2454) in the #2583 plan; this removal adds to it. diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index b1327ef6d8..0e2d6084c5 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -340,6 +340,27 @@ pub enum IdConversionError { }, } +/// A peer id, with its hex form and the name of the client that made it. +/// +/// It is built from the 20 bytes a peer sends: +/// +/// ``` +/// use torrust_tracker_primitives::PeerId; +/// use torrust_tracker_primitives::peer::Id; +/// +/// let id = Id::from(PeerId(*b"-qB4650-000000000042")); +/// +/// assert_eq!(id.get_client_name().as_deref(), Some("qBittorrent")); +/// ``` +/// +/// There is no constructor from a number: tests that need many distinct ids use +/// `peer::fixture::qbittorrent_peer_id`, which makes ids a real client could send. +/// +/// ```compile_fail,E0599 +/// use torrust_tracker_primitives::peer::Id; +/// +/// let id = Id::new(1); +/// ``` pub struct Id { data: PeerId, } @@ -364,24 +385,6 @@ impl DerefMut for Id { } } -impl Id { - #[must_use] - pub fn new(number: T) -> Self - where - T: Into, - { - let number: i128 = number.into(); - let number = number.to_le_bytes(); - let bytes = [ - 0u8, 0u8, 0u8, 0u8, number[0], number[1], number[2], number[3], number[4], number[5], number[6], number[7], - number[8], number[9], number[10], number[11], number[12], number[13], number[14], number[15], - ]; - - let data = PeerId(bytes); - Self { data } - } -} - impl TryFrom> for Id { type Error = IdConversionError; From ebe5394cd784fb51a8813cc5b60ca391bbcce72c Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:19:08 +0000 Subject: [PATCH 06/16] feat(primitives)!: [#2876] put peer::fixture behind a testing feature peer::fixture (PeerBuilder, qbittorrent_peer_id and the Default impls of Peer and peer::Id) now compiles only with the new testing feature, enabled by a path-only self dev-dependency and by the dev-dependencies of the eight packages whose tests use it. BREAKING CHANGE: peer::fixture and the Default impls of peer::Peer and peer::Id need the testing feature of torrust-tracker-primitives. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + Cargo.toml | 1 + .../2876-1347-peer-id-test-helper/ISSUE.md | 9 ++++- .../manual-verification-evidence.md | 38 ++++++++++++++++++- .../test-plans/qbittorrent-peer-id.md | 30 ++++++++++++++- packages/axum-http-server/Cargo.toml | 1 + packages/axum-rest-api-server/Cargo.toml | 1 + packages/http-core/Cargo.toml | 1 + packages/primitives/Cargo.toml | 13 ++++++- packages/primitives/src/peer.rs | 9 ++++- .../swarm-coordination-registry/Cargo.toml | 1 + .../Cargo.toml | 1 + packages/udp-core/Cargo.toml | 1 + packages/udp-server/Cargo.toml | 1 + 14 files changed, 101 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e68e50cee1..e912cf39d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5284,6 +5284,7 @@ dependencies = [ "torrust-info-hash", "torrust-net-primitives", "torrust-peer-id", + "torrust-tracker-primitives", "url", ] diff --git a/Cargo.toml b/Cargo.toml index c552ccb173..de91568fad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,6 +127,7 @@ torrust-net-primitives = "0.1.0" torrust-peer-id = "0.1.0" torrust-tracker-client-lib = { version = "0.1.0", path = "packages/tracker-client" } torrust-tracker-http-protocol = { version = "0.1.0", path = "packages/http-protocol" } +torrust-tracker-primitives = { version = "3.0.0", path = "packages/primitives", features = [ "testing" ] } torrust-tracker-test-helpers = { version = "3.0.0", path = "packages/test-helpers" } torrust-tracker-udp-protocol = { version = "0.1.0", path = "packages/udp-protocol" } url = { version = "2", features = [ "serde" ] } diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 3a77794979..f5251a86ee 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:09" +last-updated-utc: "2026-11-16 16:18" semantic-links: skill-links: - create-issue @@ -342,7 +342,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T2 | DONE | Add the realistic-id helper with unit tests | In the Q1 location, with the Q4 format; design-review checkpoint after the first passing test. | | T3 | DONE | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | | T4 | DONE | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | -| T5 | TODO | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | +| T5 | DONE | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | | T6 | TODO | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | | T7 | TODO | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | | T8 | TODO | Record the decision (Q7) | ADR amendment, or a note in this spec. | @@ -447,6 +447,11 @@ with the narrow affected scope, and sign every commit with GPG. - 2026-11-16 16:09 UTC - Claude Code (Opus 5.5) - T4: `Id::new` removed. A `compile_fail,E0599` doctest on `peer::Id`, with a companion that builds an id from 20 bytes, fails when `Id::new` is put back (stable and nightly). The break adds to the 4.0.0 that `primitives` already owes (#2583). +- 2026-11-16 16:18 UTC - Claude Code (Opus 5.5) - T5: `peer::fixture` and the `Default` impls are + behind the new `testing` feature of `primitives` (self dev-dependency, rule A.6 comment). Built + member by member, eight packages needed a `[dev-dependencies]` entry: the six of the inventory plus + `http-core` and the root crate (Q5). Machete, packaging, M2 and `cargo test --workspace` (4,087 + passed) are green (`test-plans/qbittorrent-peer-id.md`, `testing` Feature). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md index 14630c7b64..decf8c1a0e 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md -last-updated-utc: 2026-11-16 15:59 +last-updated-utc: 2026-11-16 16:18 --- # Manual Verification Evidence @@ -92,6 +92,42 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini The finding is reproduced: the three fixture ids (`-qB000...`) and the `Id::new` ids give `get_client_name() == None`; the Azureus-style control id gives `Some("qBittorrent")`. +### V2 - The release tracker carries no `testing` feature of `primitives` (M2) + +- Goal: show that, with `peer::fixture` behind the new `testing` feature (T5), the shipped + `torrust-tracker` binary's dependency tree does not enable it. +- Initial state: branch `2876-peer-id-test-helper` with the T5 change (feature, self + dev-dependency, eight consumer `[dev-dependencies]` entries), uncommitted at the time of the run. +- Status: `DONE` (repeated on the final code in T9) + +#### Steps Performed + +1. `cargo run -q -p shipped-features-check -- --package torrust-tracker` (stable Rust toolchain, + cargo 1.99.1). +2. `cargo tree -p torrust-tracker -e normal,build,features -i torrust-tracker-primitives`, then + `grep -c 'feature "testing"'` on its output. + +#### Observed Result + +```text +shipped-features exit=0 +{"kind":"checked","message":"no workspace package has the `testing` feature enabled in the dependency tree of shipped package `torrust-tracker`","shipped_package":"torrust-tracker","feature":"testing","exit_code":0} +tree exit=0 +0 +``` + +The tree's first lines show only the `default` feature: + +```text +torrust-tracker-primitives v3.1.0 (.../packages/primitives) +└── torrust-tracker-primitives feature "default" + ├── torrust-tracker v3.0.0-develop (...) +``` + +#### Conclusion + +Met. The check exits 0 and the tree has no `testing` feature of `primitives`. + ## Failures and Follow-up None so far. diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index e58c06f129..c1a8f7cbe4 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:09" +last-updated-utc: "2026-11-16 16:18" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -131,3 +131,31 @@ it's marked `compile_fail`"; 3 passed, 1 failed. The file was restored (`cmp` ag Removing a public item is a breaking change for the published `torrust-tracker-primitives` 3.0.0. The crate already owes a major release (4.0.0, for #2454) in the #2583 plan; this removal adds to it. + +## `testing` Feature (T5) + +Q2 and Q5: `peer::fixture` (with `PeerBuilder`, `qbittorrent_peer_id` and the `Default` impls of +`Peer` and `Id`) is compiled only with the new `testing` feature of `primitives`. + +- `primitives/Cargo.toml`: `testing = [ ]`, not in `default`, with the rule A.6 comment; the + path-only self dev-dependency (rule A.3). The module's doc comment says it is test support outside + semver. +- `cargo check -p torrust-tracker-primitives` (no features) exits 0. +- Consumers. `cargo test --workspace --no-run` passed without any consumer entry, because the self + dev-dependency unifies the feature on for every member (the ADR's V4 note). Building each of the + 34 members on its own (`cargo test -q -p --no-run`) found the eight that need it, with + `E0432` (`peer::fixture` unresolved) or `E0599` (`Peer::default` missing): `torrust-tracker` + (`src/app.rs`), `axum-http-server`, `axum-rest-api-server`, `http-core` (`src/event.rs`), + `swarm-coordination-registry`, `torrent-repository-benchmarking`, `udp-core` and `udp-server`. + That is the six packages of the inventory plus the two that Q5 names. Each got + `torrust-tracker-primitives = { version = "3.0.0", path = ..., features = [ "testing" ] }` under + `[dev-dependencies]`, and all eight then built on their own. No `[dependencies]` entry enables + `testing`. +- `cargo machete --with-metadata` first reported the self dev-dependency as unused (no code in + `primitives` names the crate by its package name: it has no `tests/` folder) and warned that the + ignored `quickcheck` is used (T2's test imports `quickcheck::TestResult`). The ignore list now + names the self dev-dependency, with the reason, instead of `quickcheck`; machete is clean. +- `cargo package -p torrust-tracker-primitives --no-verify --allow-dirty` exits 0, and the packaged + `Cargo.toml` has `testing = []` and no self dev-dependency (ADR criterion 5). +- `cargo test -q --workspace` (stable Rust toolchain, cargo 1.99.1): 4,087 passed, 0 failed. +- M2 (`manual-verification-evidence.md`, V2): the shipped-features check exits 0. diff --git a/packages/axum-http-server/Cargo.toml b/packages/axum-http-server/Cargo.toml index 3241134880..faf303d984 100644 --- a/packages/axum-http-server/Cargo.toml +++ b/packages/axum-http-server/Cargo.toml @@ -57,6 +57,7 @@ serde_bytes = "0" rustls = { version = "0.23", default-features = false, features = [ "ring" ] } tokio = { version = "1", features = [ "io-util", "time" ] } tokio-rustls = { version = "0.26", default-features = false, features = [ "ring" ] } +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } tower = { version = "0", features = [ "util" ] } torrust-peer-id = "0.1.0" torrust-tracker-client-lib = { version = "0.1.0", path = "../tracker-client" } diff --git a/packages/axum-rest-api-server/Cargo.toml b/packages/axum-rest-api-server/Cargo.toml index 248b6cc098..a76c0cebfe 100644 --- a/packages/axum-rest-api-server/Cargo.toml +++ b/packages/axum-rest-api-server/Cargo.toml @@ -75,6 +75,7 @@ rustls = { version = "0.23", default-features = false, features = [ "ring" ] } tempfile = "3.27.0" tokio = { version = "1", features = [ "io-util", "time" ] } tokio-rustls = { version = "0.26", default-features = false, features = [ "ring" ] } +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } torrust-tracker-rest-api-client = { version = "0.1.0", path = "../rest-api-client" } torrust-tracker-test-helpers = { version = "3.0.0", path = "../test-helpers" } tower = { version = "0", features = [ "util" ] } diff --git a/packages/http-core/Cargo.toml b/packages/http-core/Cargo.toml index 610d09dff2..7d77796f22 100644 --- a/packages/http-core/Cargo.toml +++ b/packages/http-core/Cargo.toml @@ -39,6 +39,7 @@ criterion = { version = "0.5.1", features = [ "async_tokio" ] } mockall = "0" rstest = "0.28.0" torrust-tracker-core = { version = "0.1.0", path = "../tracker-core", features = [ "testing" ] } +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } torrust-tracker-test-helpers = { version = "3.0.0", path = "../test-helpers" } [[bench]] diff --git a/packages/primitives/Cargo.toml b/packages/primitives/Cargo.toml index 42f34df9b2..00d05782f3 100644 --- a/packages/primitives/Cargo.toml +++ b/packages/primitives/Cargo.toml @@ -17,6 +17,13 @@ version = "3.1.0" [lints] workspace = true +[features] +default = [ ] +# Test support outside the semver guarantees of this package: the peer fixture in `peer::fixture` (`PeerBuilder`, +# `qbittorrent_peer_id` and the `Default` impls of `Peer` and `peer::Id`), which the tests of other workspace packages +# use. Never enable it from a `[dependencies]` entry. +testing = [ ] + [dependencies] torrust-peer-id = "0.1.0" binascii = "0" @@ -34,7 +41,9 @@ url = "2" quickcheck = { version = "1", default-features = false } quickcheck_macros = "1" serde_json = "1" +torrust-tracker-primitives = { path = ".", features = [ "testing" ] } [package.metadata.cargo-machete] -# The `#[quickcheck]` attribute expands to code that calls the `quickcheck` crate, which machete cannot see. -ignored = [ "quickcheck" ] +# The self dev-dependency only turns on the `testing` feature for this package's own tests (ADR +# 20261021190318, rule A.3); no code names the crate by its package name, so machete cannot see the use. +ignored = [ "torrust-tracker-primitives" ] diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index 0e2d6084c5..7b7daeffa9 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -354,7 +354,8 @@ pub enum IdConversionError { /// ``` /// /// There is no constructor from a number: tests that need many distinct ids use -/// `peer::fixture::qbittorrent_peer_id`, which makes ids a real client could send. +/// `peer::fixture::qbittorrent_peer_id` (behind the `testing` feature), which makes ids a real +/// client could send. /// /// ```compile_fail,E0599 /// use torrust_tracker_primitives::peer::Id; @@ -498,6 +499,12 @@ impl FromIterator for Vec

{ } } +/// Test support: peers, peer ids and the `Default` impls of [`Peer`] and [`Id`], for this crate's +/// tests and the tests of other workspace packages. +/// +/// Compiled only with the `testing` feature, which is outside the semver guarantees of this crate. +/// Enable it only from a `[dev-dependencies]` entry. +#[cfg(feature = "testing")] pub mod fixture { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; diff --git a/packages/swarm-coordination-registry/Cargo.toml b/packages/swarm-coordination-registry/Cargo.toml index 7a711ace7e..fdd05e8ca8 100644 --- a/packages/swarm-coordination-registry/Cargo.toml +++ b/packages/swarm-coordination-registry/Cargo.toml @@ -35,3 +35,4 @@ tracing = "0" mockall = "0" rstest = "0" tokio = { version = "1", features = [ "test-util" ] } +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } diff --git a/packages/torrent-repository-benchmarking/Cargo.toml b/packages/torrent-repository-benchmarking/Cargo.toml index 5705ca4f83..4c9497987e 100644 --- a/packages/torrent-repository-benchmarking/Cargo.toml +++ b/packages/torrent-repository-benchmarking/Cargo.toml @@ -30,6 +30,7 @@ torrust-tracker-primitives = { version = "3.0.0", path = "../primitives" } [dev-dependencies] criterion = { version = "0", features = [ "async_tokio" ] } rstest = "0" +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } [[bench]] harness = false diff --git a/packages/udp-core/Cargo.toml b/packages/udp-core/Cargo.toml index 5f1d46011e..083a038464 100644 --- a/packages/udp-core/Cargo.toml +++ b/packages/udp-core/Cargo.toml @@ -46,6 +46,7 @@ quickcheck = { version = "1", default-features = false } quickcheck_macros = "1" rstest = "0" torrust-tracker-core = { version = "0.1.0", path = "../tracker-core", features = [ "testing" ] } +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } [[bench]] harness = false diff --git a/packages/udp-server/Cargo.toml b/packages/udp-server/Cargo.toml index e1e46ca2ac..e9ff4ec912 100644 --- a/packages/udp-server/Cargo.toml +++ b/packages/udp-server/Cargo.toml @@ -57,6 +57,7 @@ criterion = { version = "0.5.1", features = [ "async_tokio" ] } mockall = "0" rand = "0.9" tokio = { version = "1", features = [ "test-util" ] } +torrust-tracker-primitives = { version = "3.0.0", path = "../primitives", features = [ "testing" ] } torrust-tracker-test-helpers = { version = "3.0.0", path = "../test-helpers" } torrust-tracker-udp-server = { path = ".", features = [ "testing" ] } From 71d30b4424df9657058169eef7e693e53ac8f1a3 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:22:31 +0000 Subject: [PATCH 07/16] test(primitives): [#2876] build the fixture's peer ids with qbittorrent_peer_id Peer::default, Id::default, PeerBuilder::seeder and PeerBuilder::leecher now use -qB4650-00000000000N ids, which the client registry knows as qBittorrent. No assertion depended on the old bytes. Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 8 +++- .../manual-verification-evidence.md | 37 ++++++++++++++++++- .../test-plans/qbittorrent-peer-id.md | 20 +++++++++- packages/primitives/src/peer.rs | 9 ++--- 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index f5251a86ee..078d30c9e5 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:18" +last-updated-utc: "2026-11-16 16:22" semantic-links: skill-links: - create-issue @@ -343,7 +343,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T3 | DONE | Move the `torrent-repository-benchmarking` callers to the helper | Its tests pass; ids are distinct. | | T4 | DONE | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | | T5 | DONE | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | -| T6 | TODO | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | +| T6 | DONE | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | | T7 | TODO | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | | T8 | TODO | Record the decision (Q7) | ADR amendment, or a note in this spec. | | T9 | TODO | Final verification and acceptance review | `linter all`, tests, manual scenarios, AC table filled in. | @@ -452,6 +452,10 @@ with the narrow affected scope, and sign every commit with GPG. member by member, eight packages needed a `[dev-dependencies]` entry: the six of the inventory plus `http-core` and the root crate (Q5). Machete, packaging, M2 and `cargo test --workspace` (4,087 passed) are green (`test-plans/qbittorrent-peer-id.md`, `testing` Feature). +- 2026-11-16 16:22 UTC - Claude Code (Opus 5.5) - T6: the fixture's three ids are + `qbittorrent_peer_id(0)`, `(1)` and `(2)`. No assertion depended on the old bytes: with the ids + changed, `cargo test --workspace` still passed 4,087 tests. M3 (V3): every fixture id names + qBittorrent. ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md index decf8c1a0e..7a7734b0dc 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md -last-updated-utc: 2026-11-16 16:18 +last-updated-utc: 2026-11-16 16:22 --- # Manual Verification Evidence @@ -128,6 +128,41 @@ torrust-tracker-primitives v3.1.0 (.../packages/primitives) Met. The check exits 0 and the tree has no `testing` feature of `primitives`. +### V3 - Realistic ids (M3) + +- Goal: show that the fixture's ids and the helper's ids name a client, unlike the ids of V0. +- Initial state: branch `2876-peer-id-test-helper` with the T6 change (the fixture ids built with + `qbittorrent_peer_id`), uncommitted at the time of the run. +- Status: `DONE` + +#### Steps Performed + +1. Created a temporary, untracked integration test `packages/primitives/tests/scratch_2876.rs` that + prints the bytes and `get_client_name()` of `Id::default()`, `Peer::default()`, the ids of + `PeerBuilder::seeder()` and `PeerBuilder::leecher()`, and `qbittorrent_peer_id` for 1, 1000 and + `u32::MAX`. +2. `cargo test -q -p torrust-tracker-primitives --test scratch_2876 -- --nocapture` (stable Rust + toolchain, cargo 1.99.1), exit 0. The self dev-dependency turns `testing` on. +3. `rm -r packages/primitives/tests`; `git status -s` then listed only the T6 change to + `packages/primitives/src/peer.rs`. + +#### Observed Result + +```text +Id::default() bytes=-qB4650-000000000000 client=Some("qBittorrent") +Peer::default() bytes=-qB4650-000000000000 client=Some("qBittorrent") +PeerBuilder::seeder() bytes=-qB4650-000000000001 client=Some("qBittorrent") +PeerBuilder::leecher() bytes=-qB4650-000000000002 client=Some("qBittorrent") +qbittorrent_peer_id(1) bytes=-qB4650-000000000001 client=Some("qBittorrent") +qbittorrent_peer_id(1000) bytes=-qB4650-000000001000 client=Some("qBittorrent") +qbittorrent_peer_id(u32::MAX) bytes=-qB4650-004294967295 client=Some("qBittorrent") +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s +``` + +#### Conclusion + +Met. Every id names qBittorrent; in V0 the old fixture ids and the `Id::new` ids gave `None`. + ## Failures and Follow-up None so far. diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index c1a8f7cbe4..7dc2a59daf 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:18" +last-updated-utc: "2026-11-16 16:22" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -159,3 +159,21 @@ Q2 and Q5: `peer::fixture` (with `PeerBuilder`, `qbittorrent_peer_id` and the `D `Cargo.toml` has `testing = []` and no self dev-dependency (ADR criterion 5). - `cargo test -q --workspace` (stable Rust toolchain, cargo 1.99.1): 4,087 passed, 0 failed. - M2 (`manual-verification-evidence.md`, V2): the shipped-features check exits 0. + +## Realistic Fixture Ids (T6) + +Q6: the fixture's three ids are built with the helper: `Peer::default()` and `Id::default()` use +`qbittorrent_peer_id(0)`, `PeerBuilder::seeder()` uses 1 and `PeerBuilder::leecher()` uses 2 (the +same numbering as the old `-qB0000000000000000N` ids). The `const fn` builders take the bytes with +`qbittorrent_peer_id(n).data`. + +Assertions on the old bytes, listed before the change: the spec expected some in the +`axum-http-server` and `axum-rest-api-server` tests. A search for the old literals and their hex +(`grep -rn -E 'qB0000000000000000[012]|2d7142303030...'`) finds 30 files outside `peer.rs`, but those +are ids written by hand, which Q6 leaves out of scope. To find the assertions that read bytes the +fixture makes, the three ids were changed first and `cargo test -q --workspace --no-fail-fast` was +run (stable Rust toolchain, cargo 1.99.1): 4,087 passed, 0 failed, the same count as after T5. So no +assertion depends on the fixture's id bytes; the tests that read them compare against values taken +from the same fixture. Nothing else needed to change. + +M3 (`manual-verification-evidence.md`, V3): every fixture id now names qBittorrent. diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index 7b7daeffa9..8857e78248 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -524,7 +524,7 @@ pub mod fixture { #[must_use] pub const fn seeder() -> Self { let peer = Peer { - peer_id: PeerId(*b"-qB00000000000000001"), + peer_id: qbittorrent_peer_id(1).data, peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080), updated: DurationSinceUnixEpoch::new(1_669_397_478_934, 0), uploaded: NumberOfBytes::new(0), @@ -540,7 +540,7 @@ pub mod fixture { #[must_use] pub const fn leecher() -> Self { let peer = Peer { - peer_id: PeerId(*b"-qB00000000000000002"), + peer_id: qbittorrent_peer_id(2).data, peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)), 8080), updated: DurationSinceUnixEpoch::new(1_669_397_478_934, 0), uploaded: NumberOfBytes::new(0), @@ -651,7 +651,7 @@ pub mod fixture { impl Default for Peer { fn default() -> Self { Self { - peer_id: PeerId(*b"-qB00000000000000000"), + peer_id: qbittorrent_peer_id(0).data, peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080), updated: DurationSinceUnixEpoch::new(1_669_397_478_934, 0), uploaded: NumberOfBytes::new(0), @@ -664,8 +664,7 @@ pub mod fixture { impl Default for Id { fn default() -> Self { - let data = PeerId(*b"-qB00000000000000000"); - Self { data } + qbittorrent_peer_id(0) } } } From 19ed9683f8c2a6dec0c39e3fa8cf3aea23dacf38 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:25:03 +0000 Subject: [PATCH 08/16] test(primitives): [#2876] cover the peer fixture's builder and Default impls 14 unit tests: the default Peer and Id, and each PeerBuilder method changing only its own field. The fixture has no uncovered line left. Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 8 +- .../coverage-evidence.md | 21 ++ .../test-plans/qbittorrent-peer-id.md | 52 ++++- packages/primitives/src/peer.rs | 202 ++++++++++++++++++ 4 files changed, 280 insertions(+), 3 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 078d30c9e5..81623a945d 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:22" +last-updated-utc: "2026-11-16 16:24" semantic-links: skill-links: - create-issue @@ -344,7 +344,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T4 | DONE | Remove or deprecate `Id::new` (Q3) | `compile_fail` doctest if removed. | | T5 | DONE | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | | T6 | DONE | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | -| T7 | TODO | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | +| T7 | DONE | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | | T8 | TODO | Record the decision (Q7) | ADR amendment, or a note in this spec. | | T9 | TODO | Final verification and acceptance review | `linter all`, tests, manual scenarios, AC table filled in. | @@ -456,6 +456,10 @@ with the narrow affected scope, and sign every commit with GPG. `qbittorrent_peer_id(0)`, `(1)` and `(2)`. No assertion depended on the old bytes: with the ids changed, `cargo test --workspace` still passed 4,087 tests. M3 (V3): every fixture id names qBittorrent. +- 2026-11-16 16:24 UTC - Claude Code (Opus 5.5) - T7: 14 fixture tests (the two `Default` impls and + every `PeerBuilder` setter), each setter guarded by a mutation. `primitives` is at 1,270 / 1,273 + lines; the 3 uncovered lines are #2824's dead `Display` branch and two test-only lines + (`coverage-evidence.md`). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md index dba6690c26..a6da51b468 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md @@ -46,6 +46,27 @@ Line numbers are those of `develop` at `c8b1477ad`. `PeerBuilder::seeder`, `leecher`, `build` and `into` are already covered by #2824's tests. +## After T7 (fixture tests), 2026-11-16 + +Measured on branch `2876-peer-id-test-helper` with the T7 tests in the working tree (after the +commit with subject `test(primitives): [#2876] build the fixture's peer ids with qbittorrent_peer_id`), +same command and toolchain as the baseline (separate `CARGO_LLVM_COV_TARGET_DIR`), unit-only: + +| Scope | Tests | Lines | Regions | Functions | +| --- | ---: | ---: | ---: | ---: | +| Unit-only (`--lib`) | 125 unit | 1,270 / 1,273 (99.76%) | 1,920 / 1,925 (99.74%) | 242 / 242 (100.00%) | + +`peer.rs` is 699 / 702 lines (baseline 504 / 572). `Id::new` is gone (T4); the new lines are +`qbittorrent_peer_id`, its tests and the fixture tests. The 3 uncovered lines: + +| Line | Code | Owner / decision | +| --- | --- | --- | +| 417 | `Display for Id`, the `None` branch | #2824 (dead branch); not F5 | +| 1087 | The failure message of the `qbittorrent_peer_id` format test | No test: test code that runs only when the assertion fails | +| 1100 | `TestResult::discard()` in the distinctness property | No test: test code that runs only when quickcheck draws two equal numbers | + +No line owned by F5 is left uncovered in production or fixture code. + ## Final Measurement (T9) Pending. diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index 7dc2a59daf..423f9d992a 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:22" +last-updated-utc: "2026-11-16 16:24" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -177,3 +177,53 @@ assertion depends on the fixture's id bytes; the tests that read them compare ag from the same fixture. Nothing else needed to change. M3 (`manual-verification-evidence.md`, V3): every fixture id now names qBittorrent. + +## Fixture Tests (T7) + +14 unit tests in `peer.rs`, for the fixture lines the baseline left uncovered (the `PeerBuilder` +setters and the two `Default` impls): + +- `peer_fixture_defaults` (2): the exact default `Peer` (every field written out by hand) and the + default `Id` (`-qB4650-000000000000`, named qBittorrent). +- `peer_builder` (12): `PeerBuilder::default()` gives `Peer::default()`; each of the ten setters + (`with_peer_id`, `with_peer_addr`, `with_peer_address`, `updated_on`, `last_updated_on`, + `with_bytes_left_to_download`, `with_no_bytes_left_to_download`, `with_event`, + `with_event_started`, `with_event_completed`) changes its own field and nothing else; `into` + gives the same peer as `build`. + +`cargo test -q -p torrust-tracker-primitives --lib` (stable Rust toolchain, cargo 1.99.1): 125 +passed (111 before). Clippy (`--all-targets --all-features -- -D warnings`) is clean. Coverage: +`coverage-evidence.md`, "After T7". + +Mutations (applied, checked to compile, restored with `cmp`; `cargo test -q -p +torrust-tracker-primitives --lib peer_builder`): + +| Mutation | Failed test | +| --- | --- | +| MB1: `with_event_started` sets `Completed` | `it_should_set_the_started_event_for_a_peer_that_had_completed` | +| MB2: `with_no_bytes_left_to_download` sets 1 | `it_should_set_no_bytes_left_to_download_for_a_peer_that_had_bytes_left` | +| MB3: `with_peer_addr` ignores its argument and sets the default address | `it_should_set_the_peer_address_from_a_reference` | +| MB4: `last_updated_on` also sets the event to `None` (the "nothing else" clause) | `it_should_set_the_last_update_time_with_last_updated_on` | + +A first form of MB3 (dropping the assignment) did not compile, because `mut self` became unused +under `-D warnings`; it was rewritten as above and re-run. + +Prose-first AAA review of the setter tests: + +- Arrange: a peer whose field differs from the value the setter writes: the default peer, or the + seeder (event `Completed`) for `with_event_started` and the leecher (10 bytes left) for + `with_no_bytes_left_to_download`, where the default peer already has the target value. +- Act: one builder call, then `build`. +- Assert: the built peer equals the starting peer with only that field changed + (`Peer { field, ..start }`). + +The code says this without comments. Two tests start from a fixture whose relevant field is not +obvious, so they first assert the starting value, with a message, so that a change to the seeder or +the leecher fails there and not as a false pass. The struct-update expectation takes the other fields +from the fixture used by the Act (the skill's rule against duplicated fixture-derived expectations); +the default `Peer` itself is pinned by a test with every field written out. The duplicated setters +(`with_peer_addr` / `with_peer_address`, `updated_on` / `last_updated_on`, `build` / `into`) are +tested as they are; whether to merge them is not in this issue's scope. + +Smells checked: no complex Arrange, no hidden Act, no production-derived expectation. Like the other +short tests in `peer.rs`, the sections are separated by blank lines, not `// Arrange` comments. diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index 8857e78248..7e0bb423f1 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -1104,6 +1104,208 @@ pub mod test { } } + mod peer_fixture_defaults { + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + + use torrust_clock::DurationSinceUnixEpoch; + + use crate::peer::{Id, Peer}; + use crate::{AnnounceEvent, NumberOfBytes, PeerId}; + + #[test] + fn it_should_make_a_default_peer_that_has_started_with_nothing_left_to_download_from_localhost() { + assert_eq!( + Peer::default(), + Peer { + peer_id: PeerId(*b"-qB4650-000000000000"), + peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), 8080), + updated: DurationSinceUnixEpoch::new(1_669_397_478_934, 0), + uploaded: NumberOfBytes::new(0), + downloaded: NumberOfBytes::new(0), + left: NumberOfBytes::new(0), + event: AnnounceEvent::Started, + } + ); + } + + #[test] + fn it_should_make_a_default_peer_id_that_names_qbittorrent() { + let id = Id::default(); + + assert_eq!(id.0, *b"-qB4650-000000000000"); + assert_eq!(id.get_client_name().as_deref(), Some("qBittorrent")); + } + } + + /// Each builder method changes its own field and leaves every other field as it was. + mod peer_builder { + use std::net::{IpAddr, Ipv4Addr, SocketAddr}; + + use torrust_clock::DurationSinceUnixEpoch; + + use crate::peer::Peer; + use crate::peer::fixture::PeerBuilder; + use crate::{AnnounceEvent, NumberOfBytes, PeerId}; + + fn another_address() -> SocketAddr { + SocketAddr::new(IpAddr::V4(Ipv4Addr::new(126, 0, 0, 1)), 6969) + } + + fn another_time() -> DurationSinceUnixEpoch { + DurationSinceUnixEpoch::new(1_700_000_000, 0) + } + + #[test] + fn it_should_start_from_the_default_peer() { + assert_eq!(PeerBuilder::default().build(), Peer::default()); + } + + #[test] + fn it_should_set_the_peer_id() { + let peer_id = PeerId(*b"-qB4650-000000000042"); + + let peer = PeerBuilder::default().with_peer_id(&peer_id).build(); + + assert_eq!( + peer, + Peer { + peer_id, + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_the_peer_address_from_a_reference() { + let peer = PeerBuilder::default().with_peer_addr(&another_address()).build(); + + assert_eq!( + peer, + Peer { + peer_addr: another_address(), + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_the_peer_address_from_a_value() { + let peer = PeerBuilder::default().with_peer_address(another_address()).build(); + + assert_eq!( + peer, + Peer { + peer_addr: another_address(), + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_the_last_update_time_with_updated_on() { + let peer = PeerBuilder::default().updated_on(another_time()).build(); + + assert_eq!( + peer, + Peer { + updated: another_time(), + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_the_last_update_time_with_last_updated_on() { + let peer = PeerBuilder::default().last_updated_on(another_time()).build(); + + assert_eq!( + peer, + Peer { + updated: another_time(), + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_the_bytes_left_to_download() { + let peer = PeerBuilder::default().with_bytes_left_to_download(5).build(); + + assert_eq!( + peer, + Peer { + left: NumberOfBytes::new(5), + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_no_bytes_left_to_download_for_a_peer_that_had_bytes_left() { + let leecher = PeerBuilder::leecher().build(); + assert_ne!(leecher.left, NumberOfBytes::new(0), "the leecher must start with bytes left"); + + let peer = PeerBuilder::leecher().with_no_bytes_left_to_download().build(); + + assert_eq!( + peer, + Peer { + left: NumberOfBytes::new(0), + ..leecher + } + ); + } + + #[test] + fn it_should_set_any_announce_event() { + let peer = PeerBuilder::default().with_event(AnnounceEvent::Stopped).build(); + + assert_eq!( + peer, + Peer { + event: AnnounceEvent::Stopped, + ..Peer::default() + } + ); + } + + #[test] + fn it_should_set_the_started_event_for_a_peer_that_had_completed() { + let seeder = PeerBuilder::seeder().build(); + assert_eq!(seeder.event, AnnounceEvent::Completed, "the seeder must start as completed"); + + let peer = PeerBuilder::seeder().with_event_started().build(); + + assert_eq!( + peer, + Peer { + event: AnnounceEvent::Started, + ..seeder + } + ); + } + + #[test] + fn it_should_set_the_completed_event_for_a_peer_that_had_started() { + let peer = PeerBuilder::default().with_event_completed().build(); + + assert_eq!( + peer, + Peer { + event: AnnounceEvent::Completed, + ..Peer::default() + } + ); + } + + #[test] + fn it_should_give_the_same_peer_with_into_as_with_build() { + let peer: Peer = PeerBuilder::leecher().into(); + + assert_eq!(peer, PeerBuilder::leecher().build()); + } + } + mod peer_collection { use std::net::{IpAddr, Ipv4Addr, SocketAddr}; From e2851469d95c17383ea2221d9fa13befab4696d8 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:26:15 +0000 Subject: [PATCH 09/16] docs(adrs): [#2876] amend the test-support ADR for shared fixtures such as peer::fixture Rule D's reasoning covers any fixture other packages' tests use, not only mockall mocks; the ownership map gets a row for peer::fixture, owned by primitives behind its testing feature. Co-Authored-By: Claude Opus 5.5 --- ...pace_test_support_through_testing_features.md | 16 ++++++++++++++++ .../open/2876-1347-peer-id-test-helper/ISSUE.md | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md b/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md index d472d29e5b..4fab280593 100644 --- a/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md +++ b/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md @@ -13,6 +13,8 @@ semantic-links: - "issue #2482" - "issue #2582" - "issue #2618" + - "issue #2876" + - docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md --- @@ -54,6 +56,17 @@ semantic-links: > 3. **Naming.** A file that contains only test code outside a `#[cfg(test)] mod tests` carries the prefix > `test_` (`test_support.rs`, and `tracker-core`'s `test_helpers.rs` and `whitelist/test_helpers.rs`, > which already follow it and need no move). +> +> **Amendment of 2026-11-16 (issue #2876).** The decision stands. Rule D speaks of `mockall` mocks, but its +> reasoning covers any test fixture that other packages' tests use: such a fixture belongs to the crate whose +> types it builds and sits behind that crate's `testing` feature, with the self dev-dependency of rule A.3 for +> the crate's own tests and a `[dev-dependencies]` entry in each consumer (rule A.4). The first fixture moved +> this way is `peer::fixture` of `torrust-tracker-primitives` (`PeerBuilder`, `qbittorrent_peer_id` and the +> `Default` impls of `Peer` and `peer::Id`), which #2482 did not find because its inventory searched for +> plural module names such as `fixtures`. Trait impls inside such a module (here `Default`) are gated with it, +> so they leave production builds too. The ownership map has a row for it. The maintainer decided this on +> 2026-11-16 (the answers to Q2, Q5 and Q7 in the +> [#2876 spec](../issues/open/2876-1347-peer-id-test-helper/ISSUE.md)). ## Scope @@ -256,6 +269,7 @@ package's environment. | REST API environment | `axum-rest-api-server` | Own `tests/`, `axum-health-check-api-server` tests | `axum-rest-api-server` `testing` feature | | Health check API environment | `axum-health-check-api-server` | Own `tests/` | `axum-health-check-api-server` `testing` feature | | `MockTorrentMetricsStore` and the other `tracker-core` database mocks | `tracker-core` | Own `src/`; `http-core` and `udp-core` unit tests (`MockTorrentMetricsStore`) | `tracker-core` `testing` feature | +| Peer fixture (`peer::fixture`: `PeerBuilder`, `qbittorrent_peer_id`, the `Default` impls of `Peer` and `peer::Id`); added by the amendment of 2026-11-16 | `primitives` | Own `src/` unit tests; `src/` unit tests, `tests/` or benches of `axum-http-server`, `axum-rest-api-server`, `http-core`, `swarm-coordination-registry`, `torrent-repository-benchmarking`, `udp-core`, `udp-server` and the root crate | `primitives` `testing` feature | | Ephemeral configurations, test logging, random strings | `test-helpers` (generic) | Seven packages | `[dev-dependencies]` entry | | Protocol client helpers (`http`, `udp` modules today) | The root crate's `tests/common/` | The root crate's integration tests | Not shared | @@ -342,3 +356,5 @@ so it is not an example of public test infrastructure. DEC-18 in the - #2582, the packaging failure caused by a self dev-dependency with a `version` - [Independent package versioning](20260629000000_adopt_independent_package_versioning.md) - [`deny.toml`](../../deny.toml), the layer boundary rules referenced by rule B +- [#2876 spec](../issues/open/2876-1347-peer-id-test-helper/ISSUE.md), which moved `peer::fixture` + behind the `testing` feature of `primitives` (amendment of 2026-11-16) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 81623a945d..2e06946d2e 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:24" +last-updated-utc: "2026-11-16 16:26" semantic-links: skill-links: - create-issue @@ -345,7 +345,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T5 | DONE | Gate `peer::fixture` (and the `Default` impls, Q5) behind `testing` (Q2) | Feature in `primitives/Cargo.toml` with the semver comment of ADR rule A.6, self dev-dependency, consumer `[dev-dependencies]`; `cargo machete --with-metadata` clean. | | T6 | DONE | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | | T7 | DONE | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | -| T8 | TODO | Record the decision (Q7) | ADR amendment, or a note in this spec. | +| T8 | DONE | Record the decision (Q7) | ADR amendment, or a note in this spec. | | T9 | TODO | Final verification and acceptance review | `linter all`, tests, manual scenarios, AC table filled in. | ## Commit Points @@ -460,6 +460,9 @@ with the narrow affected scope, and sign every commit with GPG. every `PeerBuilder` setter), each setter guarded by a mutation. `primitives` is at 1,270 / 1,273 lines; the 3 uncovered lines are #2824's dead `Display` branch and two test-only lines (`coverage-evidence.md`). +- 2026-11-16 16:26 UTC - Claude Code (Opus 5.5) - T8: the test-support ADR is amended (Q7): rule + D's reasoning covers shared fixtures, and the ownership map has a row for `peer::fixture`, owned by + `primitives` and reached through its `testing` feature. ## Acceptance Criteria From 50e59b343ef0985f92cc6c48b7112571bfd7cc40 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:30:33 +0000 Subject: [PATCH 10/16] docs(issues): [#2876] record the final verification, acceptance criteria and retrospective (T9) Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 66 +++++++++-------- .../coverage-evidence.md | 15 +++- .../implementation-retrospective.md | 72 +++++++++++++++++++ .../manual-verification-evidence.md | 28 ++++++-- 4 files changed, 144 insertions(+), 37 deletions(-) create mode 100644 docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 2e06946d2e..a85fcb204f 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:26" +last-updated-utc: "2026-11-16 16:29" semantic-links: skill-links: - create-issue @@ -346,7 +346,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | T6 | DONE | Make the fixture's ids realistic (Q6) | Assertions on the old bytes listed first, then updated. | | T7 | DONE | Tests or a no-test decision for every remaining fixture line | Issue-local `coverage-evidence.md` (see Coverage Evidence) shows no line owned by F5 left uncovered. | | T8 | DONE | Record the decision (Q7) | ADR amendment, or a note in this spec. | -| T9 | TODO | Final verification and acceptance review | `linter all`, tests, manual scenarios, AC table filled in. | +| T9 | DONE | Final verification and acceptance review | `linter all`, tests, manual scenarios, AC table filled in. | ## Commit Points @@ -385,14 +385,14 @@ with the narrow affected scope, and sign every commit with GPG. - [x] Open design questions Q1-Q7 answered by the maintainer (before T0) - [x] GitHub issue created (#2876) and issue number added to this spec - [x] (Optional, recommended for complex issues) Spec-only PR merged into `develop` before implementation -- [ ] Implementation completed -- [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) -- [ ] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` -- [ ] Acceptance criteria reviewed after implementation and updated with evidence -- [ ] Evidence-based implementation completion review recorded: issue-local retrospective created for material discoveries, or progress log states why none was needed +- [x] Implementation completed +- [x] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) +- [x] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` +- [x] Acceptance criteria reviewed after implementation and updated with evidence +- [x] Evidence-based implementation completion review recorded: issue-local retrospective created for material discoveries, or progress log states why none was needed - [ ] Reviewer validated acceptance criteria and updated checkboxes - [ ] Independent reviewer reports recorded in issue-local `agent-review-reports.md` when reviewers received this folder-style specification -- [ ] Committer verified spec progress is up to date before commit +- [x] Committer verified spec progress is up to date before commit - [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` ### Progress Log @@ -463,28 +463,32 @@ with the narrow affected scope, and sign every commit with GPG. - 2026-11-16 16:26 UTC - Claude Code (Opus 5.5) - T8: the test-support ADR is amended (Q7): rule D's reasoning covers shared fixtures, and the ownership map has a row for `peer::fixture`, owned by `primitives` and reached through its `testing` feature. +- 2026-11-16 16:29 UTC - Claude Code (Opus 5.5) - T9: `linter all`, M1 and M2 on the final code, + `cargo machete --with-metadata`, `cargo package --workspace --no-verify` and + `cargo test --workspace` (4,101 passed) are green; final coverage 1,274 / 1,277 lines. Acceptance + criteria filled in; retrospective recorded. Ready for the pull request. ## Acceptance Criteria -- [ ] AC1: The caller inventory and the compile proof are re-run at implementation start and at the +- [x] AC1: The caller inventory and the compile proof are re-run at implementation start and at the end, and show that no library or binary target uses `Id::new` or the fixture. -- [ ] AC2: `Id::new` is no longer part of the unconditional public API of `primitives`, as decided +- [x] AC2: `Id::new` is no longer part of the unconditional public API of `primitives`, as decided in Q3. -- [ ] AC3: A test helper builds peer ids that the client registry recognizes +- [x] AC3: A test helper builds peer ids that the client registry recognizes (`get_client_name()` is `Some`), gives distinct ids for distinct inputs, and has unit tests. -- [ ] AC4: The `torrent-repository-benchmarking` tests use the helper and pass. -- [ ] AC5: The Q2 and Q5 decisions are applied: either `cargo check -p torrust-tracker-primitives` +- [x] AC4: The `torrent-repository-benchmarking` tests use the helper and pass. +- [x] AC5: The Q2 and Q5 decisions are applied: either `cargo check -p torrust-tracker-primitives` without features compiles no fixture code and every consumer enables `testing` only from `[dev-dependencies]`, or the spec records why the fixture stays unconditional. -- [ ] AC6: Every line of the helper and of the fixture that remains is covered by a unit test or has +- [x] AC6: Every line of the helper and of the fixture that remains is covered by a unit test or has a recorded no-test decision; issue-local `coverage-evidence.md` shows no uncovered line owned by F5. -- [ ] AC7: The decision is recorded as Q7 says. -- [ ] `linter all` exits with code `0` -- [ ] Relevant tests pass -- [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` -- [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior -- [ ] Documentation is updated when behavior/workflow changes +- [x] AC7: The decision is recorded as Q7 says. +- [x] `linter all` exits with code `0` +- [x] Relevant tests pass +- [x] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` +- [x] Acceptance criteria are re-reviewed after implementation and reflect actual behavior +- [x] Documentation is updated when behavior/workflow changes ## Verification Plan @@ -505,9 +509,9 @@ Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. | ID | Scenario | Human-oriented command/steps | Expected Result | Status | Evidence | | --- | -------- | ---------------------------- | --------------- | ------ | -------- | -| M1 | Production builds need no test support | Before the change: the throwaway gate and `cargo check --workspace --lib --bins`. After: the same command on the final code, no throwaway change. | Exit code 0 both times | TODO | `manual-verification-evidence.md` section V1 | -| M2 | The release tracker carries no `testing` feature of `primitives` (if Q2 is yes) | `cargo run -p shipped-features-check -- --package torrust-tracker`, and as the readable view `cargo tree -p torrust-tracker -e normal,build,features -i torrust-tracker-primitives` | The check exits 0; the tree shows no `testing` feature of `primitives` | TODO | `manual-verification-evidence.md` section V2 | -| M3 | Realistic ids | Print a few helper ids and their `get_client_name()` in a scratch test; compare with the old fixture ids | New ids name a client; old ones give `None` | TODO | `manual-verification-evidence.md` section V3 | +| M1 | Production builds need no test support | Before the change: the throwaway gate and `cargo check --workspace --lib --bins`. After: the same command on the final code, no throwaway change. | Exit code 0 both times | DONE | `manual-verification-evidence.md` section V1 | +| M2 | The release tracker carries no `testing` feature of `primitives` (if Q2 is yes) | `cargo run -p shipped-features-check -- --package torrust-tracker`, and as the readable view `cargo tree -p torrust-tracker -e normal,build,features -i torrust-tracker-primitives` | The check exits 0; the tree shows no `testing` feature of `primitives` | DONE | `manual-verification-evidence.md` section V2 | +| M3 | Realistic ids | Print a few helper ids and their `get_client_name()` in a scratch test; compare with the old fixture ids | New ids name a client; old ones give `None` | DONE | `manual-verification-evidence.md` section V3 | Notes: @@ -541,13 +545,13 @@ commands and output. | AC ID | Status (`TODO`/`DONE`) | Evidence | | ----- | ---------------------- | -------- | -| AC1 | TODO | | -| AC2 | TODO | | -| AC3 | TODO | | -| AC4 | TODO | | -| AC5 | TODO | | -| AC6 | TODO | | -| AC7 | TODO | | +| AC1 | DONE | V1 (baseline at `c8b1477ad` and final run in T9): `cargo check --workspace --lib --bins` exit 0, no warnings; the T1 inventory is unchanged and, at the end, `peer::Id::new` has no caller (`grep`, T3) and no longer exists (T4). | +| AC2 | DONE | Removed (Q3 (a)); the `compile_fail,E0599` doctest on `peer::Id` fails when it is put back (test plan, T4). | +| AC3 | DONE | `peer::fixture::qbittorrent_peer_id`; three unit tests (exact bytes, client name `Some("qBittorrent")` for any `u32`, distinct ids), each guarded by a mutation (test plan, T2). | +| AC4 | DONE | Its builders and the scrape-limit test use the helper; 17 and 1,468 tests pass; a colliding `OTHER_PEER` fails the cutoff test (test plan, T3). | +| AC5 | DONE | `cargo check -p torrust-tracker-primitives` (no features) exit 0; eight consumers enable `testing` only from `[dev-dependencies]`; M2 (V2) exit 0; packaged manifest has no self dev-dependency (test plan, T5). | +| AC6 | DONE | `coverage-evidence.md`: 1,274 / 1,277 lines; the 3 uncovered lines are #2824's dead `Display` branch and two test-only lines with recorded no-test decisions. | +| AC7 | DONE | ADR amendment of 2026-11-16 (rule D's reasoning, ownership-map row for `peer::fixture`). | ## Risks and Trade-offs @@ -565,7 +569,7 @@ After implementation, compare the result with this specification. Record invalidated assumptions, material design changes, unexpected validation findings, and reusable lessons. -- Retrospective: `Not yet assessed` +- Retrospective: [`implementation-retrospective.md`](implementation-retrospective.md) (the workspace build hid missing consumer entries; machete flagged the self dev-dependency, unlike the ADR's O1c note; no assertion depended on the fixture's id bytes) - If needed, create `implementation-retrospective.md` from `docs/templates/IMPLEMENTATION-RETROSPECTIVE.md` in this directory. - If no retrospective is needed, add a concise progress-log entry explaining diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md index a6da51b468..e47c96482b 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/coverage-evidence.md @@ -69,4 +69,17 @@ No line owned by F5 is left uncovered in production or fixture code. ## Final Measurement (T9) -Pending. +Measured on the finished branch (head commit with subject `docs(adrs): [#2876] amend the +test-support ADR for shared fixtures such as peer::fixture`), same commands and toolchain as the +baseline, from a clean `CARGO_LLVM_COV_TARGET_DIR`. Both runs ran the same 125 unit tests (the +package still has no `tests/` folder): + +| Scope | Tests | Lines | Regions | Functions | +| --- | ---: | ---: | ---: | ---: | +| Unit-only (`--lib`) | 125 unit | 1,274 / 1,277 (99.77%) | 1,920 / 1,925 (99.74%) | 242 / 242 (100.00%) | +| Aggregate | 125 unit | 1,274 / 1,277 (99.77%) | 1,920 / 1,925 (99.74%) | 242 / 242 (100.00%) | + +From the baseline: lines +5.72 pp, regions +4.46 pp, functions +5.83 pp. The line count differs from +"After T7" by 4 because the nightly formatter re-wrapped the new tests. `peer.rs` is 703 / 706; the 3 +uncovered lines are the same as after T7 (417, 1087, 1100) with the same owners and decisions. No +uncovered line is owned by F5. diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md b/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md new file mode 100644 index 0000000000..d70c5a4b1f --- /dev/null +++ b/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md @@ -0,0 +1,72 @@ +--- +semantic-links: + skill-links: + - write-markdown-docs + related-artifacts: + - docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md + - docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md +--- + +# Implementation Retrospective — #2876 Peer Id Test Helper + +## Purpose + +Record evidence-based process improvements discovered while implementing #2876. This is a blameless +review of the implementation approach; it does not replace acceptance-criteria verification. + +## Outcome + +`peer::Id::new` is removed (a `compile_fail` doctest guards it). `peer::fixture`, with its new +`qbittorrent_peer_id(u32) -> Id` helper and the `Default` impls of `Peer` and `Id`, compiles only +with the new `testing` feature of `primitives`. Eight consumers enable it from `[dev-dependencies]`. +The fixture's ids are realistic, every fixture line is tested, and the test-support ADR is amended. +Evidence: `test-plans/qbittorrent-peer-id.md`, `manual-verification-evidence.md`, +`coverage-evidence.md`. + +## What Went Well + +1. The red stub that returned today's `Id::new` ids showed which helper tests guard new behavior (the + format and the client name) and which do not (distinct ids, which the old function had too), so + that one got its own mutation. +2. Changing the fixture ids before touching any assertion gave the list of dependent assertions by + running the tests: it was empty, which no text search could have shown. + +## What Changed During Implementation + +- **The workspace build hides missing consumer entries.** `cargo test --workspace --no-run` passed + without any consumer `[dev-dependencies]` entry, because the self dev-dependency of `primitives` + turns `testing` on for every member of a workspace build. Building each of the 34 members on its + own found the eight that need it. The ADR already notes this for per-package runs (O1a, V4); it + mattered here because the consumer list had to be complete. +- **`cargo machete --with-metadata` flagged the self dev-dependency.** The ADR (O1c) says machete + does not flag it. That held for the server packages, whose `tests/` and examples name the crate by + its package name; `primitives` has no `tests/` folder and its `src/` uses `crate::`, so machete saw + no use. The self dev-dependency is now in the package's machete `ignored` list, with the reason. +- **No assertion depended on the fixture's id bytes.** The spec (Q6, T6) expected some in the + `axum-http-server` and `axum-rest-api-server` tests; the tests that read the ids compare them with + values from the same fixture. + +## Root Cause + +The O1c statement about machete was verified on packages that all had integration tests or +examples. The spec's T6 expectation came from a text search for the old literals, which cannot tell +hand-written literals from bytes the fixture produces. + +## Improvements for Future Work + +1. When a `testing` feature gets a self dev-dependency, run `cargo machete --with-metadata` and, + for a package without `tests/` or examples, expect to add the self dev-dependency to its machete + `ignored` list. A note in the ADR's O1c row (or rule A.3) would save the next package the + surprise; proposed to the maintainer, not changed here. +2. To find the consumers of a newly gated module, build each member on its own + (`cargo test -p --no-run`), not the workspace. + +## Avoiding Overcorrection + +No new check is justified: `cargo machete` already fails the commit, and the per-package build is a +one-off step of a gating change, not something CI needs to repeat. + +## Evidence + +- [Issue specification](ISSUE.md), T5 and T6 +- [Test plan](test-plans/qbittorrent-peer-id.md), sections `testing` Feature and Realistic Fixture Ids diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md index 7a7734b0dc..e6861f7ffe 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md -last-updated-utc: 2026-11-16 16:22 +last-updated-utc: 2026-11-16 16:29 --- # Manual Verification Evidence @@ -15,8 +15,8 @@ do not invent commands, output, logs, or results. ## Environment and Prerequisites - Date and time (UTC): 2026-11-16 15:59 -- Artifact under test: `develop` at `c8b1477ad` (the merge of #2878), before any change of this - issue (T1 baseline). +- Artifact under test: `develop` at `c8b1477ad` (the merge of #2878) for the baselines (V0, V1), and + branch `2876-peer-id-test-helper` for V1's final run, V2 and V3, as each section says. - Operating system / environment: Linux 7.0.0-43-generic; stable Rust toolchain, rustc 1.99.1, cargo 1.99.1. - Prerequisites and setup performed: none beyond a checkout of `develop`. @@ -28,7 +28,7 @@ do not invent commands, output, logs, or results. - Goal: show that no library or binary target of the workspace uses `Id::new`, `peer::fixture` (`PeerBuilder`) or the `Default` impls of `Peer` and `Id`. - Initial state: clean checkout of `develop` at `c8b1477ad`. -- Status: `IN_PROGRESS` (the baseline is done; the final run on the finished code is pending, T9) +- Status: `DONE` (baseline above; final run on the finished code below) #### Steps Performed @@ -58,6 +58,21 @@ Met (baseline). With `Id::new` and the fixture module (which holds the `Default` only under `cfg(test)`, every library and binary target of the workspace still compiles, with no warnings. Code outside this workspace that depends on the published 3.0.0 is not covered. +#### Final Run (T9) + +On the finished branch (head commit with subject `docs(adrs): [#2876] amend the test-support ADR +for shared fixtures such as peer::fixture`), with no throwaway change: `Id::new` no longer exists +and `peer::fixture` is behind `testing`, so a plain check is the proof. Run at 16:27 UTC, in one +shell, after `linter all`: + +```text +M1 cargo check --workspace --lib --bins exit=0 warnings=0 +primitives no-features check exit=0 +``` + +(`cargo check -p torrust-tracker-primitives`, no features, is the second line.) Met: no library or +binary target of the workspace needs `Id::new`, the fixture or its `Default` impls. + ### V0 - Reproduction: today's test ids name no client (M3, baseline) - Goal: show that the ids the fixture and `Id::new` make today are not ids a real client sends. @@ -98,7 +113,7 @@ The finding is reproduced: the three fixture ids (`-qB000...`) and the `Id::new` `torrust-tracker` binary's dependency tree does not enable it. - Initial state: branch `2876-peer-id-test-helper` with the T5 change (feature, self dev-dependency, eight consumer `[dev-dependencies]` entries), uncommitted at the time of the run. -- Status: `DONE` (repeated on the final code in T9) +- Status: `DONE` #### Steps Performed @@ -128,6 +143,9 @@ torrust-tracker-primitives v3.1.0 (.../packages/primitives) Met. The check exits 0 and the tree has no `testing` feature of `primitives`. +Repeated on the finished branch in T9 (16:27 UTC): `M2 exit=0` with the same `checked` message, and +`grep -c 'feature "testing"'` on the tree gave `0`. + ### V3 - Realistic ids (M3) - Goal: show that the fixture's ids and the helper's ids name a client, unlike the ids of V0. From 9ade83ea34163f18b542032fe8df5fd18008b765 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:52:59 +0000 Subject: [PATCH 11/16] docs(issues): [#2876] record why the short peer.rs tests carry no AAA markers Review finding F1 of PR 2888. Co-Authored-By: Claude Opus 5.5 --- .../issues/open/2876-1347-peer-id-test-helper/ISSUE.md | 5 ++++- .../test-plans/qbittorrent-peer-id.md | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index a85fcb204f..6184f86013 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:29" +last-updated-utc: "2026-11-16 16:52" semantic-links: skill-links: - create-issue @@ -467,6 +467,9 @@ with the narrow affected scope, and sign every commit with GPG. `cargo machete --with-metadata`, `cargo package --workspace --no-verify` and `cargo test --workspace` (4,101 passed) are green; final coverage 1,274 / 1,277 lines. Acceptance criteria filled in; retrospective recorded. Ready for the pull request. +- 2026-11-16 16:52 UTC - Claude Code (Opus 5.5) - Review round 1 of PR #2888 (da2ce7, approved, F1 + Nit and F2 Suggestion): the test plan records why the short tests have no AAA markers, and the ADR + amendment notes when machete flags the self dev-dependency (`docs/pr-reviews/pr-2888-review/`). ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index 423f9d992a..bda09db03e 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:24" +last-updated-utc: "2026-11-16 16:52" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -77,7 +77,9 @@ The table did not say why these three numbers; a short comment on each case now from the helper. Property tests: each is one expression with the Act and the expected result in view (`Some("qBittorrent")`; -`!=` on the bytes, with equal inputs discarded). Prose added nothing, so none was kept. +`!=` on the bytes, with equal inputs discarded). Prose added nothing, so none was kept, and the +`// Arrange`, `// Act`, `// Assert` markers were left out as redundant: a one-expression property has +no separate sections to mark. Only the format test, whose loop has three sections, carries them. Smells checked: no complex Arrange, no hidden Act, no production-derived expectation. The format test asserts in a loop, but every assertion checks the same behavior and its message names the case. @@ -226,4 +228,6 @@ the default `Peer` itself is pinned by a test with every field written out. The tested as they are; whether to merge them is not in this issue's scope. Smells checked: no complex Arrange, no hidden Act, no production-derived expectation. Like the other -short tests in `peer.rs`, the sections are separated by blank lines, not `// Arrange` comments. +short tests in `peer.rs`, the sections are separated by blank lines; the `// Arrange`, `// Act`, +`// Assert` markers were left out as redundant prose for these one- to three-statement bodies (the +skill's prose-first step 4), a decision recorded here after review finding F1 of PR #2888. From f3aee507b84b358a1379c191cf139fd9ac5dfcc5 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:53:41 +0000 Subject: [PATCH 12/16] docs(adrs): [#2876] say when cargo machete flags a testing self dev-dependency The O1c note holds only when tests or examples name the crate; a package without them lists the self dev-dependency in its machete ignored list. Review finding F2 of PR 2888. Co-Authored-By: Claude Opus 5.5 --- ..._share_workspace_test_support_through_testing_features.md | 5 ++++- .../implementation-retrospective.md | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md b/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md index 4fab280593..3b7f2d89fd 100644 --- a/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md +++ b/docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md @@ -60,7 +60,10 @@ semantic-links: > **Amendment of 2026-11-16 (issue #2876).** The decision stands. Rule D speaks of `mockall` mocks, but its > reasoning covers any test fixture that other packages' tests use: such a fixture belongs to the crate whose > types it builds and sits behind that crate's `testing` feature, with the self dev-dependency of rule A.3 for -> the crate's own tests and a `[dev-dependencies]` entry in each consumer (rule A.4). The first fixture moved +> the crate's own tests and a `[dev-dependencies]` entry in each consumer (rule A.4). The O1c note that +> `cargo machete --with-metadata` does not flag the self dev-dependency holds only when the package's `tests/` +> or examples name the crate by its package name; a package without them, such as `primitives`, lists the self +> dev-dependency in its `[package.metadata.cargo-machete]` `ignored` list, with the reason. The first fixture moved > this way is `peer::fixture` of `torrust-tracker-primitives` (`PeerBuilder`, `qbittorrent_peer_id` and the > `Default` impls of `Peer` and `peer::Id`), which #2482 did not find because its inventory searched for > plural module names such as `fixtures`. Trait impls inside such a module (here `Default`) are gated with it, diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md b/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md index d70c5a4b1f..dad12996d8 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/implementation-retrospective.md @@ -56,8 +56,8 @@ hand-written literals from bytes the fixture produces. 1. When a `testing` feature gets a self dev-dependency, run `cargo machete --with-metadata` and, for a package without `tests/` or examples, expect to add the self dev-dependency to its machete - `ignored` list. A note in the ADR's O1c row (or rule A.3) would save the next package the - surprise; proposed to the maintainer, not changed here. + `ignored` list. The ADR amendment of 2026-11-16 now says so (added after review finding F2 of + PR #2888). 2. To find the consumers of a newly gated module, build each member on its own (`cargo test -p --no-run`), not the workspace. From 20cb3f15621d0fb1b0b7c418558802023beee1ba Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 16:55:28 +0000 Subject: [PATCH 13/16] docs(pr-reviews): [#2876] add the PR 2888 review audit Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2888-review/PR-REVIEW.md | 112 ++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 docs/pr-reviews/pr-2888-review/PR-REVIEW.md diff --git a/docs/pr-reviews/pr-2888-review/PR-REVIEW.md b/docs/pr-reviews/pr-2888-review/PR-REVIEW.md new file mode 100644 index 0000000000..62dd9dd3f2 --- /dev/null +++ b/docs/pr-reviews/pr-2888-review/PR-REVIEW.md @@ -0,0 +1,112 @@ +--- +semantic-links: + skill-links: + - process-pr-review + related-artifacts: + - .github/skills/dev/pr-reviews/process-pr-review/SKILL.md +--- + + + +# PR #2888 Review Audit + +Source: pull-request reviews and inline review threads for https://github.com/torrust/torrust-tracker/pull/2888. + +## Ownership + +The PR author owns this tracked audit record. Reviewers, including repository review agents, +deliver findings through GitHub and have no repository-artifact obligation. + +- Post-merge workflow approval: N/A + +## Status Values + +- Relationship: `ORIGINAL`, `RE_RAISE_OF:` +- Disposition: `FIXED`, `NO_ACTION`, `SUPERSEDED`, `FOLLOW_UP` +- Thread state: `OPEN`, `RESOLVED`, `NON_RESOLVABLE`, `SUPERSEDED`. `OPEN` applies prospectively + to audits created or updated for approved follow-up work; historical audits remain valid without + bulk migration. +- Severity: `Blocker`, `Major`, `Minor`, `Nit`, `Suggestion`; append `(inferred)` when derived + from free prose. +- Author class: `Copilot`, `Human`, `Unknown` +- Category: `link-integrity`, `formatting`, `metadata`, `testing`, `correctness`, + `documentation`, `maintainability`, `security`, `other` +- An outdated thread whose concern was fixed is `FIXED`/`RESOLVED`, even when GitHub marks the + original thread outdated after the push. For in-PR feedback, use `NO_ACTION`/`SUPERSEDED` only + for a duplicate, superseded, or no-change concern. A post-merge `NO_ACTION` requires maintainer + approval to decline the follow-up work. +- When the current identity cannot resolve a thread (`viewerCanResolve` is `false`), keep the + disposition established from the current tree and record `Thread state=OPEN`. The reviewer or PR + author resolves it; permission says nothing about whether the concern was fixed. + +## Findings + +| Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | +| ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | +| F1 | review-finding:pr-2888-f1 | Human | Nit | testing | ORIGINAL | FIXED | RESOLVED | +| F2 | review-finding:pr-2888-f2 | Human | Suggestion | documentation | ORIGINAL | FIXED | RESOLVED | + +## Finding Details + +### F1 - The fixture tests and the two properties carry no AAA markers + +- PR number: 2888 +- Source review ID: 5923877279 +- Reviewer finding ID: F1 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4588718259 +- Concern: The `write-unit-test` checklist asks for `// Arrange` / `// Act` / `// Assert` markers, + and the format test follows it; the 14 fixture tests and the two `#[quickcheck]` properties do + not. The reviewer offered two fixes: add the markers, or record in the test plan that they were + dropped as redundant prose. +- Solution: Recorded the decision in the test plan, for both the properties and the fixture tests: + the markers are redundant prose for one-expression properties and one- to three-statement bodies + (the skill's prose-first step 4), matching the other short tests in `peer.rs`. +- Current-tree verification: `grep -n "markers were left out" docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md` + finds the property note (T2 section) and the fixture-test note (T7 section). +- Resolution reference: docs(issues): [#2876] record why the short peer.rs tests carry no AAA markers +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4588757231 + +### F2 - The amendment leaves the O1c claim that machete does not flag the self dev-dependency + +- PR number: 2888 +- Source review ID: 5923877279 +- Reviewer finding ID: F2 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4588718262 +- Concern: The branch's own retrospective shows that `cargo machete --with-metadata` flagged the + self dev-dependency of `primitives`, a package without `tests/` or examples, but the ADR's O1c row + still says machete does not flag it, and the retrospective deferred the note. +- Solution: The 2026-11-16 amendment says the O1c note holds only when `tests/` or examples name + the crate, and that a package without them lists the self dev-dependency in its machete `ignored` + list with the reason. The retrospective's improvement 1 now points at the amendment. +- Current-tree verification: `grep -n "O1c note" docs/adrs/20261021190318_share_workspace_test_support_through_testing_features.md` + finds the clause in the amendment of 2026-11-16. +- Resolution reference: docs(adrs): [#2876] say when cargo machete flags a testing self dev-dependency +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4588757687 + +## Processing Log + +- 2026-11-16 16:52 UTC - Started audit for review round 1: review 5923877279 (da2ce7, APPROVED, with + ACK, one Nit F1 and one Suggestion F2, neither blocking). The maintainer had posted his ACK on the + same head before the review. Both fixed by commit; the two thread replies posted at 16:53 UTC, + before the push of the fix commits. + +## Completion Rules + +- Re-derive the reply claim against the current tree before replying or resolving a thread. +- Reply on every resolvable thread before resolving it. +- For an outdated thread whose concern was fixed, record `Disposition=FIXED` and + `Thread state=RESOLVED`, even if GitHub marks the thread outdated after the push. For a + duplicate, superseded, or no-change in-PR thread, reply exactly + `Superseded by : .`, record `Disposition=NO_ACTION` and + `Thread state=SUPERSEDED`, then resolve it. A post-merge `NO_ACTION` requires maintainer + approval to decline the follow-up work. When the current identity cannot resolve a thread + (`viewerCanResolve` is `false`), still reply, keep the disposition established from the current + tree, and record `Thread state=OPEN`; the reviewer or PR author resolves it. +- A consolidated PR conversation response may cover multiple review rounds only when it names + every review ID and every finding ID with its disposition and resolution reference. Record its + durable URL in each related row. +- Cite a fix by its unique Conventional Commit subject or durable reply URL, never by a branch SHA + that can change after a rebase. +- Refresh review threads using GraphQL and confirm that no unresolved actionable thread remains. From 90ea4111aaf67750056acd3d3b0869e8e235a0ee Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 17:31:05 +0000 Subject: [PATCH 14/16] docs(issues): [#2876] correct the statement count of the short peer.rs tests Two fixture tests have four statements. Review finding F3 of PR 2888. Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md | 4 +++- .../test-plans/qbittorrent-peer-id.md | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index 6184f86013..bed1211632 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 16:52" +last-updated-utc: "2026-11-16 17:30" semantic-links: skill-links: - create-issue @@ -470,6 +470,8 @@ with the narrow affected scope, and sign every commit with GPG. - 2026-11-16 16:52 UTC - Claude Code (Opus 5.5) - Review round 1 of PR #2888 (da2ce7, approved, F1 Nit and F2 Suggestion): the test plan records why the short tests have no AAA markers, and the ADR amendment notes when machete flags the self dev-dependency (`docs/pr-reviews/pr-2888-review/`). +- 2026-11-16 17:30 UTC - Claude Code (Opus 5.5) - Review round 2 of PR #2888 (da2ce7, approved, F3 + and F4 Nits): the test plan's statement count is corrected (one to four), and the audit's reply time. ## Acceptance Criteria diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md index bda09db03e..6a32e44a5b 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md @@ -4,7 +4,7 @@ issue: 2876 package: torrust-tracker-primitives target-file: packages/primitives/src/peer.rs status: done -last-updated-utc: "2026-11-16 16:52" +last-updated-utc: "2026-11-16 17:30" --- # `peer::fixture::qbittorrent_peer_id` Test Plan (T2) @@ -229,5 +229,6 @@ tested as they are; whether to merge them is not in this issue's scope. Smells checked: no complex Arrange, no hidden Act, no production-derived expectation. Like the other short tests in `peer.rs`, the sections are separated by blank lines; the `// Arrange`, `// Act`, -`// Assert` markers were left out as redundant prose for these one- to three-statement bodies (the -skill's prose-first step 4), a decision recorded here after review finding F1 of PR #2888. +`// Assert` markers were left out as redundant prose for these one- to four-statement bodies (four in the +two tests that first assert their starting fixture; the skill's prose-first step 4), a decision +recorded here after review finding F1 of PR #2888 (count corrected after F3). From a31c219cef4c511b59830d10d519d856c147215c Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 17:32:19 +0000 Subject: [PATCH 15/16] docs(pr-reviews): [#2876] record review round 2 of PR 2888 Adds F3 and F4 and corrects the round-1 reply time (F4). Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2888-review/PR-REVIEW.md | 44 ++++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/docs/pr-reviews/pr-2888-review/PR-REVIEW.md b/docs/pr-reviews/pr-2888-review/PR-REVIEW.md index 62dd9dd3f2..c5de9d2213 100644 --- a/docs/pr-reviews/pr-2888-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2888-review/PR-REVIEW.md @@ -45,6 +45,8 @@ deliver findings through GitHub and have no repository-artifact obligation. | ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | | F1 | review-finding:pr-2888-f1 | Human | Nit | testing | ORIGINAL | FIXED | RESOLVED | | F2 | review-finding:pr-2888-f2 | Human | Suggestion | documentation | ORIGINAL | FIXED | RESOLVED | +| F3 | review-finding:pr-2888-f3 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F4 | review-finding:pr-2888-f4 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -59,7 +61,7 @@ deliver findings through GitHub and have no repository-artifact obligation. not. The reviewer offered two fixes: add the markers, or record in the test plan that they were dropped as redundant prose. - Solution: Recorded the decision in the test plan, for both the properties and the fixture tests: - the markers are redundant prose for one-expression properties and one- to three-statement bodies + the markers are redundant prose for one-expression properties and one- to four-statement bodies (the skill's prose-first step 4), matching the other short tests in `peer.rs`. - Current-tree verification: `grep -n "markers were left out" docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md` finds the property note (T2 section) and the fixture-test note (T7 section). @@ -85,12 +87,50 @@ deliver findings through GitHub and have no repository-artifact obligation. - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4588757687 +### F3 - Two fixture tests have four statements, not one to three + +- PR number: 2888 +- Source review ID: 5924274073 +- Reviewer finding ID: F3 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589031084 +- Concern: The F1 fix described the fixture tests as one- to three-statement bodies, but + `it_should_set_no_bytes_left_to_download_for_a_peer_that_had_bytes_left` and + `it_should_set_the_started_event_for_a_peer_that_had_completed` have four (they first assert their + starting fixture). The F1 reply repeats the count. +- Solution: The test plan and the F1 row now say one- to four-statement bodies, four in the two + tests that assert their starting fixture. The F1 reply cannot be edited; this row records the + correction. +- Current-tree verification: `grep -n "four-statement" docs/issues/open/2876-1347-peer-id-test-helper/test-plans/qbittorrent-peer-id.md docs/pr-reviews/pr-2888-review/PR-REVIEW.md` + finds the T7 note and the F1 solution; `grep -c "three-statement"` on the test plan gives 0 (the + audit keeps the old wording only where F3 quotes it). +- Resolution reference: docs(issues): [#2876] correct the statement count of the short peer.rs tests +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589180027 + +### F4 - The Processing Log puts the round-1 replies one minute early + +- PR number: 2888 +- Source review ID: 5924274073 +- Reviewer finding ID: F4 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589031100 +- Concern: The round-1 entry said the two thread replies were posted at 16:53 UTC; GitHub records + 16:54:26 and 16:54:29 UTC. Their order before the push is right. +- Solution: The round-1 entry now says 16:54 UTC and notes the correction. +- Current-tree verification: `grep -n "16:54 UTC" docs/pr-reviews/pr-2888-review/PR-REVIEW.md` + finds the round-1 entry. +- Resolution reference: docs(pr-reviews): [#2876] record review round 2 of PR 2888 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589180507 + ## Processing Log - 2026-11-16 16:52 UTC - Started audit for review round 1: review 5923877279 (da2ce7, APPROVED, with ACK, one Nit F1 and one Suggestion F2, neither blocking). The maintainer had posted his ACK on the - same head before the review. Both fixed by commit; the two thread replies posted at 16:53 UTC, + same head before the review. Both fixed by commit; the two thread replies posted at 16:54 UTC (corrected in round 2, F4), before the push of the fix commits. +- 2026-11-16 17:32 UTC - Review round 2: review 5924274073 (da2ce7, APPROVED, two Nits F3 and F4, + neither blocking) on the head with the round-1 fixes, which the maintainer ACKed. F3 fixed by + commit, F4 in this audit; the two thread replies posted at 17:31 UTC, before the push. ## Completion Rules From c4def24693f843de3835520fc83d4c5629ff2fd7 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 17:55:45 +0000 Subject: [PATCH 16/16] docs(pr-reviews): [#2876] restore the round-1 log entry and append its correction The F4 fix had rewritten the round-1 Processing Log entry in place; the log is append-only. Review finding F5 of PR 2888. Co-Authored-By: Claude Opus 5.5 --- .../2876-1347-peer-id-test-helper/ISSUE.md | 5 ++- docs/pr-reviews/pr-2888-review/PR-REVIEW.md | 35 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md index bed1211632..85041dc1b3 100644 --- a/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md +++ b/docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2876 spec-path: docs/issues/open/2876-1347-peer-id-test-helper/ISSUE.md branch: "2876-peer-id-test-helper" related-pr: null -last-updated-utc: "2026-11-16 17:30" +last-updated-utc: "2026-11-16 17:55" semantic-links: skill-links: - create-issue @@ -472,6 +472,9 @@ with the narrow affected scope, and sign every commit with GPG. amendment notes when machete flags the self dev-dependency (`docs/pr-reviews/pr-2888-review/`). - 2026-11-16 17:30 UTC - Claude Code (Opus 5.5) - Review round 2 of PR #2888 (da2ce7, approved, F3 and F4 Nits): the test plan's statement count is corrected (one to four), and the audit's reply time. +- 2026-11-16 17:55 UTC - Claude Code (Opus 5.5) - Review round 3 of PR #2888 (da2ce7, approved, F5 + Minor): the audit's round-1 log entry is restored and the F4 time correction is appended as a new + entry, because the log is append-only. ## Acceptance Criteria diff --git a/docs/pr-reviews/pr-2888-review/PR-REVIEW.md b/docs/pr-reviews/pr-2888-review/PR-REVIEW.md index c5de9d2213..36e33e56e8 100644 --- a/docs/pr-reviews/pr-2888-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2888-review/PR-REVIEW.md @@ -47,6 +47,7 @@ deliver findings through GitHub and have no repository-artifact obligation. | F2 | review-finding:pr-2888-f2 | Human | Suggestion | documentation | ORIGINAL | FIXED | RESOLVED | | F3 | review-finding:pr-2888-f3 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | | F4 | review-finding:pr-2888-f4 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F5 | review-finding:pr-2888-f5 | Human | Minor | metadata | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -115,22 +116,48 @@ deliver findings through GitHub and have no repository-artifact obligation. - Source URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589031100 - Concern: The round-1 entry said the two thread replies were posted at 16:53 UTC; GitHub records 16:54:26 and 16:54:29 UTC. Their order before the push is right. -- Solution: The round-1 entry now says 16:54 UTC and notes the correction. +- Solution: A Processing Log correction entry (17:55 UTC) states the correct time, 16:54 UTC. The round-1 entry + keeps its original text, because the log is append-only (finding F5; round 2 had first rewritten + that entry in place). - Current-tree verification: `grep -n "16:54 UTC" docs/pr-reviews/pr-2888-review/PR-REVIEW.md` - finds the round-1 entry. -- Resolution reference: docs(pr-reviews): [#2876] record review round 2 of PR 2888 + finds the correction entry; the round-1 entry still says 16:53 UTC. +- Resolution reference: docs(pr-reviews): [#2876] restore the round-1 log entry and append its correction + (first fixed in place by `docs(pr-reviews): [#2876] record review round 2 of PR 2888`; see F5) - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589180507 +### F5 - The F4 fix rewrote the round-1 Processing Log entry in place + +- PR number: 2888 +- Source review ID: 5924785765 +- Reviewer finding ID: F5 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589413418 +- Concern: `process-pr-review` step 5 and the template say the Processing Log is append-only; an + entry rewritten in place is restored and corrected by a new entry naming the rewritten content. + The F4 fix had rewritten the round-1 entry. +- Solution: The round-1 entry is restored (`16:53 UTC,`), and a new correction entry states the + right time and names the in-place rewrite. The F4 row now describes that fix. +- Current-tree verification: `grep -n "16:53 UTC\|16:54 UTC" docs/pr-reviews/pr-2888-review/PR-REVIEW.md` + shows the restored round-1 entry, the F4 row and the correction entry. +- Resolution reference: docs(pr-reviews): [#2876] restore the round-1 log entry and append its correction +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2888#discussion_r4589431881 + ## Processing Log - 2026-11-16 16:52 UTC - Started audit for review round 1: review 5923877279 (da2ce7, APPROVED, with ACK, one Nit F1 and one Suggestion F2, neither blocking). The maintainer had posted his ACK on the - same head before the review. Both fixed by commit; the two thread replies posted at 16:54 UTC (corrected in round 2, F4), + same head before the review. Both fixed by commit; the two thread replies posted at 16:53 UTC, before the push of the fix commits. - 2026-11-16 17:32 UTC - Review round 2: review 5924274073 (da2ce7, APPROVED, two Nits F3 and F4, neither blocking) on the head with the round-1 fixes, which the maintainer ACKed. F3 fixed by commit, F4 in this audit; the two thread replies posted at 17:31 UTC, before the push. +- 2026-11-16 17:55 UTC - Correction (F4, applied as F5 asks): the round-1 entry above says the two + thread replies were posted at 16:53 UTC; GitHub records 16:54:26 and 16:54:29 UTC, still before + the push. Round 2 first fixed this by rewriting the round-1 entry in place (to "16:54 UTC + (corrected in round 2, F4)"), which broke the append-only rule; review round 3 (review 5924785765, + da2ce7, APPROVED, one Minor finding F5) found it, and the round-1 entry is restored to its original + text. F5 fixed by commit; its thread reply posted before the push. ## Completion Rules