From 6536e18e5e9f52e27c68057355db5f57ce3a6124 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sat, 14 Nov 2026 22:50:05 +0000 Subject: [PATCH 01/11] test(primitives): [#2824] test the swarm metadata counts Add one test per accessor of `SwarmMetadata` (`downloads`, `seeders`, `leechers`) on a value with three different counts, so a swap of two counts or of two fields fails, and one test that `zeroed` has every count at zero. Record the decision, coverage and mutation sample in `test-refactor-plans/swarm_metadata.md` and mark ledger row 7 done. Co-Authored-By: Claude Opus 5.5 --- .../2824-1347-add-tests-primitives/ISSUE.md | 4 +- .../test-refactor-plans/README.md | 3 +- .../test-refactor-plans/swarm_metadata.md | 97 +++++++++++++++++++ packages/primitives/src/swarm_metadata.rs | 39 ++++++++ 4 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index b9919a9630..ac596c117a 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2824 spec-path: docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md branch: "2824-1347-add-tests-primitives-defaults" related-pr: 2852 -last-updated-utc: "2026-11-13 22:30" +last-updated-utc: "2026-11-14 22:49" semantic-links: skill-links: - create-issue @@ -288,7 +288,7 @@ States: `PENDING`, `IN_PROGRESS`, `BLOCKED`, `DONE`. Unit-only lines are the bas | 4 | `policy.rs` | 2 | S3 | 0 / 16 | Test candidate | DONE (S3) | | 5 | `mode.rs` | 2 | S3 | 0 / 8 | Test candidate | DONE (S3) | | 6 | `pagination.rs` | 2 | S3 | 0 / 21 | Test candidate | DONE (S3) | -| 7 | `swarm_metadata.rs` | 3 | S4 | 3 / 18 | Test candidate; the `AddAssign` lines are not tested because #2823 deletes the impl | PENDING | +| 7 | `swarm_metadata.rs` | 3 | S4 | 3 / 18 | Test candidate; the `AddAssign` lines are not tested because #2823 deletes the impl | DONE (S4; #2823 deleted the `AddAssign` lines, 3 / 12 at the S4 start) | | 8 | `scrape.rs` | 3 | S4 | 28 / 28 | No change; review test breadth | PENDING | | 9 | `service_role.rs` | 4 | S4 | 40 / 40 | No change | PENDING | | 10 | `configuration_instance_id.rs` | 4 | S4 | 42 / 42 | No change | PENDING | diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md index b5aba3b6b8..024f37da51 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md @@ -3,7 +3,7 @@ doc-type: test-refactor-plan-guidance issue: 2824 package: torrust-tracker-primitives status: in-progress -last-updated-utc: "2026-11-12 16:45" +last-updated-utc: "2026-11-14 22:49" --- # `primitives` File Test Plan Guidance @@ -28,6 +28,7 @@ changes nor work on another file until the maintainer approves it. Files with no | 4 | [policy.md](policy.md) | DONE (S3) | | 5 | [mode.md](mode.md) | DONE (S3) | | 6 | [pagination.md](pagination.md) | DONE (S3) | +| 7 | [swarm_metadata.md](swarm_metadata.md) | DONE (S4) | ## Shared Guardrails diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md new file mode 100644 index 0000000000..f65d2c3875 --- /dev/null +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md @@ -0,0 +1,97 @@ +--- +doc-type: file-test-plan +issue: 2824 +package: torrust-tracker-primitives +target-file: packages/primitives/src/swarm_metadata.rs +status: done +last-updated-utc: "2026-11-14 22:49" +--- + +# `swarm_metadata.rs` File Test Plan + +Follow the shared [guidance](README.md). Ledger row 7, slice S4. Status: **done**: approved by the maintainer on 2026-11-14 (first gate, as written) +and the completed file approved on 2026-11-14 (second gate). + +## Current State + +- **Unit-only coverage:** 3 / 12 lines, measured 2026-11-14 on `develop` after #2852 (package: 1,049 / 1,126 lines, + 105 unit tests). The file has no tests. The baseline row said 3 / 18: #2823 deleted the `AddAssign` impl of + `AggregateActiveSwarmMetadata` (6 lines), so that group no longer exists. +- **Review of the existing tests:** none in the file. `zeroed` is covered only because the `scrape.rs` test builds a + `ScrapeData::zeroed` and compares it with another value built from `SwarmMetadata::zeroed`, so its value is never + checked: `zeroed` returning `new(1, 0, 0)` would pass every test of the package. +- **Hypothesis:** the risk is a mix-up of the three counts. The fields carry the scrape names (`downloaded`, `complete`, + `incomplete`) and the accessors the domain names (`downloads`, `seeders`, `leechers`); a swap of `seeders` and + `leechers` would report the wrong counts to every client, and no test in this package would see it. Seven calls in + three other packages build the value with `new(downloaded, complete, incomplete)`, so the argument order is a + contract too. + +## Coverage And Decision Analysis + +| Behavior group | Lines | Classification | Decision | +| --- | --- | --- | --- | +| `downloads`, `seeders`, `leechers` accessors | 39-41, 44-46, 49-51 | Unit | Three tests, one per accessor, on one value built with `new(3, 5, 7)` (three different counts): each accessor returns its own literal. A swap of two accessors, or of two fields in the struct (which reorders the `new` arguments), fails a test. | +| `zeroed` | 34-36 (covered, value unchecked) | Unit | One test: `zeroed()` equals the value built with `new(0, 0, 0)`. It is what a scrape answers for an unknown torrent. | +| `AggregateActiveSwarmMetadata` | none (derives only) | Unselected | Four public fields and derived traits, no executable line. The registry fills it (`get_aggregate_swarm_metadata`) and owns its sums. | +| Derived `Ord`, `Hash`, `Default`, `Constructor` | 17 | Unselected | Generated code. `Default` is reached through `zeroed`; I found no ordering of `SwarmMetadata` in the production code of other packages. | + +No finding blocks tests and nothing is owned elsewhere (the `AddAssign` decision of F4 is closed by #2823). + +## Property-Test Decision + +None. Three independent copies of a field; a generated input would repeat the examples. + +## Questions For The Maintainer + +- None. The four tests check package-owned behavior and none pins a finding. + +## Results (2026-11-14) + +Toolchains: stable Rust 1.99.1 for tests and coverage, `cargo-llvm-cov 0.6.16`, nightly `cargo fmt`. + +| Measure | Before | After | +| --- | ---: | ---: | +| Unit tests of the package | 105 | 109 (4 added, all in `swarm_metadata.rs`) | +| `swarm_metadata.rs` lines | 3 / 12 | 31 / 31 (the line count includes the new test module) | +| Package unit-only lines | 1,049 / 1,126 (93.16%) | 1,077 / 1,145 (94.06%) | +| Package unit-only regions | 1,659 / 1,752 (94.69%) | 1,698 / 1,782 (95.29%) | +| Package unit-only functions | 203 / 219 (92.69%) | 210 / 223 (94.17%) | + +Applied as planned, no deviation. The file moved by +28 covered and +19 lines, which is the whole package change. +The baseline is 5 covered lines above the S3 close (1,044 / 1,121) with no source change in between: the S3 review +commit `test(primitives): [#2824] compare serialized JSON by value, not by string` changed tests in `announce.rs`, +`mode.rs` and `policy.rs` after the S3 figures were taken. A first baseline run in the shared target directory read +stale profile data (it listed lines 75-80 of this 70-line file, the deleted `AddAssign`); every figure here comes from +a separate `CARGO_LLVM_COV_TARGET_DIR` after `cargo llvm-cov clean --workspace`. + +### Mutation sample (6 mutants, each applied alone and reverted exactly) + +| Mutant | Result | Killed by | +| --- | --- | --- | +| `seeders` returns `incomplete` | killed | the seeders test | +| `leechers` returns `complete` | killed | the leechers test | +| `downloads` returns `complete` | killed | the downloads test | +| `zeroed` returns `new(1, 0, 0)` | killed | the zeroed test | +| `zeroed` returns `new(0, 0, 1)` | killed | the zeroed test | +| `complete` and `incomplete` swapped in the struct (reorders the `new` arguments) | killed | the seeders and leechers tests | + +No survivor. `cmp` against a saved copy showed the file restored byte for byte after every mutant. + +## Prose-First AAA Review (every added test) + +Temporary prose per test was written and compared with the code; the code expresses it. + +| Test | Arrange (the one causal state) | Act | Assert (literal, independent) | Outcome | +| --- | --- | --- | --- | --- | +| `it_should_return_the_number_of_downloads` | `new(3, 5, 7)`, three different counts | `downloads()` | `3` | clean | +| `it_should_return_the_number_of_seeders` | `new(3, 5, 7)` | `seeders()` | `5` | clean | +| `it_should_return_the_number_of_leechers` | `new(3, 5, 7)` | `leechers()` | `7` | clean | +| `it_should_build_a_zeroed_value_with_every_count_at_zero` | none | `SwarmMetadata::zeroed()` | the value built with `new(0, 0, 0)` | clean; the expectation is built with `new`, not `default`, so it does not repeat the production path | + +Test smells found and fixed while writing: none. + +## Validation + +`cargo test -p torrust-tracker-primitives` (109 + 2 + 1 passed); `cargo +nightly fmt --all -- --check`; +`cargo clippy -p torrust-tracker-primitives --all-targets`; `git diff --check`; the pre-commit gate (at commit); +unit-only coverage before and after in the table above. diff --git a/packages/primitives/src/swarm_metadata.rs b/packages/primitives/src/swarm_metadata.rs index 99a89ceb51..3def1db478 100644 --- a/packages/primitives/src/swarm_metadata.rs +++ b/packages/primitives/src/swarm_metadata.rs @@ -68,3 +68,42 @@ pub struct AggregateActiveSwarmMetadata { /// Total number of torrents. pub total_torrents: u64, } + +#[cfg(test)] +mod tests { + use crate::swarm_metadata::SwarmMetadata; + + #[test] + fn it_should_return_the_number_of_downloads() { + let swarm_metadata = SwarmMetadata::new(3, 5, 7); + + let downloads = swarm_metadata.downloads(); + + assert_eq!(downloads, 3); + } + + #[test] + fn it_should_return_the_number_of_seeders() { + let swarm_metadata = SwarmMetadata::new(3, 5, 7); + + let seeders = swarm_metadata.seeders(); + + assert_eq!(seeders, 5); + } + + #[test] + fn it_should_return_the_number_of_leechers() { + let swarm_metadata = SwarmMetadata::new(3, 5, 7); + + let leechers = swarm_metadata.leechers(); + + assert_eq!(leechers, 7); + } + + #[test] + fn it_should_build_a_zeroed_value_with_every_count_at_zero() { + let swarm_metadata = SwarmMetadata::zeroed(); + + assert_eq!(swarm_metadata, SwarmMetadata::new(0, 0, 0)); + } +} From 0613b3a40b30383246cc855c2b0b036f0fca308f Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 07:49:11 +0000 Subject: [PATCH 02/11] test(primitives): [#2824] record the no-change files and compare instance id JSON by value Review the tests of the nine fully covered and wiring files (ledger rows 8-16) in one shared record, `test-refactor-plans/no-change-files.md`. Change the JSON test of `ConfigurationInstanceId` to compare `serde_json::Value`s, as S3 did, so a field reorder that a reader cannot see does not fail it. Explain the `readiness.rs` coverage variance (the loop body of the concurrent test) and answer its `lessons.md` row. Co-Authored-By: Claude Opus 5.5 --- .../2824-1347-add-tests-primitives/ISSUE.md | 20 ++-- .../2824-1347-add-tests-primitives/lessons.md | 2 +- .../test-refactor-plans/README.md | 3 +- .../test-refactor-plans/no-change-files.md | 91 +++++++++++++++++++ .../src/configuration_instance_id.rs | 7 +- 5 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index ac596c117a..47a492a204 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2824 spec-path: docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md branch: "2824-1347-add-tests-primitives-defaults" related-pr: 2852 -last-updated-utc: "2026-11-14 22:49" +last-updated-utc: "2026-11-15 07:48" semantic-links: skill-links: - create-issue @@ -289,15 +289,15 @@ States: `PENDING`, `IN_PROGRESS`, `BLOCKED`, `DONE`. Unit-only lines are the bas | 5 | `mode.rs` | 2 | S3 | 0 / 8 | Test candidate | DONE (S3) | | 6 | `pagination.rs` | 2 | S3 | 0 / 21 | Test candidate | DONE (S3) | | 7 | `swarm_metadata.rs` | 3 | S4 | 3 / 18 | Test candidate; the `AddAssign` lines are not tested because #2823 deletes the impl | DONE (S4; #2823 deleted the `AddAssign` lines, 3 / 12 at the S4 start) | -| 8 | `scrape.rs` | 3 | S4 | 28 / 28 | No change; review test breadth | PENDING | -| 9 | `service_role.rs` | 4 | S4 | 40 / 40 | No change | PENDING | -| 10 | `configuration_instance_id.rs` | 4 | S4 | 42 / 42 | No change | PENDING | -| 11 | `runtime_service_metadata.rs` | 4 | S4 | 32 / 32 | No change | PENDING | -| 12 | `readiness.rs` | 4 | S4 | 52 / 52 | No change | PENDING | -| 13 | `driver.rs` | 4 | S4 | 59 / 59 | No change; style review | PENDING | -| 14 | `number_of_bytes.rs` | 5 | S4 | 3 / 3 | No change | PENDING | -| 15 | `peer_id.rs` | 5 | S4 | no executable entries | Wiring only (deprecated) | PENDING | -| 16 | `lib.rs` | 5 | S4 | no executable entries | Wiring only | PENDING | +| 8 | `scrape.rs` | 3 | S4 | 28 / 28 | No change; review test breadth | DONE (S4; no change, breadth reviewed) | +| 9 | `service_role.rs` | 4 | S4 | 40 / 40 | No change | DONE (S4; no change) | +| 10 | `configuration_instance_id.rs` | 4 | S4 | 42 / 42 | No change | DONE (S4; JSON test changed to compare values) | +| 11 | `runtime_service_metadata.rs` | 4 | S4 | 32 / 32 | No change | DONE (S4; no change) | +| 12 | `readiness.rs` | 4 | S4 | 52 / 52 | No change | DONE (S4; no change; coverage variance explained) | +| 13 | `driver.rs` | 4 | S4 | 59 / 59 | No change; style review | DONE (S4; no change; style reviewed) | +| 14 | `number_of_bytes.rs` | 5 | S4 | 3 / 3 | No change | DONE (S4; no change) | +| 15 | `peer_id.rs` | 5 | S4 | no executable entries | Wiring only (deprecated) | DONE (S4; wiring) | +| 16 | `lib.rs` | 5 | S4 | no executable entries | Wiring only | DONE (S4; wiring) | The 16 rows are every `.rs` file under `packages/primitives/src/`, each once. diff --git a/docs/issues/open/2824-1347-add-tests-primitives/lessons.md b/docs/issues/open/2824-1347-add-tests-primitives/lessons.md index 25df441664..5c53d2ae92 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/lessons.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/lessons.md @@ -15,7 +15,7 @@ Candidate lessons collected while working on Issue #2824. Promoting any of them | Source | Candidate | Evidence | | --- | --- | --- | | [Pagination plan](test-refactor-plans/pagination.md) (`review-finding:pr-2852-f8`) | Correct the doc comment of `QueryParams::offset` in the REST API torrent handlers, and check the REST API documentation for the same wording. | `packages/axum-rest-api-server/src/v1/context/torrent/handlers.rs` says "The offset of the first page to return. Starts at 0." but `Pagination::new_with_options` passes the value into `Pagination::offset`, which every consumer uses as the number of items to skip (`.skip(pagination.offset as usize)`). The domain comment was corrected in S3; the REST one is outside this issue's scope. | -| [Coverage evidence](coverage-evidence.md) (S3 reconciliation) | In the S4 `readiness.rs` record, find out why its unit-only line coverage varied between runs (50 / 52 in one run, 52 / 52 in every other) and make the test deterministic if it is. | One S3 run measured `readiness.rs` at 50 / 52 with no change to the file, which moved the package totals by two lines in that step. | +| [Coverage evidence](coverage-evidence.md) (S3 reconciliation) | In the S4 `readiness.rs` record, find out why its unit-only line coverage varied between runs (50 / 52 in one run, 52 / 52 in every other) and make the test deterministic if it is. | One S3 run measured `readiness.rs` at 50 / 52 with no change to the file, which moved the package totals by two lines in that step. Answered in the S4 [no-change record](test-refactor-plans/no-change-files.md) (row 12): the likely cause is the loop body of the concurrent test (test code, not production); the maintainer decided to leave the test (Q3). | | [Issue spec](ISSUE.md#out-of-scope) (Out of Scope) | Audit the implicit lowercase and snake_case convention of enum serialization (the F2 `PeerRole` defect came from a `rename_all_fields` that does not apply to unit variants) in a separate issue, under `create-adr`. | `PeerRole` serialized as `"Seeder"` while `Display` and the metric label use `seeder`; fixed in S1 (#2834). | ## Testing Lessons diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md index 024f37da51..7bd7a3d4e6 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md @@ -3,7 +3,7 @@ doc-type: test-refactor-plan-guidance issue: 2824 package: torrust-tracker-primitives status: in-progress -last-updated-utc: "2026-11-14 22:49" +last-updated-utc: "2026-11-15 07:48" --- # `primitives` File Test Plan Guidance @@ -29,6 +29,7 @@ changes nor work on another file until the maintainer approves it. Files with no | 5 | [mode.md](mode.md) | DONE (S3) | | 6 | [pagination.md](pagination.md) | DONE (S3) | | 7 | [swarm_metadata.md](swarm_metadata.md) | DONE (S4) | +| 8 | [no-change-files.md](no-change-files.md) (ledger rows 8-16) | DONE (S4) | ## Shared Guardrails diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md new file mode 100644 index 0000000000..cd6ac08a0a --- /dev/null +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md @@ -0,0 +1,91 @@ +--- +doc-type: file-test-plan +issue: 2824 +package: torrust-tracker-primitives +target-file: packages/primitives/src/ (ledger rows 8-16) +status: done +last-updated-utc: "2026-11-15 07:48" +--- + +# No-Change Files Test Plan + +Follow the shared [guidance](README.md). Ledger rows 8-16, slice S4, one shared record. Status: **done**: approved by +the maintainer on 2026-11-15 (first gate; Q1 yes, Q2 and Q3 as recommended) and the completed rows approved on +2026-11-15 (second gate). + +## Current State + +Unit-only coverage measured 2026-11-14 on `develop` after #2852 (package 1,049 / 1,126 lines, 105 unit tests). Every +file with executable lines is fully covered, so no group below is an uncovered line; the review is of the existing tests. + +| Row | File | Lines | Tests | Review of the existing tests | Decision | +| ---: | --- | ---: | ---: | --- | --- | +| 8 | `scrape.rs` | 28 / 28 | 1 | `refactor`-light: the expectation is built with `add_file_with_zeroed_metadata`, a production path, so the test pins that `zeroed` and `add_file_with_zeroed_metadata` agree, not the value; the value is now pinned by the `SwarmMetadata::zeroed` test of row 7. `empty` and `add_file` are `HashMap::new` and `insert` delegations, reached through the same test. | No change (Q2). | +| 9 | `service_role.rs` | 40 / 40 | 3 | `clean`: one table per contract (`as_str`, `Display`, JSON), literals written in the test. The loop runs the same Act and Assert over a table of literals, with no other logic. `Deserialize` is unselected: a search found no code that names `ServiceRole` with a deserializer, a `from_str` or TOML. | No change. | +| 10 | `configuration_instance_id.rs` | 42 / 42 | 5 | `clean`, one smell: the JSON test compares a serialized **string** with `{"service_role":"http_tracker","instance_index":0}`, so it fails on a field reorder that changes nothing a reader sees. S3 replaced the same form with a comparison of `serde_json::Value`s after review. | Test changed (Q1). | +| 11 | `runtime_service_metadata.rs` | 32 / 32 | 2 | `clean`, minor: the first test asserts three accessors of one value built in one step; they describe one state, so one reason to fail. `with_public_url(None)` is not tested; it is an assignment. | No change. | +| 12 | `readiness.rs` | 52 / 52 | 5 | `clean`. Likely cause of the varying coverage seen in S3 (50 / 52 once, not reproduced since): the concurrent test's reader threads loop on `while reader.is_ready() { yield_now() }` (lines 105-106 of the **test** module). When the main thread marks the value before a reader starts, that loop body never runs and its two lines count as uncovered. Every production line is covered in every run, and the test result does not depend on the timing. | No change (Q3). | +| 13 | `driver.rs` | 59 / 59 | 13 | `clean`, style: one test per variant and contract (no AAA blocks; each test is one line of Act and one assert, so the blocks would add nothing). `Display` prints the variant names (`Sqlite3`, `MySQL`), unlike `as_str` and the JSON form (lowercase); the tests pin both as they are. The invalid-driver test asserts only the failure. `Deserialize` is collaborator-owned: the `configuration` tests load `driver = "mysql"` and `"postgresql"` from TOML. | No change. | +| 14 | `number_of_bytes.rs` | 3 / 3 | 0 | A `const fn new` around an `i64`; reached through other modules' tests. | No change (unselected: one assignment). | +| 15 | `peer_id.rs` | none | 0 | A deprecated re-export, no executable line. Removal is owned by EPIC #1669. | No change (wiring). | +| 16 | `lib.rs` | none | 0 | Module declarations, re-exports (some deprecated, owned by #1669) and two type aliases. | No change (wiring). | + +No finding: nothing here is wrong behavior, and nothing is owned by an open issue other than the #1669 removals. + +## Property-Test Decision + +None. No file has an invariant over a range of inputs; the enums are closed sets, already tested per variant. + +## Questions For The Maintainer + +- **Q1: change the JSON test of `configuration_instance_id.rs`** to compare `serde_json::to_value` with a `json!` + literal, as S3 did after review? It makes row 10 "test changed", with a Prose-First AAA row and one mutant (a field + rename). Recommendation: yes, so the package uses one form for JSON objects. Alternative: no change, and the smell is + recorded here only. +- **Q2: `scrape.rs` breadth.** Leave it, as recommended: with the `zeroed` value now pinned, a wider test would only + repeat `HashMap` behavior. Alternative: one test that `zeroed` of two info hashes holds two zeroed entries. +- **Q3: `readiness.rs` coverage variance.** Leave the test, as recommended: the variance is in the test's own loop, + not in a production line, and a fix (a barrier so every reader starts before the mark) would add machinery for a + coverage figure only. The `lessons.md` row is answered by this record. Alternative: add the barrier. + +## Results (2026-11-15) + +Toolchains: stable Rust 1.99.1 for tests and coverage, `cargo-llvm-cov 0.6.16`, nightly `cargo fmt`. + +| Measure | Before | After | +| --- | ---: | ---: | +| Unit tests of the package | 109 | 109 (one test changed, none added) | +| `configuration_instance_id.rs` lines | 42 / 42 | 43 / 43 (the assertion now spans more lines) | +| Package unit-only lines | 1,077 / 1,145 (94.06%) | 1,078 / 1,146 (94.07%) | +| Package unit-only regions | 1,698 / 1,782 (95.29%) | 1,702 / 1,786 (95.30%) | +| Package unit-only functions | 210 / 223 (94.17%) | 210 / 223 (94.17%) | + +Applied as approved: Q1 changed `it_should_serialize_the_role_and_instance_index` to compare `serde_json::to_value` with +a `json!` literal (and `expect` in place of `unwrap`). Q2 and Q3 changed nothing; Q3 answers the `readiness.rs` row of +`lessons.md`. `readiness.rs` read 52 / 52 in both S4 runs. + +### Mutation sample (3 mutants, each applied alone and reverted exactly) + +| Mutant | Result | Killed by | +| --- | --- | --- | +| `instance_index` renamed in JSON (`#[serde(rename = "index")]`) | killed | the JSON test | +| `service_role` left out of the JSON (`#[serde(skip)]`) | killed | the JSON test | +| The two fields swapped in the struct | **survived, by design** | the JSON object is the same; the old string comparison failed on it. The derived `Ord` changes order (index before role). The identifiers are keys of the `metrics_policy` `BTreeMap`s in `http-core` and `udp-core`, which look them up by key; any total order consistent with `Eq` gives the same lookups, so the order stays unselected. | + +`cmp` against a saved copy showed the file restored byte for byte after every mutant. + +## Prose-First AAA Review (every changed test) + +Temporary prose was written and compared with the code; the code expresses it. + +| Test | Arrange (the one causal state) | Act | Assert (literal, independent) | Outcome | +| --- | --- | --- | --- | --- | +| `it_should_serialize_the_role_and_instance_index` | an id for `HttpTracker`, index `0` | `to_value` | the literal document, as a `serde_json::Value` | clean | + +Test smells found and fixed while writing: none beyond Q1. The other rows keep their tests unchanged. + +## Validation + +`cargo test -p torrust-tracker-primitives` (109 + 2 + 1 passed); `cargo +nightly fmt --all -- --check`; +`cargo clippy -p torrust-tracker-primitives --all-targets`; `git diff --check`; the pre-commit gate (at commit); +unit-only coverage before and after in the table above. diff --git a/packages/primitives/src/configuration_instance_id.rs b/packages/primitives/src/configuration_instance_id.rs index abf1fd7220..6d358a20c1 100644 --- a/packages/primitives/src/configuration_instance_id.rs +++ b/packages/primitives/src/configuration_instance_id.rs @@ -101,9 +101,12 @@ mod tests { let instance_id = ConfigurationInstanceId::new(ServiceRole::HttpTracker, 0); // Act - let serialized = serde_json::to_string(&instance_id).unwrap(); + let value = serde_json::to_value(instance_id).expect("it should serialize"); // Assert - assert_eq!(serialized, r#"{"service_role":"http_tracker","instance_index":0}"#); + assert_eq!( + value, + serde_json::json!({"service_role": "http_tracker", "instance_index": 0}) + ); } } From e999f0b5b901e27aae5b0c4b79bb48784a6567c9 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 08:33:43 +0000 Subject: [PATCH 03/11] test(primitives): [#2824] test the instance index with a value no mutant returns The only test of `ConfigurationInstanceId::instance_index` used index 1, so replacing the accessor body with `1` survived the package mutation run. Use index 2, which kills the `0` and `1` replacements. Co-Authored-By: Claude Opus 5.5 --- .../open/2824-1347-add-tests-primitives/ISSUE.md | 2 +- .../test-refactor-plans/no-change-files.md | 16 ++++++++++++++-- .../primitives/src/configuration_instance_id.rs | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index 47a492a204..116aa2444c 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -291,7 +291,7 @@ States: `PENDING`, `IN_PROGRESS`, `BLOCKED`, `DONE`. Unit-only lines are the bas | 7 | `swarm_metadata.rs` | 3 | S4 | 3 / 18 | Test candidate; the `AddAssign` lines are not tested because #2823 deletes the impl | DONE (S4; #2823 deleted the `AddAssign` lines, 3 / 12 at the S4 start) | | 8 | `scrape.rs` | 3 | S4 | 28 / 28 | No change; review test breadth | DONE (S4; no change, breadth reviewed) | | 9 | `service_role.rs` | 4 | S4 | 40 / 40 | No change | DONE (S4; no change) | -| 10 | `configuration_instance_id.rs` | 4 | S4 | 42 / 42 | No change | DONE (S4; JSON test changed to compare values) | +| 10 | `configuration_instance_id.rs` | 4 | S4 | 42 / 42 | No change | DONE (S4; JSON test changed to compare values; accessor test uses index 2 after T4) | | 11 | `runtime_service_metadata.rs` | 4 | S4 | 32 / 32 | No change | DONE (S4; no change) | | 12 | `readiness.rs` | 4 | S4 | 52 / 52 | No change | DONE (S4; no change; coverage variance explained) | | 13 | `driver.rs` | 4 | S4 | 59 / 59 | No change; style review | DONE (S4; no change; style reviewed) | diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md index cd6ac08a0a..a1228c415c 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/no-change-files.md @@ -4,7 +4,7 @@ issue: 2824 package: torrust-tracker-primitives target-file: packages/primitives/src/ (ledger rows 8-16) status: done -last-updated-utc: "2026-11-15 07:48" +last-updated-utc: "2026-11-15 08:34" --- # No-Change Files Test Plan @@ -82,7 +82,19 @@ Temporary prose was written and compared with the code; the code expresses it. | --- | --- | --- | --- | --- | | `it_should_serialize_the_role_and_instance_index` | an id for `HttpTracker`, index `0` | `to_value` | the literal document, as a `serde_json::Value` | clean | -Test smells found and fixed while writing: none beyond Q1. The other rows keep their tests unchanged. +### Update after the T4 mutation run (2026-11-15) + +The package-wide run (`mutation-evidence.md`) found that `instance_index()` replaced by `1` survived: the only test that +calls the accessor used index `1`. The maintainer approved using `2` (2026-11-15), a value no default mutant returns. +`it_should_expose_its_role_and_zero_based_index` now builds the id with index `2` and expects `2`. A re-run of +`cargo mutants` on this file gives 2 caught and 1 unviable; the replacements by `0` and `1` both fail the test. The +coverage figures above do not change (same lines). + +| Test | Arrange (the one causal state) | Act | Assert (literal, independent) | Outcome | +| --- | --- | --- | --- | --- | +| `it_should_expose_its_role_and_zero_based_index` | an id for `UdpTracker`, index `2` | `service_role()` and `instance_index()` | `UdpTracker` and `2` | clean; one state read through its two accessors | + +Test smells found and fixed while writing: none beyond Q1 and the index value above. The other rows keep their tests unchanged. ## Validation diff --git a/packages/primitives/src/configuration_instance_id.rs b/packages/primitives/src/configuration_instance_id.rs index 6d358a20c1..e5c80f5a9e 100644 --- a/packages/primitives/src/configuration_instance_id.rs +++ b/packages/primitives/src/configuration_instance_id.rs @@ -84,7 +84,7 @@ mod tests { #[test] fn it_should_expose_its_role_and_zero_based_index() { // Arrange - let instance_id = ConfigurationInstanceId::new(ServiceRole::UdpTracker, 1); + let instance_id = ConfigurationInstanceId::new(ServiceRole::UdpTracker, 2); // Act let service_role = instance_id.service_role(); @@ -92,7 +92,7 @@ mod tests { // Assert assert_eq!(service_role, ServiceRole::UdpTracker); - assert_eq!(instance_index, 1); + assert_eq!(instance_index, 2); } #[test] From 284d3931223049746fa90182fa2a2b6cf2f156e0 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 08:37:29 +0000 Subject: [PATCH 04/11] docs(issues): [#2824] close slice S4 with mutation, manual and final records Record the package mutation run (147 mutants; the one real survivor is killed by the previous commit), the manual checks M1 and M2 against a built tracker, the S4 and final coverage measurements, the implementation retrospective, and `lessons.md` rows for every finding and for the unpinned REST peer `event` text. Reconcile the tasks, slice table, checkpoints, acceptance rows and both EPIC "Latest" tables. Co-Authored-By: Claude Opus 5.5 --- .../1347-overhaul-packages-testing/EPIC.md | 9 +- .../2824-1347-add-tests-primitives/ISSUE.md | 85 +++++++++-------- .../coverage-evidence.md | 37 ++++++++ .../implementation-retrospective.md | 76 +++++++++++++++ .../2824-1347-add-tests-primitives/lessons.md | 6 ++ .../manual-verification-evidence.md | 94 ++++++++++++++++++- .../mutation-evidence.md | 89 ++++++++++++++++++ .../test-refactor-plans/README.md | 2 +- 8 files changed, 347 insertions(+), 51 deletions(-) create mode 100644 docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md create mode 100644 docs/issues/open/2824-1347-add-tests-primitives/mutation-evidence.md diff --git a/docs/issues/open/1347-overhaul-packages-testing/EPIC.md b/docs/issues/open/1347-overhaul-packages-testing/EPIC.md index 6a5da925d1..db7b69df86 100644 --- a/docs/issues/open/1347-overhaul-packages-testing/EPIC.md +++ b/docs/issues/open/1347-overhaul-packages-testing/EPIC.md @@ -6,7 +6,7 @@ epic: null github-issue: 1347 spec-path: docs/issues/open/1347-overhaul-packages-testing/EPIC.md epic-owner: josecelano -last-updated-utc: "2026-11-14 08:06" +last-updated-utc: "2026-11-15 08:37" semantic-links: skill-links: - create-issue @@ -96,7 +96,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | 8 | #2301 - Review package coverage rollout | `docs/issues/open/2301-1347-review-package-coverage-rollout/ISSUE.md` | TODO | After the EPIC completes, review real rollout evidence before retaining, revising, or proposing a required coverage check. | | 9 | #2361 - Keep the report-only package coverage summary from failing on a discovery failure | `docs/issues/open/2361-1347-package-coverage-summary-discovery-failure/ISSUE.md` | TODO | Bug follow-up of #2347 (`review-finding:pr-2293-f1`): the #2222 summary check goes red with a JSON parse error when discovery fails. | | 10 | #2637 - Add tests to the axum-rest-api-server package | `docs/issues/closed/2637-1347-add-tests-axum-rest-api-server/ISSUE.md` | DONE | S0 (spec and T1 baseline) merged through #2638; S1 (authentication and shared responses) merged through #2667; S2 (routes) merged through #2687; S3 (auth-key and whitelist contexts) merged through #2702; S4 (torrent and stats contexts) merged through #2718; S5 (server lifecycle) merged through #2744; S6 (crate root, wiring and final tasks) merged through #2772; the issue is closed. Replaces the former draft that was misfiled under #1349. | -| 11 | #2824 - Add tests to the primitives package | `docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md` | IN_PROGRESS | Spec-only PR carries the specification and the T1 baseline and inventory; S0 (the spec, #2828) is merged and S1 (the `PeerRole` JSON casing fix, #2834) is merged and S2 (the `peer.rs` tests, #2841) is merged and S3 (the configuration defaults and bounded values) is in review; S4 follows. Findings F1 (fixed through #2811), F3 (#2804) and the `AddAssign` and `peer::Id::new` follow-ups are handed off to their own issues. | +| 11 | #2824 - Add tests to the primitives package | `docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md` | IN_PROGRESS | Spec-only PR carries the specification and the T1 baseline and inventory; S0 (the spec, #2828) is merged and S1 (the `PeerRole` JSON casing fix, #2834) is merged and S2 (the `peer.rs` tests, #2841) is merged and S3 (the configuration defaults and bounded values, #2852) is merged; S4 (`swarm_metadata.rs`, the no-change files, the mutation run, the manual checks and the close-out) is in review and closes the issue. Findings F1 (fixed through #2811), F3 (#2804) and the `AddAssign` and `peer::Id::new` follow-ups are handed off to their own issues. | | 12 | #2838 - UDP tracker accepts announces with a negative left, uploaded or downloaded | `docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md` | BLOCKED | Bug found by the #2824 primitives tests work. Planned fix: the standalone issue #2850 (`docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md`), whose implementation will close it; until then the bug is present on `develop`. The patch of PR #2839 was not merged. | | 13 | Additional package-testing subissues | Create a folder-style spec when a concrete package need is identified | TODO | Permitted but not required upfront; retain scope in this EPIC. | @@ -122,7 +122,7 @@ level or determine whether unit coverage is adequate. | `torrust-tracker-udp-core` | [#1348](../../closed/1348-1347-add-tests-udp-core/ISSUE.md) | Lines: 72.49%; regions: 78.56%; functions: 71.27% | Lines: 98.04%; regions: 98.15%; functions: 97.61% | Lines: +25.55 pp; regions: +19.58 pp; functions: +26.34 pp | [Coverage evidence](../../closed/1348-1347-add-tests-udp-core/coverage-evidence.md) | | `torrust-tracker-http-core` | [#1349](../../closed/1349-1347-add-tests-http-core/ISSUE.md) | Lines: 88.88%; regions: 90.41%; functions: 84.29% | Lines: 99.28%; regions: 99.25%; functions: 99.74% | Lines: +10.40 pp; regions: +8.84 pp; functions: +15.45 pp | [Coverage evidence](../../closed/1349-1347-add-tests-http-core/coverage-evidence.md) | | `torrust-tracker-axum-rest-api-server` | [#2637](../../closed/2637-1347-add-tests-axum-rest-api-server/ISSUE.md) | Lines: 87.98%; regions: 84.10%; functions: 83.42% | Lines: 97.67%; regions: 97.13%; functions: 95.48% | Lines: +9.69 pp; regions: +13.03 pp; functions: +12.06 pp | [Coverage evidence](../../closed/2637-1347-add-tests-axum-rest-api-server/coverage-evidence.md) | -| `torrust-tracker-primitives` | [#2824](../2824-1347-add-tests-primitives/ISSUE.md) | Lines: 60.56%; regions: 67.94%; functions: 57.23% | Lines: 93.13%; regions: 94.66%; functions: 92.69% | Lines: +32.57 pp; regions: +26.72 pp; functions: +35.46 pp | [Coverage evidence](../2824-1347-add-tests-primitives/coverage-evidence.md) | +| `torrust-tracker-primitives` | [#2824](../2824-1347-add-tests-primitives/ISSUE.md) | Lines: 60.56%; regions: 67.94%; functions: 57.23% | Lines: 94.07%; regions: 95.30%; functions: 94.17% | Lines: +33.51 pp; regions: +27.36 pp; functions: +36.94 pp | [Coverage evidence](../2824-1347-add-tests-primitives/coverage-evidence.md) | ### Unit-Only Coverage @@ -137,7 +137,7 @@ weak unit-only result with aggregate, integration, example, or end-to-end covera | `torrust-tracker-udp-core` | [#1348](../../closed/1348-1347-add-tests-udp-core/ISSUE.md) | Lines: 72.49%; regions: 78.56%; functions: 71.27% | Lines: 98.04%; regions: 98.15%; functions: 97.61% | Lines: +25.55 pp; regions: +19.58 pp; functions: +26.34 pp | [Coverage evidence](../../closed/1348-1347-add-tests-udp-core/coverage-evidence.md) | | `torrust-tracker-http-core` | [#1349](../../closed/1349-1347-add-tests-http-core/ISSUE.md) | Lines: 88.88%; regions: 90.41%; functions: 84.29% | Lines: 99.28%; regions: 99.25%; functions: 99.74% | Lines: +10.40 pp; regions: +8.84 pp; functions: +15.45 pp | [Coverage evidence](../../closed/1349-1347-add-tests-http-core/coverage-evidence.md) | | `torrust-tracker-axum-rest-api-server` | [#2637](../../closed/2637-1347-add-tests-axum-rest-api-server/ISSUE.md) | Lines: 63.87%; regions: 63.98%; functions: 51.34% | Lines: 96.67%; regions: 96.38%; functions: 93.97% | Lines: +32.80 pp; regions: +32.40 pp; functions: +42.63 pp | [Coverage evidence](../../closed/2637-1347-add-tests-axum-rest-api-server/coverage-evidence.md) | -| `torrust-tracker-primitives` | [#2824](../2824-1347-add-tests-primitives/ISSUE.md) | Lines: 60.56%; regions: 67.94%; functions: 57.23% | Lines: 93.13%; regions: 94.66%; functions: 92.69% | Lines: +32.57 pp; regions: +26.72 pp; functions: +35.46 pp | [Coverage evidence](../2824-1347-add-tests-primitives/coverage-evidence.md) | +| `torrust-tracker-primitives` | [#2824](../2824-1347-add-tests-primitives/ISSUE.md) | Lines: 60.56%; regions: 67.94%; functions: 57.23% | Lines: 94.07%; regions: 95.30%; functions: 94.17% | Lines: +33.51 pp; regions: +27.36 pp; functions: +36.94 pp | [Coverage evidence](../2824-1347-add-tests-primitives/coverage-evidence.md) | ## Delivery Strategy @@ -349,6 +349,7 @@ For each subissue implementation, the completion policy is: - 2026-11-12 14:10 UTC - Claude Code - #2824 S2 review round 1 of #2841: Copilot asked for trait-qualified `ReadInfo` role cases (positive, zero, negative `left`, and the stopped event, on `Peer` and `Arc`); one test was added, so `primitives` unit-only (= aggregate) is lines 85.20% (846 / 993), regions 89.28%, functions 82.99%, 81 unit tests. Both "Latest" tables carry the new values. - 2026-11-12 18:24 UTC - Claude Code - #2824 S2 review round 3 of #2841: two assertions were added to the `is_completed` test, so `primitives` unit-only (= aggregate) is lines 85.23% (848 / 995), regions 89.31%, functions 82.99%, 81 unit tests. Both "Latest" tables carry the new values. - 2026-11-13 08:58 UTC - Claude Code - #2824 S3 (configuration defaults and bounded values, 24 tests added) re-measured `primitives` unit-only (= aggregate) at lines 93.13% (1,044 / 1,121), regions 94.66%, functions 92.69%, 105 unit tests. Both "Latest" tables carry the new values. +- 2026-11-15 08:37 UTC - Claude Code - #2824 S4 (`swarm_metadata.rs` tests, the no-change rows, T4-T6) re-measured `primitives` unit-only (= aggregate) at lines 94.07% (1,078 / 1,146), regions 95.30%, functions 94.17%, 109 unit tests. The package mutation run (147 mutants) left no non-equivalent survivor after one test fix. Both "Latest" tables carry the final values; the row stays `IN_PROGRESS` until the S4 PR merges and the issue closes. ## Acceptance Criteria diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index 116aa2444c..b365c532e8 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -7,9 +7,9 @@ priority: p2 epic: 1347 github-issue: 2824 spec-path: docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md -branch: "2824-1347-add-tests-primitives-defaults" +branch: "2824-1347-add-tests-primitives-final" related-pr: 2852 -last-updated-utc: "2026-11-15 07:48" +last-updated-utc: "2026-11-15 08:36" semantic-links: skill-links: - create-issue @@ -218,10 +218,10 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`, `DEFERRED`. | T1 | DONE | Coverage evidence and complete module inventory | [coverage-evidence.md](coverage-evidence.md): baseline, per-file uncovered groups, property candidacy, initial hypothesis for the 16 files. Delivered with this spec (S0). | | T2a | DONE | Fix the small defects decided in this issue (slice S1) | F2 only: F1 is fixed upstream and F3, F4, F5 are handed off to their own issues. Each fix: failing regression test first, then a separate `fix` commit, per the `fix-bug` skill. Merged before the test slices. Done: the commits `test(primitives): [#2824] pin the lowercase JSON form of PeerRole` (fails before the fix) and `fix(primitives): [#2824] serialize PeerRole in lowercase`. | | T2 | DONE | Shared plan guidance | `test-refactor-plans/README.md`: two-phase sequence, guardrails, toolchain-pinned commands. First test slice (S2). | -| T3 | TODO | Process every ledger row through the per-file workflow | Each row ends in exactly one of: test added, no-change with reason, deferred with owner. | -| T4 | TODO | Bounded mutation assessment | `mutation-evidence.md`: configuration, survivors, reason for each unviable mutant. | -| T5 | TODO | Reconcile evidence and progress state | Ledger, plans, slice table, acceptance rows and both EPIC coverage tables agree; grep for `status: proposed` and stray `TODO` labels in finished records. | -| T6 | TODO | Final verification, acceptance review, retrospective | Automatic checks, manual verification, acceptance review, `implementation-retrospective.md` (or a log entry saying none was needed). | +| T3 | DONE | Process every ledger row through the per-file workflow | Each row ends in exactly one of: test added, no-change with reason, deferred with owner. | +| T4 | DONE | Bounded mutation assessment | `mutation-evidence.md`: configuration, survivors, reason for each unviable mutant. Done (S4): 147 mutants, 94 caught, 2 equivalent survivors, 2 timeouts, 48 unviable; the one real survivor (`instance_index`) is killed after a test fix. | +| T5 | DONE | Reconcile evidence and progress state | Ledger, plans, slice table, acceptance rows and both EPIC coverage tables agree; grep for `status: proposed` and stray `TODO` labels in finished records. | +| T6 | DONE | Final verification, acceptance review, retrospective | Automatic checks, manual verification, acceptance review, `implementation-retrospective.md` (or a log entry saying none was needed). | After the last test-producing increment, stop for maintainer review before T4-T6 and the final PR. @@ -235,8 +235,8 @@ the maintainer (2026-11-10): | S0 | This specification, the T1 evidence, and the EPIC registration with the baseline | - | `2824-1347-add-tests-primitives-spec` | #2828 | DONE | | S1 | Defect fixes decided in this issue (T2a): F2 `PeerRole` JSON casing, only (F1 fixed upstream; F3, F4, F5 handed off). Merged first, so the test slices pin the fixed behavior. | - | `2824-1347-add-tests-primitives-fixes` | #2834 | DONE | | S2 | T2, then `peer.rs` (rank 1, the largest gap) | 1 | `2824-1347-add-tests-primitives-peer` | #2841 | DONE | -| S3 | Configuration defaults and bounded values: `announce.rs`, `policy.rs`, `mode.rs`, `pagination.rs`, `announce_interval.rs` | 2-6 | `2824-1347-add-tests-primitives-defaults` | #2852 | IN_PROGRESS | -| S4 | `swarm_metadata.rs`, no-change decisions for the covered and wiring files, then T4-T6; the clean-up moves the spec to `docs/issues/closed/` and updates the EPIC tables | 7-16 | `2824-1347-add-tests-primitives-final` | - | TODO | +| S3 | Configuration defaults and bounded values: `announce.rs`, `policy.rs`, `mode.rs`, `pagination.rs`, `announce_interval.rs` | 2-6 | `2824-1347-add-tests-primitives-defaults` | #2852 | DONE | +| S4 | `swarm_metadata.rs`, no-change decisions for the covered and wiring files, then T4-T6; updates the EPIC tables; the spec moves to `docs/issues/closed/` in a separate `cleanup-completed-issues` PR after the issue closes (as for #2637) | 7-16 | `2824-1347-add-tests-primitives-final` | - | IN_PROGRESS | Rules: S0 to S3 use `Related to #2824`; only S4 uses `Closes #2824`. Do not stack branches; keep at most one implementation PR open. Titles follow the repository convention, for @@ -311,14 +311,14 @@ The 16 rows are every `.rs` file under `packages/primitives/src/`, each once. - [x] Specification and slicing reviewed and approved by the maintainer. - [x] GitHub issue #2824 created. Linking it as a subissue of #1347 needs the maintainer (the bot account gets 404 from the sub-issues API). - [x] Spec-only PR (S0) merged before implementation (#2828). -- [ ] Every ledger row `DONE` with a decision record, merged through its slice. -- [ ] Maintainer review after the final test-producing increment. -- [ ] Automatic verification with toolchain-qualified evidence. -- [ ] Manual verification in `manual-verification-evidence.md`. -- [ ] Bounded mutation assessment in `mutation-evidence.md`. -- [ ] Independent reviewer reports in `agent-review-reports.md` (if used). -- [ ] Acceptance criteria and implementation retrospective. -- [ ] Issue closed; spec moved to `docs/issues/closed/`. +- [x] Every ledger row `DONE` with a decision record, merged through its slice. +- [x] Maintainer review after the final test-producing increment. +- [x] Automatic verification with toolchain-qualified evidence. +- [x] Manual verification in `manual-verification-evidence.md`. +- [x] Bounded mutation assessment in `mutation-evidence.md`. +- [x] Independent reviewer reports in `agent-review-reports.md` (if used): not used; the PR reviews are audited in `docs/pr-reviews/`. +- [x] Acceptance criteria and implementation retrospective. +- [ ] Issue closed (by the S4 PR); spec moved to `docs/issues/closed/` (separate PR after the close). ### Progress Log @@ -333,24 +333,27 @@ The 16 rows are every `.rs` file under `packages/primitives/src/`, each once. - 2026-11-13 08:55 UTC - Claude Code (Sonnet 5.5) - S3: five files, each with an approved decision record and a completed-file review (`announce_interval.rs`, `announce.rs`, `policy.rs`, `mode.rs`, `pagination.rs`); 24 tests added (105 in the package), unit-only lines 93.13%, regions 94.66%, functions 92.69%. The `quickcheck` property for `AnnounceIntervalInSecs` was kept because it alone kills a mid-range band mutant. Two doc comments were corrected (`check_keys_expiration` said the opposite of the behavior; `offset` said "page number" but is a number of items to skip); both were non-behavior findings decided as documentation-only corrections, so no `lessons.md` row is needed beyond this entry. - 2026-11-13 09:03 UTC - Claude Code (Sonnet 5.5) - S3 pushed and opened as PR #2852 against `develop`; the slice table carries the number. - 2026-11-13 09:41 UTC - Claude Code (Sonnet 5.5) - S3 review round 1 of #2852 (Copilot at 09:34 UTC: no open issues; da2ce7 at 09:39 UTC: 8 findings): the description was corrected (the survivor count and the property rule) and the records were corrected (the `i64` mutant, the step coverage figures re-measured at their commits, 90.53%, line references, this frontmatter) and `lessons.md` was created for the REST `offset` wording. Correction of the 2026-11-13 08:55 UTC entry above: it says no `lessons.md` row was needed; one is, for the F8 finding of that review. +- 2026-11-14 12:09 UTC - Claude Code (Opus 5.5) - S3 merged (#2852, 2026-11-14 09:56 UTC) after six review rounds (audit record `docs/pr-reviews/pr-2852-review/PR-REVIEW.md`). S4 started on `2824-1347-add-tests-primitives-final` from `develop`; the baseline is 1,049 / 1,126 lines, 105 tests (5 lines above the S3 close, from the S3 review test fix). +- 2026-11-15 07:49 UTC - Claude Code (Opus 5.5) - S4 test rows: `swarm_metadata.rs` (4 tests, record `swarm_metadata.md`) and the no-change rows 8-16 (record `no-change-files.md`, the `ConfigurationInstanceId` JSON test compares values), both through the two gates; 109 unit tests, 94.07% lines. +- 2026-11-15 08:36 UTC - Claude Code (Opus 5.5) - T4-T6: the package mutation run (147 mutants) found one real survivor, `instance_index` replaced by `1`, killed after the maintainer approved index `2` in its test; M1 and M2 passed against a built tracker; the T5 reconciliation updated the tasks, slices, checkpoints, acceptance rows, coverage evidence and both EPIC tables. `implementation-retrospective.md` records the deviations. F5 still has no GitHub issue (`lessons.md`). The spec moves to `docs/issues/closed/` in a separate PR after the issue closes. ## Acceptance Criteria -- [ ] AC1: Complete per-file inventory with unit-only coverage, property candidacy and hypothesis. -- [ ] AC2: Every row ends in test-added, no-change-with-reason, or deferred-with-owner, with its +- [x] AC1: Complete per-file inventory with unit-only coverage, property candidacy and hypothesis. +- [x] AC2: Every row ends in test-added, no-change-with-reason, or deferred-with-owner, with its decision record and recorded coverage. -- [ ] AC3: Clean, reproducible unit-only coverage evidence with toolchain-qualified results. -- [ ] AC4: Every highest-risk and high objective is protected by a unit test or has a recorded owner. -- [ ] AC5: No-change and deferral decisions enumerate their uncovered lines with per-group reasons. -- [ ] AC6: Each added or changed test has a recorded prose-first AAA review. -- [ ] AC7: Bounded mutation assessment completed, with no score target or CI gate. -- [ ] AC8: Reconciliation confirms plans, evidence, slice table and both EPIC tables agree. -- [ ] AC9: Every finding needing a production change has a draft spec, a log entry and a `lessons.md` +- [x] AC3: Clean, reproducible unit-only coverage evidence with toolchain-qualified results. +- [x] AC4: Every highest-risk and high objective is protected by a unit test or has a recorded owner. +- [x] AC5: No-change and deferral decisions enumerate their uncovered lines with per-group reasons. +- [x] AC6: Each added or changed test has a recorded prose-first AAA review. +- [x] AC7: Bounded mutation assessment completed, with no score target or CI gate. +- [x] AC8: Reconciliation confirms plans, evidence, slice table and both EPIC tables agree. +- [x] AC9: Every finding needing a production change has a draft spec, a log entry and a `lessons.md` row, and no test pins its reported behavior without a recorded maintainer decision. - [ ] AC10: Merged through the planned slices; only the last PR closes the issue. -- [ ] AC11: `cargo +nightly fmt --all -- --check`, `linter all` and +- [x] AC11: `cargo +nightly fmt --all -- --check`, `linter all` and `cargo test -p torrust-tracker-primitives` pass. -- [ ] AC12: Manual verification executed and recorded. +- [x] AC12: Manual verification executed and recorded. ## Verification Plan @@ -375,8 +378,8 @@ Human-oriented interaction with the built tracker, run once in S4 with an isolat | ID | Scenario | Steps | Expected | Status | Evidence | | --- | --- | --- | --- | --- | --- | -| M1 | Default announce interval | Start the tracker with a minimal configuration (no announce policy section); announce once and read the interval from the announce response. | The announce response carries the documented default interval (120 s). The peer cap (74) is not a response field and is protected by the unit test of the default in S3. | TODO | `manual-verification-evidence.md` (S4) | -| M2 | Seeder and leecher counts | Announce one seeder and one leecher with `tracker_client`, then scrape and call the REST API torrent endpoint. | Complete/incomplete counts and the peer JSON match the announces. | TODO | `manual-verification-evidence.md` (S4) | +| M1 | Default announce interval | Start the tracker with a minimal configuration (no announce policy section); announce once and read the interval from the announce response. | The announce response carries the documented default interval (120 s). The peer cap (74) is not a response field and is protected by the unit test of the default in S3. | DONE | `manual-verification-evidence.md` (S4): 120 s over HTTP and UDP. | +| M2 | Seeder and leecher counts | Announce one seeder and one leecher with `tracker_client`, then scrape and call the REST API torrent endpoint. | Complete/incomplete counts and the peer JSON match the announces. | DONE | `manual-verification-evidence.md` (S4): 1 seeder and 1 leecher in both scrapes and the REST API. | ### Acceptance Verification @@ -384,18 +387,18 @@ Reviewed against observed behavior after the last slice, before the issue is clo | AC ID | Status | Evidence | | ----- | ------ | -------- | -| AC1 | TODO | Inventory and T1 hypotheses in `coverage-evidence.md`. | -| AC2 | TODO | All ledger rows `DONE`; plans in `test-refactor-plans/`; per-file results in `coverage-evidence.md`. | -| AC3 | TODO | Commands, toolchains and figures in the final measurement section of `coverage-evidence.md`. | -| AC4 | TODO | Decision records of the highest and high objectives. | -| AC5 | TODO | No-change and deferral records with per-group reasons. | -| AC6 | TODO | Prose-first AAA review in each decision record. | -| AC7 | TODO | `mutation-evidence.md`. | -| AC8 | TODO | The T5 reconciliation and both EPIC tables. | -| AC9 | TODO | Draft specs, progress-log entries and `lessons.md` rows, or a recorded absence of findings. | -| AC10 | TODO | The slice table and the merged pull requests. | -| AC11 | TODO | `cargo +nightly fmt --all -- --check` (nightly Rust), `linter all`, `cargo test -p torrust-tracker-primitives` (stable Rust) output. | -| AC12 | TODO | `manual-verification-evidence.md`. | +| AC1 | DONE | Inventory and T1 hypotheses in `coverage-evidence.md` (16 files, each once). | +| AC2 | DONE | All 16 ledger rows `DONE`; records in `test-refactor-plans/` (`peer.md` to `swarm_metadata.md`, and `no-change-files.md` for rows 8-16); per-slice results in `coverage-evidence.md`. | +| AC3 | DONE | `coverage-evidence.md`, "Final Measurement (AC3)": stable Rust 1.99.1, `cargo-llvm-cov 0.6.16`, 94.07% lines, 95.30% regions, 94.17% functions. | +| AC4 | DONE | Highest and high objectives (peer classification, configuration defaults, the announce interval bound) are tested in `peer.md`, `announce.md`, `policy.md`, `mode.md`, `pagination.md` and `announce_interval.md`; the `peer::fixture` and `Id::new` lines are owned by F5. | +| AC5 | DONE | `no-change-files.md` (per-file reasons) and the uncovered groups of `peer.md`; the only uncovered lines left are in `peer.rs` (F5). | +| AC6 | DONE | A Prose-First AAA table in every record with an added or changed test. | +| AC7 | DONE | `mutation-evidence.md` (no score target, no CI gate). | +| AC8 | DONE | The T5 reconciliation (S4): ledger, plan index, slice table, acceptance rows, coverage evidence and both EPIC "Latest" tables carry the final figures; no record says `status: proposed` or `in-progress`. | +| AC9 | DONE | F1 #2798, F2 fixed in S1 (#2834), F3 #2804, F4 #2823, F6 #2838 and #2850, each with its owner in the Findings Register and a `lessons.md` row. F5 is handed off by decision (2026-11-11) but has no GitHub issue yet; its `lessons.md` row says so. | +| AC10 | IN_PROGRESS | S0-S3 merged (#2828, #2834, #2841, #2852) with `Related to #2824`; S4 is the only PR that uses `Closes #2824`. | +| AC11 | DONE | `cargo +nightly fmt --all -- --check` (nightly Rust), `linter all` (the pre-commit gate of every S4 commit), `cargo test -p torrust-tracker-primitives` (stable Rust 1.99.1: 109 unit tests and 3 doctests pass). | +| AC12 | DONE | `manual-verification-evidence.md`: M1 and M2 passed on 2026-11-15. | ## Risks and Trade-offs diff --git a/docs/issues/open/2824-1347-add-tests-primitives/coverage-evidence.md b/docs/issues/open/2824-1347-add-tests-primitives/coverage-evidence.md index a29a0d4296..5ce98c5d0f 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/coverage-evidence.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/coverage-evidence.md @@ -88,6 +88,43 @@ regions) caught `readiness.rs` at 50 / 52 lines instead of 52 / 52, a file this coverage varied between runs (every other run read 52 / 52). Observation for the S4 `readiness.rs` record: find what makes that coverage vary. +### S4 (`swarm_metadata.rs`, no-change files, final measurement), 2026-11-15 + +Measured on branch `2824-1347-add-tests-primitives-final` after the S3 merge (#2852), with `cargo-llvm-cov 0.6.16` and +stable Rust 1.99.1, same command as the baseline, in a separate `CARGO_LLVM_COV_TARGET_DIR` after +`cargo llvm-cov clean --workspace`. The first S4 baseline run, in the shared target directory, read stale profile data +(it reported lines 75-80 of the 70-line `swarm_metadata.rs`, the deleted `AddAssign`, and 33 lines in `mode.rs`); it +was discarded and repeated in the separate directory. + +| Point | Tests | Lines | Regions | Functions | +| --- | ---: | ---: | ---: | ---: | +| S4 start (`develop` after #2852) | 105 unit | 1,049 / 1,126 (93.16%) | 1,659 / 1,752 (94.69%) | 203 / 219 (92.69%) | +| After `swarm_metadata.rs` | 109 unit | 1,077 / 1,145 (94.06%) | 1,698 / 1,782 (95.29%) | 210 / 223 (94.17%) | +| Final (after the no-change rows and the T4 index fix) | 109 unit | 1,078 / 1,146 (94.07%) | 1,702 / 1,786 (95.30%) | 210 / 223 (94.17%) | + +The S4 start is 5 lines above the S3 close (1,044 / 1,121) with no source change in between: the S3 review commit +`test(primitives): [#2824] compare serialized JSON by value, not by string` changed tests in `announce.rs`, `mode.rs` +and `policy.rs` after the S3 figures were taken. `swarm_metadata.rs` moved from 3 / 12 to 31 / 31 (+28 covered, +19 +lines, the whole step); `configuration_instance_id.rs` from 42 / 42 to 43 / 43 (one longer assertion). The T4 index fix +changes a literal only, so the final figures equal the no-change step. + +### Final Measurement (AC3) + +| Scope | Tests | Lines | Regions | Functions | +| --- | ---: | ---: | ---: | ---: | +| Baseline (`eaae0e487`) | 47 unit | 453 / 748 (60.56%) | 712 / 1,048 (67.94%) | 91 / 159 (57.23%) | +| Final (S4 branch) | 109 unit | 1,078 / 1,146 (94.07%) | 1,702 / 1,786 (95.30%) | 210 / 223 (94.17%) | +| Change | +62 | +33.51 pp | +27.36 pp | +36.94 pp | + +Per file, final unit-only lines: `announce.rs` 56 / 56, `announce_interval.rs` 113 / 113, `configuration_instance_id.rs` +43 / 43, `driver.rs` 59 / 59, `mode.rs` 25 / 25, `number_of_bytes.rs` 3 / 3, `pagination.rs` 42 / 42, `peer.rs` +510 / 578, `policy.rs` 44 / 44, `readiness.rs` 52 / 52, `runtime_service_metadata.rs` 32 / 32, `scrape.rs` 28 / 28, +`service_role.rs` 40 / 40, `swarm_metadata.rs` 31 / 31 (`peer_id.rs` and `lib.rs` have no executable entries). The 68 +uncovered lines are all in `peer.rs`: the `peer::fixture` test support and `peer::Id::new`, classified in +`test-refactor-plans/peer.md` (owned by the F5 follow-up). The baseline includes code removed by other issues since +(`Peer` `Ord`, `AddAssign`), and the totals include the in-file test modules, so the change is not only tests of +existing code. + ## Module Inventory Every `.rs` file under `packages/primitives/src/` (16 files), once. "Initial hypothesis" is a diff --git a/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md b/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md new file mode 100644 index 0000000000..ef6d25e8f2 --- /dev/null +++ b/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md @@ -0,0 +1,76 @@ +--- +semantic-links: + skill-links: + - write-markdown-docs + related-artifacts: + - docs/templates/IMPLEMENTATION-RETROSPECTIVE.md + - docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md + - docs/issues/open/2824-1347-add-tests-primitives/lessons.md + - docs/issues/closed/2637-1347-add-tests-axum-rest-api-server/implementation-retrospective.md +--- + +# Implementation Retrospective — Issue #2824 Add Tests to the Primitives Package + +## Purpose + +Record evidence-based process improvements discovered while implementing #2824. This is a blameless review of the +implementation approach; it does not replace the acceptance verification in [ISSUE.md](ISSUE.md). + +## Outcome + +All 16 source files of `packages/primitives/src/` were processed through the per-file workflow in five pull requests +(the specification, a fix slice and three test slices). Unit-only lines went from 453 / 748 (60.56%) to 1,078 / 1,146 +(94.07%), regions from 67.94% to 95.30% and functions from 57.23% to 94.17%; the package has no integration tests, so +unit-only equals aggregate ([coverage-evidence.md](coverage-evidence.md)). It has 109 unit tests (47 at the baseline). +The only uncovered lines are the `peer::fixture` test support and `peer::Id::new`, owned by the F5 follow-up. One +production defect was fixed here (F2, the `PeerRole` JSON casing, S1); two doc comments were corrected (S3); the others +were handed off (F1 #2798, F3 #2804, F4 #2823, F5, F6 #2838 and #2850). A whole-package mutation run gave 94 caught, 3 +missed (2 equivalent), 2 timeouts and 48 unviable ([mutation-evidence.md](mutation-evidence.md)); the real survivor +got a one-value test fix. M1 and M2 passed against a built tracker +([manual-verification-evidence.md](manual-verification-evidence.md)). + +## What Went Well + +1. Two maintainer gates per file kept each slice small: every plan named its mutants in advance, and each per-file + survivor was explained in its record (an equivalent mutant or a decision taken by design). +2. A `quickcheck` property was kept only where it killed a mutant no example caught (`announce_interval.rs`), so the + new dependency carries a recorded reason. +3. The whole-package run at the end found a gap the per-file samples missed (a test value equal to a default mutant's + constant), and the fix was one literal. + +## What Changed During Implementation + +1. **Review rounds of S3.** PR #2852 took six review rounds, most of them about the records, not the tests: a + mislabeled round, Processing Log entries rewritten in place, stamps before the events, branch SHAs as references. + The audit-record rules were known; they were not checked before each push. +2. **Stale coverage data.** The first S4 baseline read old profile data in the shared target directory (lines of a + deleted impl in a 70-line file). Every later figure used a separate `CARGO_LLVM_COV_TARGET_DIR`. +3. **Spec archive timing.** The slice table said S4 moves the spec to `docs/issues/closed/`. The + `cleanup-completed-issues` skill archives after the issue is closed, and #2637 did it in its own PR; S4 follows the + skill. + +## Root Cause + +1. The audit record is long and append-only; correcting it under time pressure invited in-place edits. No local check + compares a new stamp with the event it records. +2. The stale report came after `cargo llvm-cov clean --workspace` in the default coverage target; why that directory + still held old data was not established. A separate directory gave consistent figures in every later run. + +## Improvements for Future Work + +1. Before each push of a review fix, read the Processing Log diff and confirm it only appends, and take every stamp + with `date -u` after the event it records. +2. Measure coverage in a per-slice `CARGO_LLVM_COV_TARGET_DIR`, and reject a report whose line numbers exceed the file + length. +3. In accessor tests, use values that no default mutant returns (not `0`, `1` or `Default::default()`). + +## Avoiding Overcorrection + +The two-gate workflow is the reason the slices stayed small; the improvements above are local checks, not more gates. + +## Evidence + +- [ISSUE.md](ISSUE.md): progress log, ledger, slice table and acceptance verification. +- [coverage-evidence.md](coverage-evidence.md), [mutation-evidence.md](mutation-evidence.md), + [manual-verification-evidence.md](manual-verification-evidence.md), [lessons.md](lessons.md). +- `docs/pr-reviews/pr-2852-review/PR-REVIEW.md`: the six review rounds of S3. diff --git a/docs/issues/open/2824-1347-add-tests-primitives/lessons.md b/docs/issues/open/2824-1347-add-tests-primitives/lessons.md index 5c53d2ae92..17fc99451f 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/lessons.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/lessons.md @@ -16,6 +16,12 @@ Candidate lessons collected while working on Issue #2824. Promoting any of them | --- | --- | --- | | [Pagination plan](test-refactor-plans/pagination.md) (`review-finding:pr-2852-f8`) | Correct the doc comment of `QueryParams::offset` in the REST API torrent handlers, and check the REST API documentation for the same wording. | `packages/axum-rest-api-server/src/v1/context/torrent/handlers.rs` says "The offset of the first page to return. Starts at 0." but `Pagination::new_with_options` passes the value into `Pagination::offset`, which every consumer uses as the number of items to skip (`.skip(pagination.offset as usize)`). The domain comment was corrected in S3; the REST one is outside this issue's scope. | | [Coverage evidence](coverage-evidence.md) (S3 reconciliation) | In the S4 `readiness.rs` record, find out why its unit-only line coverage varied between runs (50 / 52 in one run, 52 / 52 in every other) and make the test deterministic if it is. | One S3 run measured `readiness.rs` at 50 / 52 with no change to the file, which moved the package totals by two lines in that step. Answered in the S4 [no-change record](test-refactor-plans/no-change-files.md) (row 12): the likely cause is the loop body of the concurrent test (test code, not production); the maintainer decided to leave the test (Q3). | +| [Manual verification](manual-verification-evidence.md) (M2, S4) | Pin the text of the REST peer `event` field in `rest-api-runtime-adapter`, or map `AnnounceEvent` to the REST string explicitly, so a change of the derived `Debug` of the domain enum cannot change the REST API unnoticed. | `packages/rest-api-runtime-adapter/src/v1/conversion.rs` sets `event: format!("{:?}", value.event)`; the M2 run returned `"Completed"` and `"Started"`; its conversion tests compare against `from_domain_peer` itself, so they do not pin the text. | +| [Findings register](ISSUE.md#findings-register) (F1) | None left: `Peer` lost `Ord` and `PartialOrd`. | Bug #2798, fixed by #2811 (merged 2026-11-11). | +| [Findings register](ISSUE.md#findings-register) (F3) | Audit every `Location::caller()` in the packages (65 uses, 3 `#[track_caller]`). | Follow-up issue #2804 (spec PR #2805). | +| [Findings register](ISSUE.md#findings-register) (F4) | None left: the unused `AddAssign` of `AggregateActiveSwarmMetadata` was deleted. | Follow-up issue #2823. | +| [Findings register](ISSUE.md#findings-register) (F5) | Move `peer::Id::new` and `peer::fixture` to test support behind a `testing` feature, with realistic ids. | Handed off by the maintainer's decision (2026-11-11) as `peer-id-test-helper`; **no GitHub issue exists yet** (searched 2026-11-15). The only uncovered lines of the package are its. | +| [Findings register](ISSUE.md#findings-register) (F6) | Make the number of bytes non-negative by construction, so a negative `left` cannot reach `is_seeder`. | #2838 (fix PR #2839 closed unmerged), superseded by #2850 (spec PR #2851). | | [Issue spec](ISSUE.md#out-of-scope) (Out of Scope) | Audit the implicit lowercase and snake_case convention of enum serialization (the F2 `PeerRole` defect came from a `rename_all_fields` that does not apply to unit variants) in a separate issue, under `create-adr`. | `PeerRole` serialized as `"Seeder"` while `Display` and the metric label use `seeder`; fixed in S1 (#2834). | ## Testing Lessons diff --git a/docs/issues/open/2824-1347-add-tests-primitives/manual-verification-evidence.md b/docs/issues/open/2824-1347-add-tests-primitives/manual-verification-evidence.md index 8d8e3ab3a9..d4e8f13558 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/manual-verification-evidence.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/manual-verification-evidence.md @@ -1,15 +1,16 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md -last-updated-utc: "2026-11-11 14:31" +last-updated-utc: "2026-11-15 07:58" --- # Manual Verification Evidence ## Purpose -Record real verification of the slice S1 fix (finding F2, `PeerRole` JSON casing). Nothing -here is invented: every output below was copied from the runs listed, on 2026-11-11. +Record real verification of the slice S1 fix (finding F2, `PeerRole` JSON casing, V1-V3, 2026-11-11) and the +tracker-wide scenarios M1 and M2 of the issue (S4, 2026-11-15). Nothing here is invented: every output below was copied +from the runs listed. ## Environment and Prerequisites @@ -114,7 +115,90 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini The unit tests (49) and the doctests (2 + 1) pass at the head. +### M1 - Default announce interval (S4) + +- Goal: a tracker started with no announce policy section answers announces with the documented default interval + (120 s), over HTTP and UDP. +- Environment: 2026-11-15, branch `2824-1347-add-tests-primitives-final` at the commit + `test(primitives): [#2824] record the no-change files and compare instance id JSON by value`; Linux + 7.0.0-43-generic, stable `rustc 1.99.1`; debug builds of `torrust-tracker` and `tracker_client`. +- Configuration: `.tmp/manual-2824/tracker.toml` (git-ignored), `schema_version = "3.0.0"`, SQLite in `.tmp/`, one + UDP tracker on `127.0.0.1:16979`, one HTTP tracker on `127.0.0.1:17079`, the REST API on `127.0.0.1:11219`. It has + no `[core.announce_policy]` section, so the defaults apply. +- Status: `DONE` + +#### Steps Performed (M1) + +1. 07:54:01 - `./target/debug/torrust-tracker --config-toml-path ./.tmp/manual-2824/tracker.toml` (started in the + background; the HTTP and API ports were listening, `ss -tlnp`). +2. 07:54:20.672 - `tracker_client http announce http://127.0.0.1:17079 1111111111111111111111111111111111111111 + --left 100 --port 6001 '--peer-id=-qB00000000000000011' --compact 0` +3. 07:54:20.679 - `tracker_client udp announce 127.0.0.1:16979 1111111111111111111111111111111111111111` + +#### Observed Result (M1) + +```text +== M1 http 07:54:20.672 +{"complete":0,"incomplete":1,"interval":120,"min interval":120,"peers":[]} +== M1 udp 07:54:20.679 +{"AnnounceIpv4":{"transaction_id":-888840697,"announce_interval":120,"leechers":1,"seeders":1,"peers":["127.0.0.1:6001"]}} +``` + +#### Conclusion (M1) + +Both protocols carry the 120 s default (`interval` and `min interval` over HTTP, `announce_interval` over UDP). The +peer cap (74) is not a response field; it is protected by the unit test of the default in S3. + +### M2 - Seeder and leecher counts (S4) + +- Goal: one seeder and one leecher announced with `tracker_client` give matching complete/incomplete counts in both + scrapes and in the REST API torrent endpoint, with peer JSON that matches the announces. +- Environment and configuration: the same tracker process as M1, on a different info hash. +- Status: `DONE` + +#### Steps Performed (M2) + +1. 07:54:20.684 - a first attempt passed `--ip 10.0.0.1` and `--ip 10.0.0.2`; the tracker answered + `{"failure reason":"Client-supplied peer IPs are disabled"}` (the configuration does not enable them), so nothing + was stored (the scrape at 07:54:20.698 read 0 / 0 and the API said `"torrent not known"`). Repeated without `--ip`: +2. 07:54:25.719 - seeder: `tracker_client http announce http://127.0.0.1:17079 + 9c38422213e30bff212b30c360d26f9a02136422 --event completed --left 0 --port 6881 + '--peer-id=-qB00000000000000001' --compact 0` +3. 07:54:25.726 - leecher: the same with `--event started --left 1000 --port 6882 '--peer-id=-qB00000000000000002'` +4. 07:54:25.733 - `tracker_client http scrape http://127.0.0.1:17079 9c38422213e30bff212b30c360d26f9a02136422` +5. 07:54:25.739 - `tracker_client udp scrape 127.0.0.1:16979 9c38422213e30bff212b30c360d26f9a02136422` +6. 07:54:25.744 - `curl -s http://127.0.0.1:11219/api/v1/torrent/9c38422213e30bff212b30c360d26f9a02136422 -H + "Authorization: Bearer MyAccessToken"` +7. 07:54:35 - the tracker was stopped by its PID (`kill`); its log has no `ERROR` line. + +#### Observed Result (M2) + +```text +== M2 seeder 07:54:25.719 +{"complete":1,"incomplete":0,"interval":120,"min interval":120,"peers":[]} +== M2 leecher 07:54:25.726 +{"complete":1,"incomplete":1,"interval":120,"min interval":120,"peers":[{"ip":"127.0.0.1","peer id":[45,113,66,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,49],"port":6881}]} +== M2 http scrape 07:54:25.733 +{"9c38422213e30bff212b30c360d26f9a02136422":{"complete":1,"downloaded":0,"incomplete":1}} +== M2 udp scrape 07:54:25.739 +{"Scrape":{"transaction_id":-888840697,"torrent_stats":[{"seeders":1,"completed":0,"leechers":1}]}} +== M2 rest 07:54:25.744 +{"info_hash":"9c38422213e30bff212b30c360d26f9a02136422","seeders":1,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d71423030303030303030303030303030303031","client":null},"peer_addr":"127.0.0.1:6881","updated":1794729265724,"updated_milliseconds_ago":1794729265724,"updated_at_ms":1794729265724,"uploaded":0,"downloaded":0,"left":0,"event":"Completed"},{"peer_id":{"id":"0x2d71423030303030303030303030303030303032","client":null},"peer_addr":"127.0.0.1:6882","updated":1794729265730,"updated_milliseconds_ago":1794729265730,"updated_at_ms":1794729265730,"uploaded":0,"downloaded":0,"left":1000,"event":"Started"}]} +``` + +#### Conclusion (M2) + +One seeder and one leecher everywhere: `complete` 1 / `incomplete` 1 over HTTP, `seeders` 1 / `leechers` 1 over UDP and +in the REST API. The two REST peers carry the announced peer ids, ports, `left` (0 and 1000) and events. Two +observations, neither a finding of this package: the download count stays 0 because the seeder's first announce was +already `completed` (it was never a leecher of this swarm), and the deprecated `updated` and +`updated_milliseconds_ago` REST fields equal `updated_at_ms`, as the REST torrent module documents. The `event` text +(`"Completed"`) is the derived `Debug` form of the domain `AnnounceEvent`: `rest-api-runtime-adapter` builds it with +`format!("{:?}", value.event)`, and no test there pins the text. Recorded as a follow-up candidate in `lessons.md`; the +REST contract is outside this issue. + ## Failures and Follow-up -None. The EPIC "Latest" values and the slice coverage measurement are recorded in -`coverage-evidence.md` and the EPIC for this slice. +None. The M2 first attempt failed on a client option this configuration does not allow, not on the +tracker; it is recorded above. The EPIC "Latest" values and the slice coverage measurements are recorded in +`coverage-evidence.md` and the EPIC. diff --git a/docs/issues/open/2824-1347-add-tests-primitives/mutation-evidence.md b/docs/issues/open/2824-1347-add-tests-primitives/mutation-evidence.md new file mode 100644 index 0000000000..a81537913f --- /dev/null +++ b/docs/issues/open/2824-1347-add-tests-primitives/mutation-evidence.md @@ -0,0 +1,89 @@ +--- +doc-type: mutation-evidence +issue: 2824 +package: torrust-tracker-primitives +status: completed +measured-utc: 2026-11-15T07:51:51Z +--- + +# Primitives Mutation Evidence + +This is the bounded mutation-testing assessment (T4) for Issue #2824. The package has only 147 mutants, so every source +file was run. It is not a package score, a coverage target or a CI gate. The per-file mutation samples of S2-S4 are in +each file's decision record; this run checks the whole package once, after the last test-producing commit. + +## Configuration + +```text +RUSTFLAGS="--cap-lints=warn" cargo mutants \ + -p torrust-tracker-primitives --all-features \ + --output .tmp/mutants-2824 --timeout-multiplier 5 --jobs 2 +``` + +`cargo-mutants 27.0.0`, stable Rust 1.99.1, on branch `2824-1347-add-tests-primitives-final` at the commit +`test(primitives): [#2824] record the no-change files and compare instance id JSON by value`. Started +2026-11-15T07:51:51Z, finished 07:52:56Z (64 s). `--cap-lints=warn` follows the #1348 lesson: the workspace denies +`unused`, which would turn replaced bodies into unviable mutants. The baseline without mutations passed. + +## Results + +147 mutants: **94 caught, 3 missed, 2 timeouts, 48 unviable.** + +| File | Caught | Missed | Timeout | Unviable | +| --- | ---: | ---: | ---: | ---: | +| `announce.rs` | 2 | 0 | 0 | 2 | +| `announce_interval.rs` | 12 | 0 | 0 | 5 | +| `configuration_instance_id.rs` | 1 | 1 | 0 | 1 | +| `driver.rs` | 5 | 0 | 0 | 1 | +| `mode.rs` | 1 | 0 | 0 | 0 | +| `pagination.rs` | 3 | 0 | 0 | 1 | +| `peer.rs` | 54 | 0 | 0 | 33 | +| `policy.rs` | 4 | 0 | 0 | 0 | +| `readiness.rs` | 1 | 0 | 2 | 0 | +| `runtime_service_metadata.rs` | 1 | 0 | 0 | 4 | +| `scrape.rs` | 3 | 1 | 0 | 0 | +| `service_role.rs` | 3 | 0 | 0 | 0 | +| `swarm_metadata.rs` | 4 | 1 | 0 | 1 | + +`number_of_bytes.rs`, `peer_id.rs` and `lib.rs` produced no mutants. + +### Missed + +1. `swarm_metadata.rs:35`: replace `SwarmMetadata::zeroed` with `Default::default()`. **Equivalent**: the body is + `Self::default()`. Selected action: none. +2. `scrape.rs:22`: replace `ScrapeData::empty` with `Default::default()`. **Equivalent**: the derived `Default` of + `ScrapeData` is an empty `HashMap`, the same value `empty` builds. Selected action: none. +3. `configuration_instance_id.rs:37`: replace `ConfigurationInstanceId::instance_index` with `1`. **A real, cheap + gap**: the only test that calls `instance_index()` builds the id with index `1`, the constant the mutant returns; + the other tests compare whole ids and never call the accessor. Fixed after the maintainer approved it (2026-11-15): + `it_should_expose_its_role_and_zero_based_index` now uses index `2` (commit + `test(primitives): [#2824] test the instance index with a value no mutant returns`). A re-run on the file at + 2026-11-15T08:33Z (`--file packages/primitives/src/configuration_instance_id.rs`, output `.tmp/mutants-2824-cid`) gave + **2 caught, 1 unviable**, so the mutant is now killed. + +### Timeouts + +`readiness.rs:32` (`is_ready` returns `true`) and `readiness.rs:39` (`mark_not_ready` does nothing): the concurrent +test's readers loop until they see "not ready", so both mutants hang it until the timeout (20 s). They are detected, +since the run fails, but by a hang, not a failed assertion. `it_should_not_be_ready_after_it_is_marked_not_ready` also +fails for both mutants; the timeout comes first only because the whole test binary is stopped. Selected action: none. +The test has no time bound of its own, so a regression would surface in CI as a hung job rather than a failure; +recorded here, not changed (the maintainer kept the test as it is in the S4 no-change record, Q3). + +### Unviable + +All 48 failed to build; none is a lint failure (see the configuration). The first compiler error of each per-mutant log +gives these kinds, which add up to 48: + +- **No `Default` for the returned type** (30, `E0277`): `AnnounceIntervalInSecs` (6), the serializer's `Ok` type (6), + `PeerId` (4), `PeerRole` (3), `AnnounceEvent` (2), `ServiceRole` (2), `SocketAddr` (2), and one each for + `ConfigurationInstanceId`, `Driver`, `IpAddr`, `RuntimeServiceMetadata` and `Url`. +- **Non-`const` call in a `const fn`** (17, `E0015`): `Default::default()` and similar replacements inside the + `const fn` accessors and constructors. +- **Conditionally-`const` call in a `const fn`** (1, `E0658`). + +## Conclusion + +Every behavior the decision records chose to protect kills its mutants. Of the three survivors of the package run, two +are equivalent and one was a cheap test gap, now closed (the file re-run kills it). With that fix the package has no +non-equivalent survivor. diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md index 7bd7a3d4e6..11f07afc0a 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/README.md @@ -2,7 +2,7 @@ doc-type: test-refactor-plan-guidance issue: 2824 package: torrust-tracker-primitives -status: in-progress +status: done last-updated-utc: "2026-11-15 07:48" --- From 4958efd00cc0859521491087ff856067f344c2f2 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 09:42:34 +0000 Subject: [PATCH 05/11] docs(issues): [#2824] record the S4 pull request number Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index b365c532e8..50019ceabe 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -8,7 +8,7 @@ epic: 1347 github-issue: 2824 spec-path: docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md branch: "2824-1347-add-tests-primitives-final" -related-pr: 2852 +related-pr: 2864 last-updated-utc: "2026-11-15 08:36" semantic-links: skill-links: @@ -236,7 +236,7 @@ the maintainer (2026-11-10): | S1 | Defect fixes decided in this issue (T2a): F2 `PeerRole` JSON casing, only (F1 fixed upstream; F3, F4, F5 handed off). Merged first, so the test slices pin the fixed behavior. | - | `2824-1347-add-tests-primitives-fixes` | #2834 | DONE | | S2 | T2, then `peer.rs` (rank 1, the largest gap) | 1 | `2824-1347-add-tests-primitives-peer` | #2841 | DONE | | S3 | Configuration defaults and bounded values: `announce.rs`, `policy.rs`, `mode.rs`, `pagination.rs`, `announce_interval.rs` | 2-6 | `2824-1347-add-tests-primitives-defaults` | #2852 | DONE | -| S4 | `swarm_metadata.rs`, no-change decisions for the covered and wiring files, then T4-T6; updates the EPIC tables; the spec moves to `docs/issues/closed/` in a separate `cleanup-completed-issues` PR after the issue closes (as for #2637) | 7-16 | `2824-1347-add-tests-primitives-final` | - | IN_PROGRESS | +| S4 | `swarm_metadata.rs`, no-change decisions for the covered and wiring files, then T4-T6; updates the EPIC tables; the spec moves to `docs/issues/closed/` in a separate `cleanup-completed-issues` PR after the issue closes (as for #2637) | 7-16 | `2824-1347-add-tests-primitives-final` | #2864 | IN_PROGRESS | Rules: S0 to S3 use `Related to #2824`; only S4 uses `Closes #2824`. Do not stack branches; keep at most one implementation PR open. Titles follow the repository convention, for From a9af8d350dd7dc0c788fd58eb2fa003d06f77825 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 12:34:57 +0000 Subject: [PATCH 06/11] test(primitives): [#2824] add the AAA section comments to the swarm metadata tests The four SwarmMetadata tests separated their sections with blank lines only. They now carry the // Arrange, // Act and // Assert comments the write-unit-test checklist asks for, as the ConfigurationInstanceId tests do. No assertion changes. Co-Authored-By: Claude Opus 5.5 --- packages/primitives/src/swarm_metadata.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/primitives/src/swarm_metadata.rs b/packages/primitives/src/swarm_metadata.rs index 3def1db478..a4ed5baa7b 100644 --- a/packages/primitives/src/swarm_metadata.rs +++ b/packages/primitives/src/swarm_metadata.rs @@ -75,35 +75,46 @@ mod tests { #[test] fn it_should_return_the_number_of_downloads() { + // Arrange let swarm_metadata = SwarmMetadata::new(3, 5, 7); + // Act let downloads = swarm_metadata.downloads(); + // Assert assert_eq!(downloads, 3); } #[test] fn it_should_return_the_number_of_seeders() { + // Arrange let swarm_metadata = SwarmMetadata::new(3, 5, 7); + // Act let seeders = swarm_metadata.seeders(); + // Assert assert_eq!(seeders, 5); } #[test] fn it_should_return_the_number_of_leechers() { + // Arrange let swarm_metadata = SwarmMetadata::new(3, 5, 7); + // Act let leechers = swarm_metadata.leechers(); + // Assert assert_eq!(leechers, 7); } #[test] fn it_should_build_a_zeroed_value_with_every_count_at_zero() { + // Act let swarm_metadata = SwarmMetadata::zeroed(); + // Assert assert_eq!(swarm_metadata, SwarmMetadata::new(0, 0, 0)); } } From fda6c8b8823dcbd15da33e4e2ca34f802ef4a56a Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 12:35:47 +0000 Subject: [PATCH 07/11] docs(issues): [#2824] record the AAA comments added to the swarm metadata tests Co-Authored-By: Claude Opus 5.5 --- .../test-refactor-plans/swarm_metadata.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md index f65d2c3875..ac584f785d 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/test-refactor-plans/swarm_metadata.md @@ -90,6 +90,10 @@ Temporary prose per test was written and compared with the code; the code expres Test smells found and fixed while writing: none. +After review of #2864 (finding F5 of its audit record): the four tests separated the sections with blank lines only; +they now carry the `// Arrange`, `// Act` and `// Assert` comments the `write-unit-test` checklist asks for +(`zeroed` has no arrange step, so it has `// Act` and `// Assert`). + ## Validation `cargo test -p torrust-tracker-primitives` (109 + 2 + 1 passed); `cargo +nightly fmt --all -- --check`; From 2e96b11f59636d8e5a379b8c0fd6233cf24e0217 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 12:36:18 +0000 Subject: [PATCH 08/11] docs(issues): [#2824] record the merged removal of the AddAssign impl in the F4 row The F4 row of the Findings Register still said the unused AddAssign impl of AggregateActiveSwarmMetadata was being deleted. PR #2827 deleted it on 2026-11-11; the row now says so. Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index 50019ceabe..91cdfa96b4 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -199,7 +199,7 @@ maintainer decides to fix in this issue are not handed off: they go to the T2a s | --- | --- | --- | --- | --- | | F1 | `peer::Peer` derives `Eq`/`Hash` over all fields but implements `Ord` by `peer_id` only, so two unequal peers compare `Ordering::Equal` (violates the `Ord`/`Eq` contract). No production collection orders peers today (the swarm keys by `PeerId`), so the impact is latent. | Throwaway test, 2026-11-10: a seeder and a copy with `left = 5` give `a == b` false and `a.cmp(&b) == Equal`. | Handled by a separate bug issue and session, not fixed here (maintainer decision, 2026-11-10). Bug issue: #2798, spec PR #2800. Fixed by PR #2811 (merged 2026-11-11): `Ord` and `PartialOrd` removed from `Peer` (option A, maintainer's choice), guarded by a `compile_fail` doctest in `peer.rs`. | FIXED (upstream) | | F3 | `ParsePeerRoleError::InvalidPeerRole` records `Location::caller()` inside `PeerRole::from_str`, which has no `#[track_caller]`, so every error reports the same line inside `peer.rs` (`peer.rs:73:27`) instead of the caller's. Adding `#[track_caller]` fixes only a direct `from_str` call: through `str::parse` the location is a line in Rust's standard library. The pattern is wider than this type: `Location::caller()` appears 65 times across the packages and `#[track_caller]` 3 times, and the located error may reach production output. | Throwaway test, 2026-11-10: `"x".parse::()` reports `peer.rs:73:27`; with `#[track_caller]`, `parse` reports `core/src/str/mod.rs:2783:9` and a direct `from_str` call reports the caller's line. | Handed off to a follow-up issue that audits every use of `Location::caller()` (maintainer decision, 2026-11-10). Follow-up issue: #2804 (spec PR #2805). Nothing is fixed in this issue. | HANDED OFF | -| F4 | `AggregateActiveSwarmMetadata::add_assign` uses plain `+=` on four `u64` fields (panic in debug, wrap in release on overflow; practically unreachable). The registry and `torrent-repository-benchmarking` sum the fields by hand, so the impl may be dead code. | Code reading, 2026-11-11. | Handed off to a follow-up issue/session `aggregate-addassign` (maintainer decision, 2026-11-11): check whether the impl is used (remove it and run all tests, check git history); delete it if unused, otherwise make overflow explicit (`checked_add` + panic, test, comment). Follow-up issue: #2823. Outcome (maintainer approved, 2026-11-11): the unused `AddAssign` impl is being deleted, so the `AddAssign` lines of `swarm_metadata.rs` are not tested here. Nothing is fixed in this issue. | HANDED OFF | +| F4 | `AggregateActiveSwarmMetadata::add_assign` uses plain `+=` on four `u64` fields (panic in debug, wrap in release on overflow; practically unreachable). The registry and `torrent-repository-benchmarking` sum the fields by hand, so the impl may be dead code. | Code reading, 2026-11-11. | Handed off to a follow-up issue/session `aggregate-addassign` (maintainer decision, 2026-11-11): check whether the impl is used (remove it and run all tests, check git history); delete it if unused, otherwise make overflow explicit (`checked_add` + panic, test, comment). Follow-up issue: #2823. Outcome (maintainer approved, 2026-11-11): the unused `AddAssign` impl was deleted by PR #2827 (merged 2026-11-11), so `swarm_metadata.rs` has no `AddAssign` lines to test. Nothing is fixed in this issue. | HANDED OFF | | F5 | `peer::Id::new` (public, in a production crate) builds a 20-byte id from a little-endian `i128` (4 zero bytes + 16 bytes). Behavior is correct and lossless, including negatives (two's complement). But it is a test-only helper: the only callers found are `torrent-repository-benchmarking` tests, and its ids look like no real client (`get_client_name()` is `None`). It has no doc comment and no tests. | Code reading and caller search, 2026-11-11 (not a behavior defect; a design problem). | Handed off to a follow-up issue/session `peer-id-test-helper` (maintainer decision, 2026-11-11): prove it is unused in production, move it to a testing helper that generates realistic ids, decide with it whether `peer::fixture` (and `Id::new`) move behind a `testing` feature, as the ADR on shared test support asks (EPIC #2482 is closed and did not reorganize `peer::fixture`). Follow-up issue: not yet created when S2 was written (proposal `peer-id-test-helper`); fill in its number. The `Id::new` tests in `peer.rs` wait on its outcome. | HANDED OFF | | F2 | `PeerRole` derives `Serialize` with `#[serde(rename_all_fields = "lowercase")]`, which does not apply to unit variants, so it serializes as `"Seeder"` and `"Leecher"` while `Display` and the `peer_role` metric label use `seeder` and `leecher`. No production code serializes `PeerRole` today. | Throwaway test, 2026-11-10: `serde_json::to_string(&PeerRole::Seeder)` gives `"Seeder"`. | Fixed in this issue, in slice S1 (maintainer decision, 2026-11-10): `rename_all = "lowercase"` plus a regression test, in its own `fix` commit. | FIXED through #2834 | | F6 | `Peer::is_seeder` classifies a negative `left` as a seeder because `NumberOfBytes` is signed; the UDP announce accepts a negative `left` while HTTP rejects it. | Found writing the `peer.rs` tests (S2), 2026-11-12. | Handed off to issue #2838; its fix PR #2839 was closed unmerged, and #2850 (non-negative number of bytes by construction, spec PR #2851) will remove the case. The S2 test pins the classification of the signed domain value and is removed by the #2850 implementation. | HANDED OFF | From cc738c60a8c14f48fed26e1ef04e985886f128ab Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 12:36:49 +0000 Subject: [PATCH 09/11] docs(issues): [#2824] count five review rounds of the S3 pull request The audit record of #2852 names rounds 1 to 5. The retrospective said six in two places; it now says five, and a progress-log entry corrects the 2026-11-14 12:09 entry without rewriting it. Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md | 1 + .../implementation-retrospective.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index 91cdfa96b4..795c41a3ee 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -336,6 +336,7 @@ The 16 rows are every `.rs` file under `packages/primitives/src/`, each once. - 2026-11-14 12:09 UTC - Claude Code (Opus 5.5) - S3 merged (#2852, 2026-11-14 09:56 UTC) after six review rounds (audit record `docs/pr-reviews/pr-2852-review/PR-REVIEW.md`). S4 started on `2824-1347-add-tests-primitives-final` from `develop`; the baseline is 1,049 / 1,126 lines, 105 tests (5 lines above the S3 close, from the S3 review test fix). - 2026-11-15 07:49 UTC - Claude Code (Opus 5.5) - S4 test rows: `swarm_metadata.rs` (4 tests, record `swarm_metadata.md`) and the no-change rows 8-16 (record `no-change-files.md`, the `ConfigurationInstanceId` JSON test compares values), both through the two gates; 109 unit tests, 94.07% lines. - 2026-11-15 08:36 UTC - Claude Code (Opus 5.5) - T4-T6: the package mutation run (147 mutants) found one real survivor, `instance_index` replaced by `1`, killed after the maintainer approved index `2` in its test; M1 and M2 passed against a built tracker; the T5 reconciliation updated the tasks, slices, checkpoints, acceptance rows, coverage evidence and both EPIC tables. `implementation-retrospective.md` records the deviations. F5 still has no GitHub issue (`lessons.md`). The spec moves to `docs/issues/closed/` in a separate PR after the issue closes. +- 2026-11-15 12:35 UTC - Claude Code (Opus 5.5) - Correction to the 2026-11-14 12:09 entry: the audit record of #2852 (`docs/pr-reviews/pr-2852-review/PR-REVIEW.md`) records five review rounds, not six; `implementation-retrospective.md` now says five. ## Acceptance Criteria diff --git a/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md b/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md index ef6d25e8f2..8a711553ae 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md @@ -40,7 +40,7 @@ got a one-value test fix. M1 and M2 passed against a built tracker ## What Changed During Implementation -1. **Review rounds of S3.** PR #2852 took six review rounds, most of them about the records, not the tests: a +1. **Review rounds of S3.** PR #2852 took five review rounds, most of them about the records, not the tests: a mislabeled round, Processing Log entries rewritten in place, stamps before the events, branch SHAs as references. The audit-record rules were known; they were not checked before each push. 2. **Stale coverage data.** The first S4 baseline read old profile data in the shared target directory (lines of a @@ -73,4 +73,4 @@ The two-gate workflow is the reason the slices stayed small; the improvements ab - [ISSUE.md](ISSUE.md): progress log, ledger, slice table and acceptance verification. - [coverage-evidence.md](coverage-evidence.md), [mutation-evidence.md](mutation-evidence.md), [manual-verification-evidence.md](manual-verification-evidence.md), [lessons.md](lessons.md). -- `docs/pr-reviews/pr-2852-review/PR-REVIEW.md`: the six review rounds of S3. +- `docs/pr-reviews/pr-2852-review/PR-REVIEW.md`: the five review rounds of S3. From 290802ac914f1e377714ea9ee9b440425d49e243 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 12:47:52 +0000 Subject: [PATCH 10/11] docs(issues): [#2824] cite the F5 draft spec pull request for AC9 AC9 asks for a draft spec for every finding that needs a production change. F5 had none; its draft spec is now PR #2865 (docs/issues/drafts/peer-id-test-helper/ISSUE.md). The Findings Register row, the AC9 evidence row, the peer::fixture risk, the lessons row and the retrospective cite it, and a progress-log entry records it. Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md | 7 ++++--- .../implementation-retrospective.md | 6 +++--- docs/issues/open/2824-1347-add-tests-primitives/lessons.md | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md index 795c41a3ee..6b2a4a6963 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md @@ -200,7 +200,7 @@ maintainer decides to fix in this issue are not handed off: they go to the T2a s | F1 | `peer::Peer` derives `Eq`/`Hash` over all fields but implements `Ord` by `peer_id` only, so two unequal peers compare `Ordering::Equal` (violates the `Ord`/`Eq` contract). No production collection orders peers today (the swarm keys by `PeerId`), so the impact is latent. | Throwaway test, 2026-11-10: a seeder and a copy with `left = 5` give `a == b` false and `a.cmp(&b) == Equal`. | Handled by a separate bug issue and session, not fixed here (maintainer decision, 2026-11-10). Bug issue: #2798, spec PR #2800. Fixed by PR #2811 (merged 2026-11-11): `Ord` and `PartialOrd` removed from `Peer` (option A, maintainer's choice), guarded by a `compile_fail` doctest in `peer.rs`. | FIXED (upstream) | | F3 | `ParsePeerRoleError::InvalidPeerRole` records `Location::caller()` inside `PeerRole::from_str`, which has no `#[track_caller]`, so every error reports the same line inside `peer.rs` (`peer.rs:73:27`) instead of the caller's. Adding `#[track_caller]` fixes only a direct `from_str` call: through `str::parse` the location is a line in Rust's standard library. The pattern is wider than this type: `Location::caller()` appears 65 times across the packages and `#[track_caller]` 3 times, and the located error may reach production output. | Throwaway test, 2026-11-10: `"x".parse::()` reports `peer.rs:73:27`; with `#[track_caller]`, `parse` reports `core/src/str/mod.rs:2783:9` and a direct `from_str` call reports the caller's line. | Handed off to a follow-up issue that audits every use of `Location::caller()` (maintainer decision, 2026-11-10). Follow-up issue: #2804 (spec PR #2805). Nothing is fixed in this issue. | HANDED OFF | | F4 | `AggregateActiveSwarmMetadata::add_assign` uses plain `+=` on four `u64` fields (panic in debug, wrap in release on overflow; practically unreachable). The registry and `torrent-repository-benchmarking` sum the fields by hand, so the impl may be dead code. | Code reading, 2026-11-11. | Handed off to a follow-up issue/session `aggregate-addassign` (maintainer decision, 2026-11-11): check whether the impl is used (remove it and run all tests, check git history); delete it if unused, otherwise make overflow explicit (`checked_add` + panic, test, comment). Follow-up issue: #2823. Outcome (maintainer approved, 2026-11-11): the unused `AddAssign` impl was deleted by PR #2827 (merged 2026-11-11), so `swarm_metadata.rs` has no `AddAssign` lines to test. Nothing is fixed in this issue. | HANDED OFF | -| F5 | `peer::Id::new` (public, in a production crate) builds a 20-byte id from a little-endian `i128` (4 zero bytes + 16 bytes). Behavior is correct and lossless, including negatives (two's complement). But it is a test-only helper: the only callers found are `torrent-repository-benchmarking` tests, and its ids look like no real client (`get_client_name()` is `None`). It has no doc comment and no tests. | Code reading and caller search, 2026-11-11 (not a behavior defect; a design problem). | Handed off to a follow-up issue/session `peer-id-test-helper` (maintainer decision, 2026-11-11): prove it is unused in production, move it to a testing helper that generates realistic ids, decide with it whether `peer::fixture` (and `Id::new`) move behind a `testing` feature, as the ADR on shared test support asks (EPIC #2482 is closed and did not reorganize `peer::fixture`). Follow-up issue: not yet created when S2 was written (proposal `peer-id-test-helper`); fill in its number. The `Id::new` tests in `peer.rs` wait on its outcome. | HANDED OFF | +| F5 | `peer::Id::new` (public, in a production crate) builds a 20-byte id from a little-endian `i128` (4 zero bytes + 16 bytes). Behavior is correct and lossless, including negatives (two's complement). But it is a test-only helper: the only callers found are `torrent-repository-benchmarking` tests, and its ids look like no real client (`get_client_name()` is `None`). It has no doc comment and no tests. | Code reading and caller search, 2026-11-11 (not a behavior defect; a design problem). | Handed off to a follow-up issue/session `peer-id-test-helper` (maintainer decision, 2026-11-11): prove it is unused in production, move it to a testing helper that generates realistic ids, decide with it whether `peer::fixture` (and `Id::new`) move behind a `testing` feature, as the ADR on shared test support asks (EPIC #2482 is closed and did not reorganize `peer::fixture`). Draft spec: `docs/issues/drafts/peer-id-test-helper/ISSUE.md`, PR #2865 (opened 2026-11-15, after review finding F1 of #2864); no GitHub issue yet, because the maintainer first answers its open design questions. The `Id::new` tests in `peer.rs` wait on its outcome. | HANDED OFF | | F2 | `PeerRole` derives `Serialize` with `#[serde(rename_all_fields = "lowercase")]`, which does not apply to unit variants, so it serializes as `"Seeder"` and `"Leecher"` while `Display` and the `peer_role` metric label use `seeder` and `leecher`. No production code serializes `PeerRole` today. | Throwaway test, 2026-11-10: `serde_json::to_string(&PeerRole::Seeder)` gives `"Seeder"`. | Fixed in this issue, in slice S1 (maintainer decision, 2026-11-10): `rename_all = "lowercase"` plus a regression test, in its own `fix` commit. | FIXED through #2834 | | F6 | `Peer::is_seeder` classifies a negative `left` as a seeder because `NumberOfBytes` is signed; the UDP announce accepts a negative `left` while HTTP rejects it. | Found writing the `peer.rs` tests (S2), 2026-11-12. | Handed off to issue #2838; its fix PR #2839 was closed unmerged, and #2850 (non-negative number of bytes by construction, spec PR #2851) will remove the case. The S2 test pins the classification of the signed domain value and is removed by the #2850 implementation. | HANDED OFF | @@ -337,6 +337,7 @@ The 16 rows are every `.rs` file under `packages/primitives/src/`, each once. - 2026-11-15 07:49 UTC - Claude Code (Opus 5.5) - S4 test rows: `swarm_metadata.rs` (4 tests, record `swarm_metadata.md`) and the no-change rows 8-16 (record `no-change-files.md`, the `ConfigurationInstanceId` JSON test compares values), both through the two gates; 109 unit tests, 94.07% lines. - 2026-11-15 08:36 UTC - Claude Code (Opus 5.5) - T4-T6: the package mutation run (147 mutants) found one real survivor, `instance_index` replaced by `1`, killed after the maintainer approved index `2` in its test; M1 and M2 passed against a built tracker; the T5 reconciliation updated the tasks, slices, checkpoints, acceptance rows, coverage evidence and both EPIC tables. `implementation-retrospective.md` records the deviations. F5 still has no GitHub issue (`lessons.md`). The spec moves to `docs/issues/closed/` in a separate PR after the issue closes. - 2026-11-15 12:35 UTC - Claude Code (Opus 5.5) - Correction to the 2026-11-14 12:09 entry: the audit record of #2852 (`docs/pr-reviews/pr-2852-review/PR-REVIEW.md`) records five review rounds, not six; `implementation-retrospective.md` now says five. +- 2026-11-15 12:47 UTC - Claude Code (Opus 5.5) - F5 draft spec: after review finding F1 of #2864 (AC9 checked without an F5 draft), the maintainer had a separate session write `docs/issues/drafts/peer-id-test-helper/ISSUE.md`; its PR #2865 was opened at 12:47 UTC. The Findings Register, the AC9 row, the `peer::fixture` risk and the `lessons.md` row now cite it. It has no GitHub issue yet. ## Acceptance Criteria @@ -396,7 +397,7 @@ Reviewed against observed behavior after the last slice, before the issue is clo | AC6 | DONE | A Prose-First AAA table in every record with an added or changed test. | | AC7 | DONE | `mutation-evidence.md` (no score target, no CI gate). | | AC8 | DONE | The T5 reconciliation (S4): ledger, plan index, slice table, acceptance rows, coverage evidence and both EPIC "Latest" tables carry the final figures; no record says `status: proposed` or `in-progress`. | -| AC9 | DONE | F1 #2798, F2 fixed in S1 (#2834), F3 #2804, F4 #2823, F6 #2838 and #2850, each with its owner in the Findings Register and a `lessons.md` row. F5 is handed off by decision (2026-11-11) but has no GitHub issue yet; its `lessons.md` row says so. | +| AC9 | DONE | F1 #2798, F2 fixed in S1 (#2834), F3 #2804, F4 #2823, F6 #2838 and #2850, each with its owner in the Findings Register and a `lessons.md` row. F5 is handed off by decision (2026-11-11); its draft spec is PR #2865 (`docs/issues/drafts/peer-id-test-helper/ISSUE.md`), with no GitHub issue yet; its `lessons.md` row says so. | | AC10 | IN_PROGRESS | S0-S3 merged (#2828, #2834, #2841, #2852) with `Related to #2824`; S4 is the only PR that uses `Closes #2824`. | | AC11 | DONE | `cargo +nightly fmt --all -- --check` (nightly Rust), `linter all` (the pre-commit gate of every S4 commit), `cargo test -p torrust-tracker-primitives` (stable Rust 1.99.1: 109 unit tests and 3 doctests pass). | | AC12 | DONE | `manual-verification-evidence.md`: M1 and M2 passed on 2026-11-15. | @@ -411,7 +412,7 @@ Reviewed against observed behavior after the last slice, before the issue is clo `20261021190318_share_workspace_test_support_through_testing_features.md` puts shared test support behind a `testing` feature. EPIC #2482 (closed, `status: done`) did not reorganize it. Its lines are planned to be classified as test support in the `peer.rs` record (S2): no package-owned behavior, so - no unit test by decision; the live owner of any move is the F5 follow-up (issue number to be filled in). + no unit test by decision; the live owner of any move is the F5 follow-up (draft spec PR #2865). - `develop` moves under the work; mitigate by re-measuring at every slice start. ## Implementation Completion Review diff --git a/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md b/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md index 8a711553ae..41bf0e43ac 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/implementation-retrospective.md @@ -24,9 +24,9 @@ All 16 source files of `packages/primitives/src/` were processed through the per unit-only equals aggregate ([coverage-evidence.md](coverage-evidence.md)). It has 109 unit tests (47 at the baseline). The only uncovered lines are the `peer::fixture` test support and `peer::Id::new`, owned by the F5 follow-up. One production defect was fixed here (F2, the `PeerRole` JSON casing, S1); two doc comments were corrected (S3); the others -were handed off (F1 #2798, F3 #2804, F4 #2823, F5, F6 #2838 and #2850). A whole-package mutation run gave 94 caught, 3 -missed (2 equivalent), 2 timeouts and 48 unviable ([mutation-evidence.md](mutation-evidence.md)); the real survivor -got a one-value test fix. M1 and M2 passed against a built tracker +were handed off (F1 #2798, F3 #2804, F4 #2823, F5 draft spec PR #2865, F6 #2838 and #2850). A whole-package mutation +run gave 94 caught, 3 missed (2 equivalent), 2 timeouts and 48 unviable ([mutation-evidence.md](mutation-evidence.md)); +the real survivor got a one-value test fix. M1 and M2 passed against a built tracker ([manual-verification-evidence.md](manual-verification-evidence.md)). ## What Went Well diff --git a/docs/issues/open/2824-1347-add-tests-primitives/lessons.md b/docs/issues/open/2824-1347-add-tests-primitives/lessons.md index 17fc99451f..f87db070e8 100644 --- a/docs/issues/open/2824-1347-add-tests-primitives/lessons.md +++ b/docs/issues/open/2824-1347-add-tests-primitives/lessons.md @@ -20,7 +20,7 @@ Candidate lessons collected while working on Issue #2824. Promoting any of them | [Findings register](ISSUE.md#findings-register) (F1) | None left: `Peer` lost `Ord` and `PartialOrd`. | Bug #2798, fixed by #2811 (merged 2026-11-11). | | [Findings register](ISSUE.md#findings-register) (F3) | Audit every `Location::caller()` in the packages (65 uses, 3 `#[track_caller]`). | Follow-up issue #2804 (spec PR #2805). | | [Findings register](ISSUE.md#findings-register) (F4) | None left: the unused `AddAssign` of `AggregateActiveSwarmMetadata` was deleted. | Follow-up issue #2823. | -| [Findings register](ISSUE.md#findings-register) (F5) | Move `peer::Id::new` and `peer::fixture` to test support behind a `testing` feature, with realistic ids. | Handed off by the maintainer's decision (2026-11-11) as `peer-id-test-helper`; **no GitHub issue exists yet** (searched 2026-11-15). The only uncovered lines of the package are its. | +| [Findings register](ISSUE.md#findings-register) (F5) | Move `peer::Id::new` and `peer::fixture` to test support behind a `testing` feature, with realistic ids. | Handed off by the maintainer's decision (2026-11-11) as `peer-id-test-helper`; draft spec PR #2865 (`docs/issues/drafts/peer-id-test-helper/ISSUE.md`, opened 2026-11-15); no GitHub issue yet. The only uncovered lines of the package are its. | | [Findings register](ISSUE.md#findings-register) (F6) | Make the number of bytes non-negative by construction, so a negative `left` cannot reach `is_seeder`. | #2838 (fix PR #2839 closed unmerged), superseded by #2850 (spec PR #2851). | | [Issue spec](ISSUE.md#out-of-scope) (Out of Scope) | Audit the implicit lowercase and snake_case convention of enum serialization (the F2 `PeerRole` defect came from a `rename_all_fields` that does not apply to unit variants) in a separate issue, under `create-adr`. | `PeerRole` serialized as `"Seeder"` while `Display` and the metric label use `seeder`; fixed in S1 (#2834). | From 2c9c69b82fc2e2ad0985324dc864e88e2d1e5221 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 12:52:50 +0000 Subject: [PATCH 11/11] docs(pr-reviews): [#2824] add the PR 2864 review audit record for round 1 da2ce7's review 5910653714 (F1 to F5, all fixed, replied to and resolved) and Copilot's review 5910671180 (approval recommended, no findings). Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2864-review/PR-REVIEW.md | 177 ++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 docs/pr-reviews/pr-2864-review/PR-REVIEW.md diff --git a/docs/pr-reviews/pr-2864-review/PR-REVIEW.md b/docs/pr-reviews/pr-2864-review/PR-REVIEW.md new file mode 100644 index 0000000000..f303b6f71a --- /dev/null +++ b/docs/pr-reviews/pr-2864-review/PR-REVIEW.md @@ -0,0 +1,177 @@ +--- +semantic-links: + skill-links: + - process-pr-review + related-artifacts: + - .github/skills/dev/pr-reviews/process-pr-review/SKILL.md +--- + +# PR #2864 Review Audit + +Source: pull-request reviews and inline review threads for https://github.com/torrust/torrust-tracker/pull/2864. + +## 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 + +Round 1 is da2ce7's review `5910653714` (changes requested) at the head whose last commit is +`docs(issues): [#2824] record the S4 pull request number`. Its five inline findings keep the +reviewer's IDs F1 to F5; the review body only summarizes them. + +| Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | +| ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | +| F1 | review-finding:pr-2864-f1 | Human | Major | documentation | ORIGINAL | FIXED | RESOLVED | +| F2 | review-finding:pr-2864-f2 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F3 | review-finding:pr-2864-f3 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F4 | review-finding:pr-2864-f4 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F5 | review-finding:pr-2864-f5 | Human | Nit | testing | ORIGINAL | FIXED | RESOLVED | + +## Finding Details + +### F1 - AC9 is checked, but F5 has no draft spec and no issue + +- PR number: 2864 +- Source review ID: 5910653714 +- Reviewer finding ID: F1 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578333763 +- Concern: AC9 requires a draft spec, a log entry and a `lessons.md` row for every finding that needs + a production change. F5 (`peer::Id::new` and `peer::fixture` in a production crate) had none of a + draft spec or an issue, yet AC9 was checked, and this PR closes #2824. +- Solution: The maintainer chose a draft spec written by a separate session on its own branch from + `develop`, as the findings procedure of #2824 asks: PR #2865 adds + `docs/issues/drafts/peer-id-test-helper/ISSUE.md`. The F5 register row, the AC9 evidence row, the + `peer::fixture` risk, the F5 `lessons.md` row and the retrospective cite it; a progress-log entry + (2026-11-15 12:47) records it. It has no GitHub issue yet: its open design questions go to the + maintainer first. AC9 stays checked. +- Current-tree verification: `gh-bot pr view 2865` shows it open, by `josecelano-bot`, created + 2026-11-15T12:47:15Z, changing only `docs/issues/drafts/peer-id-test-helper/ISSUE.md`; + `grep -n 'fill in its number\|to be filled in\|no GitHub issue exists'` over the issue folder prints + nothing. +- Resolution reference: docs(issues): [#2824] cite the F5 draft spec pull request for AC9 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578461775 + +### F2 - T5 is DONE, but the Findings Register was not reconciled + +- PR number: 2864 +- Source review ID: 5910653714 +- Reviewer finding ID: F2 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578333768 +- Concern: The F5 register row kept the "fill in its number" placeholder, and the F4 row still said + the `AddAssign` impl "is being deleted", although its removal is merged. +- Solution: The F4 row now says PR #2827 deleted the impl on 2026-11-11 (`gh-bot pr list --search + 2823 --state merged` lists #2827, merged 2026-11-11T13:43:48Z). The F5 placeholder is replaced + in the F1 fix (`docs(issues): [#2824] cite the F5 draft spec pull request for AC9`). +- Current-tree verification: `grep -n 'is being deleted'` over the issue folder prints nothing; the F4 + row reads "was deleted by PR #2827 (merged 2026-11-11)". +- Resolution reference: docs(issues): [#2824] record the merged removal of the AddAssign impl in the F4 row +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578461942 + +### F3 - The cited audit records five review rounds, not six + +- PR number: 2864 +- Source review ID: 5910653714 +- Reviewer finding ID: F3 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578333773 +- Concern: `docs/pr-reviews/pr-2852-review/PR-REVIEW.md` names rounds 1 to 5, but the retrospective + (twice) and the progress-log entry of 2026-11-14 12:09 say six. +- Solution: The retrospective says five in both places. The progress-log entry is not rewritten; an + appended entry (2026-11-15 12:35) corrects it. +- Current-tree verification: `grep -rn 'six review'` over the issue folder prints only the + 2026-11-14 12:09 progress-log entry, which the appended entry corrects; `PR-REVIEW.md` of #2852 + names rounds 1 to 5, and its reviews list shows no later da2ce7 or Copilot review. +- Resolution reference: docs(issues): [#2824] count five review rounds of the S3 pull request +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578462094 + +### F4 - The description miscounts the test targets + +- PR number: 2864 +- Source review ID: 5910653714 +- Reviewer finding ID: F4 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578333776 +- Concern: The description said "the other two test targets pass, 2 + 1"; the package has no + `tests/` directory, and the 2 + 1 are the three doctests of `peer.rs` reported in two groups. +- Solution: The description's Validation line now says "109 unit tests and the 3 doctests, 2 + 1". + The plan records count `109 + 2 + 1` per cargo group, which is correct, so they are unchanged. +- Current-tree verification: `gh-bot pr view 2864 --json body` shows the new line and no + "test targets". +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2864#issuecomment-6894593185 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578462209 + +### F5 - The new tests omit the AAA section comments + +- PR number: 2864 +- Source review ID: 5910653714 +- Reviewer finding ID: F5 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578333781 +- Concern: The four `SwarmMetadata` tests separated their sections with blank lines only, while the + `write-unit-test` checklist asks for `// Arrange`, `// Act` and `// Assert` comments. +- Solution: Added the comments (the `zeroed` test has no arrange step, so it has `// Act` and + `// Assert`); no assertion changed. `swarm_metadata.md` records the change in a separate commit, + `docs(issues): [#2824] record the AAA comments added to the swarm metadata tests`. +- Current-tree verification: `cargo test -p torrust-tracker-primitives --lib swarm_metadata`: 4 passed; + `cargo +nightly fmt --all -- --check` passed; the pre-commit gate passed at the commit. +- Resolution reference: test(primitives): [#2824] add the AAA section comments to the swarm metadata tests +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2864#discussion_r4578462329 + +## Processing Log + +- 2026-11-15 12:37 UTC - Started this audit for da2ce7's review `5910653714` (submitted + 2026-11-15T12:19:00Z), before any reply. F2, F3 and F5 are committed locally; F1 waits on the F5 + draft spec the maintainer asked for (a separate session and PR); F4 is a description edit. +- 2026-11-15 12:41 UTC - Copilot's review `5910671180` (submitted 2026-11-15T12:22:14Z, same head) + recommends approval with no findings and no inline comments; no row. +- 2026-11-15 12:52 UTC - Round 1 processed. The fixes were pushed by `git-bot-push` (head + `docs(issues): [#2824] cite the F5 draft spec pull request for AC9`); the description was edited + and comment https://github.com/torrust/torrust-tracker/pull/2864#issuecomment-6894593185 states + the F4 and F1 description changes; each of the five threads has a reply and was resolved + (`isResolved: true`). `validate-audit-record.py --pr-number 2864` returned `status: ok`, 5 rows, + 0 failures, before the resolution. + +## 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.