From f1121d9fc7eb60f07ff6f11daaa29663e5217d03 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:34:22 +0000 Subject: [PATCH 01/28] test(udp-core): [#2850] add a UDP announce benchmark No Criterion benchmark timed a UDP announce. `udp_tracker/announce_once` times one awaited `AnnounceService::handle_announce` of a repeat announce on a public tracker with events disabled, so the wire-to-domain conversion of the counters is on the timed path. It carries the routine guard. Co-Authored-By: Claude Opus 5.5 --- docs/benchmarking.md | 2 +- packages/udp-core/benches/helpers/announce.rs | 117 ++++++++++++++++++ packages/udp-core/benches/helpers/mod.rs | 1 + .../benches/udp_tracker_core_benchmark.rs | 27 +++- 4 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 packages/udp-core/benches/helpers/announce.rs diff --git a/docs/benchmarking.md b/docs/benchmarking.md index 39c2a5f37a..f8264ef03f 100644 --- a/docs/benchmarking.md +++ b/docs/benchmarking.md @@ -32,7 +32,7 @@ is the agent workflow for this guide. | Level | Tool and location | Measures | Does not measure | Run it with | | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------- | | Function microbenchmark | Criterion, `packages/udp-core/benches/connection_cookie_benchmark.rs` | One `connection_cookie::make` or `check` call | Request handling, I/O | `cargo bench -p torrust-tracker-udp-core --bench connection_cookie_benchmark` | -| Service microbenchmark | Criterion, `packages/udp-core/benches/udp_tracker_core_benchmark.rs` | One awaited `ConnectService::handle_connect`, events disabled | Socket I/O, events | `cargo bench -p torrust-tracker-udp-core --bench udp_tracker_core_benchmark` | +| Service microbenchmark | Criterion, `packages/udp-core/benches/udp_tracker_core_benchmark.rs` | One awaited `ConnectService::handle_connect`, and one awaited `AnnounceService::handle_announce` (a repeat announce), events disabled | Socket I/O, events | `cargo bench -p torrust-tracker-udp-core --bench udp_tracker_core_benchmark` | | Service microbenchmark | Criterion, `packages/udp-core/benches/ban_service_benchmark.rs` ([guide](../packages/udp-core/docs/benchmarking/banning.md)) | `BanService` counter operations | Socket I/O, lock contention | `cargo bench -p torrust-tracker-udp-core --bench ban_service_benchmark` | | Handler microbenchmark | Criterion, `packages/udp-server/benches/udp_tracker_server_benchmark.rs` | One `handle_scrape` of 74 torrents | Socket I/O, the receive loop | `cargo bench -p torrust-tracker-udp-server` | | Service microbenchmark | Criterion, `packages/http-core/benches/http_tracker_core_benchmark.rs` | One awaited `AnnounceService::handle_announce`, a repeat announce ([why](#http-announce-microbenchmark)) | HTTP parsing, first announces | `cargo bench -p torrust-tracker-http-core` | diff --git a/packages/udp-core/benches/helpers/announce.rs b/packages/udp-core/benches/helpers/announce.rs new file mode 100644 index 0000000000..a20be96cf3 --- /dev/null +++ b/packages/udp-core/benches/helpers/announce.rs @@ -0,0 +1,117 @@ +use std::net::{IpAddr, Ipv4Addr, SocketAddr}; +use std::num::NonZeroU16; +use std::ops::Range; +use std::sync::Arc; + +use torrust_net_primitives::service_binding::{Protocol, ServiceBinding}; +use torrust_tracker_configuration::v3_0_0::core::Core; +use torrust_tracker_core::announce_handler::AnnounceHandler; +use torrust_tracker_core::torrent::repository::in_memory::InMemoryTorrentRepository; +use torrust_tracker_core::whitelist::authorization::WhitelistAuthorization; +use torrust_tracker_core::whitelist::repository::in_memory::InMemoryWhitelist; +use torrust_tracker_events::bus::SenderStatus; +use torrust_tracker_primitives::{AnnounceData, ConfigurationInstanceId, PeerId, ServiceRole}; +use torrust_tracker_udp_core::connection_cookie::{gen_remote_fingerprint, make}; +use torrust_tracker_udp_core::crypto::cookie_cipher::CookieCipher; +use torrust_tracker_udp_core::event::bus::EventBus; +use torrust_tracker_udp_core::event::sender::Broadcaster; +use torrust_tracker_udp_core::services::announce::AnnounceService; +use torrust_tracker_udp_protocol::{ + AnnounceActionPlaceholder, AnnounceEvent, AnnounceRequest, InfoHash, NumberOfBytes, NumberOfPeers, PeerKey, Port, + TransactionId, +}; + +use crate::helpers::utils::{sample_ipv4_remote_addr, sample_issue_time}; + +/// An announce service and request built once, outside the measured loop. +/// +/// Every iteration announces the same peer to the same torrent, so after the +/// first iteration each announce updates the existing peer in a one-peer swarm +/// and returns an empty peer list, as the HTTP `announce_once` benchmark does +/// (see `docs/benchmarking.md` for why). The result is a lower bound on +/// announce cost. +/// +/// The tracker is public and events are disabled, so an announce measures the +/// connection-cookie check, the whitelist check, the conversion of the wire +/// request into a domain peer, and the swarm update. +pub struct AnnounceBenchmarkContext { + announce_service: AnnounceService, + announce_request: AnnounceRequest, + client_socket_addr: SocketAddr, + server_service_binding: ServiceBinding, + cookie_valid_range: Range, +} + +impl AnnounceBenchmarkContext { + /// # Panics + /// + /// Panics if the connection cookie cannot be made for the fixed issue time, + /// or if the fixed server address is not a valid UDP service binding. + #[must_use] + pub fn new() -> Self { + let core = Core::default(); + let whitelist_authorization = Arc::new(WhitelistAuthorization::new(&core, &Arc::new(InMemoryWhitelist::default()))); + let torrents = Arc::new(InMemoryTorrentRepository::default()); + let announce_handler = AnnounceHandler::new_public(&core, &whitelist_authorization, &torrents); + let cookie_cipher = CookieCipher::random(); + let event_bus = Arc::new(EventBus::new(SenderStatus::Disabled, Broadcaster::default())); + + let client_socket_addr = sample_ipv4_remote_addr(); + let connection_id = make( + &cookie_cipher, + gen_remote_fingerprint(&client_socket_addr), + sample_issue_time(), + ) + .expect("the fixed issue time should make a connection cookie"); + + let announce_service = AnnounceService::new( + Arc::new(announce_handler), + whitelist_authorization, + Arc::new(cookie_cipher), + event_bus.sender(), + ConfigurationInstanceId::new(ServiceRole::UdpTracker, 0), + None, + ); + + let server_socket_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 196)), 6969); + + Self { + announce_service, + announce_request: AnnounceRequest { + connection_id, + action_placeholder: AnnounceActionPlaceholder::default(), + transaction_id: TransactionId(0i32.into()), + info_hash: InfoHash([0x11; 20]), + peer_id: PeerId([0x2d; 20]), + bytes_downloaded: NumberOfBytes(0i64.into()), + bytes_uploaded: NumberOfBytes(0i64.into()), + bytes_left: NumberOfBytes(1000i64.into()), + event: AnnounceEvent::Started.into(), + ip_address: Ipv4Addr::UNSPECIFIED.into(), + key: PeerKey::new(0i32), + peers_wanted: NumberOfPeers::new(74i32), + port: Port::new(NonZeroU16::new(6881).expect("6881 is not zero")), + }, + client_socket_addr, + server_service_binding: ServiceBinding::new(Protocol::UDP, server_socket_addr).unwrap(), + cookie_valid_range: (sample_issue_time() - 60.0)..(sample_issue_time() + 60.0), + } + } + + /// # Panics + /// + /// Panics if the announce is rejected, which would mean the benchmark + /// measures an error path instead of an announce. + pub async fn announce_once(&self) -> AnnounceData { + self.announce_service + .handle_announce( + self.client_socket_addr, + self.server_service_binding.clone(), + &self.announce_request, + self.cookie_valid_range.clone(), + true, + ) + .await + .expect("the benchmark announce should be accepted") + } +} diff --git a/packages/udp-core/benches/helpers/mod.rs b/packages/udp-core/benches/helpers/mod.rs index bdb0040ab1..ae14bd92d5 100644 --- a/packages/udp-core/benches/helpers/mod.rs +++ b/packages/udp-core/benches/helpers/mod.rs @@ -1,3 +1,4 @@ +pub mod announce; pub mod connect; pub mod routine_guard; mod utils; diff --git a/packages/udp-core/benches/udp_tracker_core_benchmark.rs b/packages/udp-core/benches/udp_tracker_core_benchmark.rs index 61277b7695..88a526a7bd 100644 --- a/packages/udp-core/benches/udp_tracker_core_benchmark.rs +++ b/packages/udp-core/benches/udp_tracker_core_benchmark.rs @@ -4,6 +4,7 @@ use std::time::Duration; use criterion::{Criterion, criterion_group, criterion_main}; +use crate::helpers::announce::AnnounceBenchmarkContext; use crate::helpers::connect::ConnectBenchmarkContext; use crate::helpers::routine_guard::RoutineGuard; @@ -31,5 +32,29 @@ fn bench_connect_once(c: &mut Criterion) { guard.assert_routine_ran(&format!("{GROUP}/{BENCHMARK}")); } -criterion_group!(benches, bench_connect_once); +const ANNOUNCE_GROUP: &str = "udp_tracker/announce_once"; +const ANNOUNCE_BENCHMARK: &str = "announce_once"; + +fn bench_announce_once(c: &mut Criterion) { + let runtime = tokio::runtime::Runtime::new().expect("it should build a Tokio runtime"); + let context = AnnounceBenchmarkContext::new(); + let guard = RoutineGuard::default(); + + { + let mut group = c.benchmark_group(ANNOUNCE_GROUP); + group.warm_up_time(Duration::from_millis(500)); + group.measurement_time(Duration::from_secs(1)); + + group.bench_function(ANNOUNCE_BENCHMARK, |b| { + guard.record_benchmark_invocation(); + b.to_async(&runtime).iter(|| guard.track(context.announce_once())); + }); + + group.finish(); + } + + guard.assert_routine_ran(&format!("{ANNOUNCE_GROUP}/{ANNOUNCE_BENCHMARK}")); +} + +criterion_group!(benches, bench_connect_once, bench_announce_once); criterion_main!(benches); From d674c8eea2490111bb4cd82a02f6defb27775172 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:49:48 +0000 Subject: [PATCH 02/28] docs(issues): [#2850] record the performance baseline Three Criterion runs of the UDP and HTTP announce benchmarks and five 30-second UDP load-test runs, built from a clean worktree of the benchmark commit. A first attempt built from the working tree is discarded because uncommitted edits leaked into it. Co-Authored-By: Claude Opus 5.5 --- .../performance-evidence.md | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md new file mode 100644 index 0000000000..aed4dd6b82 --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md @@ -0,0 +1,107 @@ +--- +doc-type: performance-evidence +issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +last-updated-utc: "2026-11-15 20:50" +--- + +# Performance Evidence - Non-Negative Number of Bytes + +Performance Evidence plan of issue #2850 (see the specification, "Verification Plan"). The baseline +is measured on the code the branch starts from plus the benchmark-only commit of T0; the after +measurement is repeated after T3 on the same machine with the same build profile, configuration and +load-test settings. Only actual results are recorded here. + +## Method + +Two instruments, following [`docs/benchmarking.md`](../../../benchmarking.md) and the method of +[issue #2458](../../closed/2458-inject-udp-cookie-cipher/performance-evidence.md). + +### Microbenchmarks (Criterion) + +- `udp_tracker/announce_once/announce_once`, added by T0 in + `packages/udp-core/benches/udp_tracker_core_benchmark.rs`: one awaited + `AnnounceService::handle_announce` of a repeat announce on a public tracker with events disabled + and cookie validation on. It includes the wire-to-domain conversion that T2 makes fallible. +- `http_tracker/announce_once/announce_once` from + `packages/http-core/benches/http_tracker_core_benchmark.rs`, the existing HTTP announce + benchmark. +- Commands, run three times in a row (disposable script `.tmp/perf-2850/run-criterion.sh`): + + ```sh + cargo bench -q -p torrust-tracker-udp-core --bench udp_tracker_core_benchmark -- announce_once + cargo bench -q -p torrust-tracker-http-core --bench http_tracker_core_benchmark -- announce_once + ``` + +- Metric: the median point estimate from each benchmark's + `target/criterion///new/estimates.json`, read after each run with `LC_ALL=C`. + +### End-to-End Load Test (`aquatic_udp_load_test`) + +- Tracker: `cargo build --release --bin torrust-tracker`, started with the unmodified + `share/default/config/tracker.udp.benchmarking.toml`; a fresh tracker per run, each in its own + scratch folder, stopped with `SIGTERM`. +- Load generator: `aquatic_udp_load_test` built from source at aquatic commit `a2ddc4b3`. +- Configuration: the one of issue #2458 (`workers = 1`, `duration = 30`, `summarize_last = 20`, + four sockets, connect and announce weights 50/50, scrape weight 1, `announce_peers_wanted = 74`). +- Metric: `Average responses per second` from aquatic's report (the last 20 seconds of each run). + +### Isolation of the Measured Code + +Each measurement is built in its own detached `git worktree` of the measured commit under +`.tmp/perf-2850/`, with its own `target` directory, so edits in the working branch cannot leak into +the build. + +A first baseline attempt (20:37 to 20:41 UTC) was built from the working branch while the T1 and T2 +edits were already in the working tree: the release binary finished at 20:37:47 UTC and +`packages/udp-core/src/peer_builder.rs` had been edited at 20:36:59 UTC. It is discarded and not +used below. + +## Machine + +- CPU: AMD Ryzen 9 7950X 16-Core Processor (32 threads); RAM: 61 GiB +- OS: Linux 7.0.0-43-generic +- Toolchain: `rustc 1.99.1 (58cf8f9c3 2026-10-13)`, `release` profile +- A shared desktop with other agent sessions: the load average was 4.8 to 7.1 during the + baseline (recorded at the start of each run). No other tracker was running, and UDP `3000` and + TCP `127.0.0.1:1313` were free. + +## Baseline + +Commit `7b5dd310f` ("test(udp-core): [#2850] add a UDP announce benchmark"), on `develop` at +`abd7a10ff`. Measured on 2026-11-15. + +### Criterion Medians + +| Run | Start (UTC) | Load average (1 min) | UDP `announce_once` | HTTP `announce_once` | +| --- | --- | --- | --- | --- | +| 1 | 20:44:11 | 4.84 | 284.90 ns | 338.57 ns | +| 2 | 20:45:56 | 5.06 | 286.77 ns | 336.82 ns | +| 3 | 20:46:07 | 5.06 | 303.52 ns | 342.05 ns | + +Spread: UDP 284.90 to 303.52 ns (6.5%); HTTP 336.82 to 342.05 ns (1.6%). + +### Load Test + +| Run | Start (UTC) | Load average (1 min) | Average responses per second | Error responses | +| --- | --- | --- | --- | --- | +| 1 | 20:46:15 | 5.12 | 135,528.53 | 0.00 | +| 2 | 20:46:49 | 6.72 | 141,469.34 | 0.00 | +| 3 | 20:47:23 | 7.09 | 145,907.69 | 0.00 | +| 4 | 20:47:57 | 6.49 | 139,970.87 | 0.00 | +| 5 | 20:48:31 | 6.71 | 142,644.38 | 0.00 | + +Mean 141,104.16; lowest run 135,528.53; spread 7.7%. + +## Pass Rule + +From the specification: + +- the after mean of the load test is not below the lowest baseline run (135,528.53); +- the after HTTP `announce_once` median is not above the highest baseline median (342.05 ns); +- the after UDP `announce_once` median is not above the highest baseline median (303.52 ns) plus a + tolerance for the three sign checks T2 adds. The tolerance is agreed with the maintainer before + the after measurement and recorded here. + +## After + +Not measured yet. From a8efcc433680dd81fc8b8b02ceff163aaeef1560 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:50:45 +0000 Subject: [PATCH 03/28] test(http-protocol): [#2850] pin the accepted range of the byte-count params For each of `downloaded`, `uploaded` and `left`: a negative value and a non-numeric value are refused with `InvalidParam`, and zero is accepted. They pass before any production change. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 1 + packages/http-protocol/Cargo.toml | 3 + .../http-protocol/src/v1/requests/announce.rs | 76 +++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b8ab58f2ae..e68e50cee1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5236,6 +5236,7 @@ dependencies = [ "hex", "multimap", "percent-encoding", + "rstest", "serde", "serde_bencode", "serde_bytes", diff --git a/packages/http-protocol/Cargo.toml b/packages/http-protocol/Cargo.toml index f37e0f27a0..2266cdce05 100644 --- a/packages/http-protocol/Cargo.toml +++ b/packages/http-protocol/Cargo.toml @@ -34,3 +34,6 @@ torrust-located-error = "3.0.0" [package.metadata.cargo-machete] ignored = [ "serde_bytes" ] + +[dev-dependencies] +rstest = "0.28.0" diff --git a/packages/http-protocol/src/v1/requests/announce.rs b/packages/http-protocol/src/v1/requests/announce.rs index ac5f1e97e4..81d06426d0 100644 --- a/packages/http-protocol/src/v1/requests/announce.rs +++ b/packages/http-protocol/src/v1/requests/announce.rs @@ -970,5 +970,81 @@ mod tests { )); } } + + mod when_a_number_of_bytes_param_is_parsed { + + use rstest::rstest; + + use crate::v1::query::Query; + use crate::v1::requests::announce::{ + Announce, DOWNLOADED, INFO_HASH, LEFT, NumberOfBytes, PEER_ID, PORT, ParseAnnounceQueryError, UPLOADED, + }; + + /// Parses a valid announce query plus one byte-count param. + fn announce_with(param_name: &str, param_value: &str) -> Result { + let raw_query = Query::from(vec![ + (INFO_HASH, "%3B%24U%04%CF%5F%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0"), + (PEER_ID, "-RC3000-000000000001"), + (PORT, "17548"), + (param_name, param_value), + ]) + .to_string(); + + Announce::try_from(raw_query.parse::().unwrap()) + } + + fn number_of_bytes_in(announce: &Announce, param_name: &str) -> Option { + match param_name { + DOWNLOADED => announce.downloaded, + UPLOADED => announce.uploaded, + LEFT => announce.left, + other => panic!("`{other}` is not a byte-count param"), + } + } + + #[rstest] + #[case::downloaded(DOWNLOADED)] + #[case::uploaded(UPLOADED)] + #[case::left(LEFT)] + fn it_should_reject_a_negative_value(#[case] param_name: &str) { + let result = announce_with(param_name, "-1"); + + assert!(matches!( + result, + Err(ParseAnnounceQueryError::InvalidParam { + param_name: rejected_param, + param_value, + .. + }) if rejected_param == param_name && param_value == "-1" + )); + } + + #[rstest] + #[case::downloaded(DOWNLOADED)] + #[case::uploaded(UPLOADED)] + #[case::left(LEFT)] + fn it_should_accept_zero(#[case] param_name: &str) { + let announce = announce_with(param_name, "0").unwrap(); + + assert_eq!(number_of_bytes_in(&announce, param_name), Some(NumberOfBytes::new(0))); + } + + #[rstest] + #[case::downloaded(DOWNLOADED)] + #[case::uploaded(UPLOADED)] + #[case::left(LEFT)] + fn it_should_reject_a_non_numeric_value(#[case] param_name: &str) { + let result = announce_with(param_name, "ten"); + + assert!(matches!( + result, + Err(ParseAnnounceQueryError::InvalidParam { + param_name: rejected_param, + param_value, + .. + }) if rejected_param == param_name && param_value == "ten" + )); + } + } } } From 4d5db6a278ea6733f32c4a9b5b0d4fc36d76e81c Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:51:55 +0000 Subject: [PATCH 04/28] test(udp-server): [#2850] reject a negative left in an announce (red) The UDP announce handler accepts left = -5 and counts the peer as a seeder, while the HTTP tracker refuses the same value. The test is red until the fix. Taken from commit f4f5ddf96 of the closed PR #2839. Co-Authored-By: Claude Opus 5.5 --- packages/udp-server/src/handlers/announce.rs | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/udp-server/src/handlers/announce.rs b/packages/udp-server/src/handlers/announce.rs index f53aa189a3..f20aadbc03 100644 --- a/packages/udp-server/src/handlers/announce.rs +++ b/packages/udp-server/src/handlers/announce.rs @@ -267,6 +267,11 @@ pub(crate) mod tests { self } + pub fn with_bytes_left(mut self, bytes_left: i64) -> Self { + self.request.bytes_left = NumberOfBytes(bytes_left.into()); + self + } + pub fn into(self) -> AnnounceRequest { self.request } @@ -559,6 +564,42 @@ pub(crate) mod tests { assert_eq!(peers[0].peer_addr, SocketAddr::new(IpAddr::V4(remote_client_ip), client_port)); } + #[tokio::test] + async fn it_should_reject_an_announce_with_a_negative_number_of_bytes_left() { + // Arrange + let (core_tracker_services, core_udp_tracker_services, server_udp_tracker_services) = + initialize_core_tracker_services_for_public_tracker().await; + let client_socket_addr = sample_ipv4_socket_address(); + let server_socket_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 196)), 6969); + let server_service_binding = ServiceBinding::new(Protocol::UDP, server_socket_addr).unwrap(); + let info_hash = AquaticInfoHash([0u8; 20]); + let request = AnnounceRequestBuilder::default() + .with_connection_id(connection_id_issued_to(&client_socket_addr)) + .with_info_hash(info_hash) + .with_bytes_left(-5) + .into(); + + // Act + let actual = handle_announce( + &core_udp_tracker_services.announce_service, + client_socket_addr, + server_service_binding, + &request, + &core_tracker_services.core_config, + &server_udp_tracker_services.udp_server_stats_event_sender, + sample_strict_cookie_validation(), + ) + .await; + + // Assert: the announce is refused (the HTTP tracker refuses the same value) and no peer is stored. + assert!(actual.is_err(), "a negative `left` must be rejected, got: {actual:?}"); + let peers = core_tracker_services + .in_memory_torrent_repository + .get_torrent_peers(&info_hash.0.into(), usize::MAX) + .await; + assert!(peers.is_empty(), "a rejected announce must not register a peer"); + } + #[tokio::test] async fn it_should_preserve_an_announce_service_failure_for_packet_error_routing() { // Arrange From 594c21bc731c9547a9928ad90e58218cfd23a4f6 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:53:55 +0000 Subject: [PATCH 05/28] fix(udp-core)!: [#2850] refuse a negative byte count in the wire-to-domain conversion BEP 15 sends `left`, `uploaded` and `downloaded` as signed 64-bit integers, and a UDP announce with a negative `left` was counted as a seeder. The conversion `peer_builder::from_request` now returns `FromRequestError::NegativeNumberOfBytes` (the field and the value) for a negative count, and the announce service wraps it as `UdpAnnounceError::InvalidAnnounceRequest`. The peer is built after the connection cookie check and before the whitelist check. `udp-server` classifies the error as a bad request, and the handler test now pins the exact error and the transaction id. The domain type is unchanged. The field is named by the `ByteCountField` enum rather than one error variant per field: the three fields share one rule and one message, and the tests and the event classifier match on the field as a value. Fixes the bug of #2838. The tests are taken from the closed PR #2839. BREAKING CHANGE: `peer_builder::from_request` returns a `Result`, and `UdpAnnounceError` has the new variant `InvalidAnnounceRequest`. Co-Authored-By: Claude Opus 5.5 --- packages/udp-core/src/peer_builder.rs | 119 +++++++++++++++++-- packages/udp-core/src/services/announce.rs | 79 +++++++++++- packages/udp-server/src/event.rs | 26 ++++ packages/udp-server/src/handlers/announce.rs | 20 +++- 4 files changed, 225 insertions(+), 19 deletions(-) diff --git a/packages/udp-core/src/peer_builder.rs b/packages/udp-core/src/peer_builder.rs index 7e31d3e98b..a72f73aa0e 100644 --- a/packages/udp-core/src/peer_builder.rs +++ b/packages/udp-core/src/peer_builder.rs @@ -1,34 +1,89 @@ //! Logic to extract the peer info from the announce request. +use std::fmt; use std::net::{IpAddr, SocketAddr}; use torrust_clock::clock::Time; -use torrust_tracker_primitives::peer; +use torrust_tracker_primitives::{NumberOfBytes, peer}; use crate::CurrentClock; /// Extracts the [`peer::Peer`] info from the /// announce request. /// +/// This is the conversion from the BEP 15 wire request into the domain peer, +/// the first type the project owns. BEP 15 sends the byte counts as signed +/// 64-bit integers, so the wire type can hold a negative count; the domain +/// cannot, and the count is refused here. +/// /// # Arguments /// /// * `peer_ip` - The real IP address of the peer, not the one in the announce request. -#[must_use] -pub fn from_request(announce_request: &torrust_tracker_udp_protocol::AnnounceRequest, peer_ip: &IpAddr) -> peer::Peer { +/// +/// # Errors +/// +/// It returns [`FromRequestError::NegativeNumberOfBytes`] if `left`, +/// `uploaded` or `downloaded` is negative. +// adr: docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md +pub fn from_request( + announce_request: &torrust_tracker_udp_protocol::AnnounceRequest, + peer_ip: &IpAddr, +) -> Result { let wire_event = torrust_tracker_udp_protocol::AnnounceEvent::from(announce_request.event); - peer::Peer { + Ok(peer::Peer { peer_id: torrust_tracker_primitives::PeerId(announce_request.peer_id.0), peer_addr: SocketAddr::new(*peer_ip, announce_request.port.0.into()), updated: CurrentClock::now(), - uploaded: torrust_tracker_primitives::NumberOfBytes::new(announce_request.bytes_uploaded.0.get()), - downloaded: torrust_tracker_primitives::NumberOfBytes::new(announce_request.bytes_downloaded.0.get()), - left: torrust_tracker_primitives::NumberOfBytes::new(announce_request.bytes_left.0.get()), + uploaded: number_of_bytes(ByteCountField::Uploaded, announce_request.bytes_uploaded)?, + downloaded: number_of_bytes(ByteCountField::Downloaded, announce_request.bytes_downloaded)?, + left: number_of_bytes(ByteCountField::Left, announce_request.bytes_left)?, event: match wire_event { torrust_tracker_udp_protocol::AnnounceEvent::Completed => torrust_tracker_primitives::AnnounceEvent::Completed, torrust_tracker_udp_protocol::AnnounceEvent::Started => torrust_tracker_primitives::AnnounceEvent::Started, torrust_tracker_udp_protocol::AnnounceEvent::Stopped => torrust_tracker_primitives::AnnounceEvent::Stopped, torrust_tracker_udp_protocol::AnnounceEvent::None => torrust_tracker_primitives::AnnounceEvent::None, }, + }) +} + +/// Converts one wire byte count into the domain type. +fn number_of_bytes( + field: ByteCountField, + wire_number_of_bytes: torrust_tracker_udp_protocol::NumberOfBytes, +) -> Result { + let value = wire_number_of_bytes.0.get(); + + match u64::try_from(value) { + Ok(_) => Ok(NumberOfBytes::new(value)), + Err(_) => Err(FromRequestError::NegativeNumberOfBytes { field, value }), + } +} + +/// Errors of the conversion from a wire announce request into a domain peer. +#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub enum FromRequestError { + /// A byte count is negative. BEP 15 sends it as a signed integer, but a + /// number of bytes cannot be negative. + #[error("`{field}` must not be negative, got {value}")] + NegativeNumberOfBytes { field: ByteCountField, value: i64 }, +} + +/// The byte-count fields of an announce request. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ByteCountField { + Left, + Uploaded, + Downloaded, +} + +impl fmt::Display for ByteCountField { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self { + Self::Left => "left", + Self::Uploaded => "uploaded", + Self::Downloaded => "downloaded", + }) } } @@ -46,7 +101,7 @@ mod tests { PeerKey, Port, TransactionId, }; - use super::from_request; + use super::{ByteCountField, FromRequestError, from_request}; use crate::CurrentClock; fn announce_request() -> AnnounceRequest { @@ -78,7 +133,7 @@ mod tests { request.peer_id = PeerId(*b"-qB4650-abcdefghijkl"); // Act - let peer = from_request(&request, &peer_ip()); + let peer = from_request(&request, &peer_ip()).unwrap(); // Assert assert_eq!(peer.peer_id, PeerId(*b"-qB4650-abcdefghijkl")); @@ -92,7 +147,7 @@ mod tests { request.port = Port::new(NonZeroU16::new(51_413).unwrap()); // Act - let peer = from_request(&request, &peer_ip()); + let peer = from_request(&request, &peer_ip()).unwrap(); // Assert assert_eq!(peer.peer_addr, SocketAddr::new(peer_ip(), 51_413)); @@ -107,7 +162,7 @@ mod tests { request.bytes_left = torrust_tracker_udp_protocol::NumberOfBytes(300i64.into()); // Act - let peer = from_request(&request, &peer_ip()); + let peer = from_request(&request, &peer_ip()).unwrap(); // Assert assert_eq!( @@ -130,7 +185,7 @@ mod tests { request.event = wire_event.into(); // Act - let peer = from_request(&request, &peer_ip()); + let peer = from_request(&request, &peer_ip()).unwrap(); // Assert assert_eq!(peer.event, expected_event); @@ -143,9 +198,47 @@ mod tests { CurrentClock::local_set(&announce_time); // Act - let peer = from_request(&announce_request(), &peer_ip()); + let peer = from_request(&announce_request(), &peer_ip()).unwrap(); // Assert assert_eq!(peer.updated, announce_time); } + + #[rstest] + #[case::left(ByteCountField::Left, -1)] + #[case::left_min(ByteCountField::Left, i64::MIN)] + #[case::uploaded(ByteCountField::Uploaded, -1)] + #[case::downloaded(ByteCountField::Downloaded, -1)] + fn it_should_reject_a_negative_number_of_bytes(#[case] field: ByteCountField, #[case] value: i64) { + // Arrange + let mut request = announce_request(); + let bytes = torrust_tracker_udp_protocol::NumberOfBytes(value.into()); + match field { + ByteCountField::Left => request.bytes_left = bytes, + ByteCountField::Uploaded => request.bytes_uploaded = bytes, + ByteCountField::Downloaded => request.bytes_downloaded = bytes, + } + + // Act + let result = from_request(&request, &peer_ip()); + + // Assert + assert_eq!(result, Err(FromRequestError::NegativeNumberOfBytes { field, value })); + } + + #[rstest] + #[case::zero(0)] + #[case::unknown_size_of_libtorrent(16 * 1024)] + #[case::unknown_size_of_transmission(i64::MAX)] + fn it_should_accept_a_non_negative_number_of_bytes_left(#[case] left: i64) { + // Arrange + let mut request = announce_request(); + request.bytes_left = torrust_tracker_udp_protocol::NumberOfBytes(left.into()); + + // Act + let peer = from_request(&request, &peer_ip()).unwrap(); + + // Assert + assert_eq!(peer.left, NumberOfBytes::new(left)); + } } diff --git a/packages/udp-core/src/services/announce.rs b/packages/udp-core/src/services/announce.rs index ca2c965661..d94379f05c 100644 --- a/packages/udp-core/src/services/announce.rs +++ b/packages/udp-core/src/services/announce.rs @@ -23,7 +23,7 @@ use torrust_tracker_udp_protocol::AnnounceRequest; use crate::connection_cookie::{ConnectionCookieError, check, gen_remote_fingerprint}; use crate::crypto::cookie_cipher::CookieCipher; use crate::event::{ConnectionContext, Event}; -use crate::peer_builder; +use crate::peer_builder::{self, FromRequestError}; /// The `AnnounceService` is responsible for handling the `announce` requests. /// @@ -86,6 +86,7 @@ impl AnnounceService { /// It will return an error if: /// /// - Cookie validation fails and `validate_cookie` is `true`. + /// - `left`, `uploaded` or `downloaded` is negative. /// - The tracker is running in listed mode and the torrent is not in the /// whitelist. /// @@ -104,13 +105,13 @@ impl AnnounceService { self.authenticate(client_socket_addr, request, cookie_valid_range)?; } - let info_hash = InfoHash::from(request.info_hash.0); + let remote_client_ip = client_socket_addr.ip(); - self.authorize(&info_hash).await?; + let mut peer = peer_builder::from_request(request, &remote_client_ip)?; - let remote_client_ip = client_socket_addr.ip(); + let info_hash = InfoHash::from(request.info_hash.0); - let mut peer = peer_builder::from_request(request, &remote_client_ip); + self.authorize(&info_hash).await?; let peers_wanted = PeersWanted::from_client_request(i32::from(request.peers_wanted.0)); @@ -189,6 +190,11 @@ pub enum UdpAnnounceError { #[error("Connection cookie error: {source}")] ConnectionCookieError { source: ConnectionCookieError }, + /// Error returned when the request cannot be converted into a domain + /// peer, for example because a byte count is negative. + #[error("Invalid announce request: {source}")] + InvalidAnnounceRequest { source: FromRequestError }, + /// Error returned when there was an error with the tracker core announce handler. #[error("Tracker core announce error: {source}")] TrackerCoreAnnounceError { source: AnnounceError }, @@ -206,6 +212,14 @@ impl From for UdpAnnounceError { } } +impl From for UdpAnnounceError { + fn from(from_request_error: FromRequestError) -> Self { + Self::InvalidAnnounceRequest { + source: from_request_error, + } + } +} + impl From for UdpAnnounceError { fn from(announce_error: AnnounceError) -> Self { Self::TrackerCoreAnnounceError { source: announce_error } @@ -250,6 +264,7 @@ mod tests { use crate::connection_cookie::{ConnectionCookieError, gen_remote_fingerprint, make}; use crate::crypto::cookie_cipher::CookieCipher; use crate::event::{ConnectionContext, Event}; + use crate::peer_builder::{ByteCountField, FromRequestError}; use crate::services::tests::MockUdpCoreStatsEventSender; const INSTANCE_ID: ConfigurationInstanceId = ConfigurationInstanceId::new(ServiceRole::UdpTracker, 0); @@ -527,6 +542,60 @@ mod tests { assert!(matches!(result, Err(UdpAnnounceError::ConnectionCookieError { .. }))); } + #[tokio::test] + async fn it_should_validate_the_connection_id_before_the_number_of_bytes() { + // Arrange + let fixture = AnnounceServiceFixture::public_tracker(); + let mut request = announce_request(expired_connection_id_for(client_socket_addr())); + request.bytes_left = torrust_tracker_udp_protocol::NumberOfBytes((-1i64).into()); + + // Act + let result = fixture + .service + .handle_announce( + client_socket_addr(), + server_service_binding(), + &request, + cookie_valid_range(), + VALIDATE_COOKIE, + ) + .await; + + // Assert + assert!(matches!(result, Err(UdpAnnounceError::ConnectionCookieError { .. }))); + } + + #[tokio::test] + async fn it_should_reject_a_negative_number_of_bytes_before_revealing_whether_the_torrent_is_whitelisted() { + // Arrange + let fixture = AnnounceServiceFixture::listed_tracker_without_whitelisted_torrents(); + let mut request = announce_request(valid_connection_id_for(client_socket_addr())); + request.bytes_left = torrust_tracker_udp_protocol::NumberOfBytes((-1i64).into()); + + // Act + let result = fixture + .service + .handle_announce( + client_socket_addr(), + server_service_binding(), + &request, + cookie_valid_range(), + VALIDATE_COOKIE, + ) + .await; + + // Assert + assert!(matches!( + result, + Err(UdpAnnounceError::InvalidAnnounceRequest { + source: FromRequestError::NegativeNumberOfBytes { + field: ByteCountField::Left, + value: -1 + } + }) + )); + } + #[tokio::test] async fn it_should_announce_the_peer_with_the_client_socket_ip_instead_of_the_ip_in_the_request() { // Arrange diff --git a/packages/udp-server/src/event.rs b/packages/udp-server/src/event.rs index 3e381f7ff2..dbce5939e6 100644 --- a/packages/udp-server/src/event.rs +++ b/packages/udp-server/src/event.rs @@ -133,6 +133,9 @@ impl From for ErrorKind { unknown => Self::InternalServer(unknown.to_string()), }, UdpAnnounceError::TrackerCoreWhitelistError { source } => Self::Whitelist(source.to_string()), + invalid_request @ UdpAnnounceError::InvalidAnnounceRequest { .. } => { + Self::BadRequest(invalid_request.to_string()) + } unknown => Self::InternalServer(unknown.to_string()), }, Error::ScrapeFailed { source } => match source { @@ -186,6 +189,7 @@ mod tests { use torrust_tracker_core::error::{AnnounceError, ScrapeError, WhitelistError}; use torrust_tracker_primitives::Driver; use torrust_tracker_udp_core::connection_cookie::ConnectionCookieError; + use torrust_tracker_udp_core::peer_builder::{ByteCountField, FromRequestError}; use torrust_tracker_udp_core::services::announce::UdpAnnounceError; use torrust_tracker_udp_core::services::scrape::UdpScrapeError; use torrust_tracker_udp_protocol::{ @@ -408,6 +412,28 @@ mod tests { ); } + #[test] + fn it_should_classify_a_negative_number_of_bytes_in_an_announce_as_a_bad_request() { + // Arrange + let error = Error::AnnounceFailed { + source: UdpAnnounceError::InvalidAnnounceRequest { + source: FromRequestError::NegativeNumberOfBytes { + field: ByteCountField::Left, + value: -5, + }, + }, + }; + + // Act + let actual = ErrorKind::from(error); + + // Assert + assert_eq!( + actual, + ErrorKind::BadRequest("Invalid announce request: `left` must not be negative, got -5".to_string()) + ); + } + #[test] fn it_should_classify_an_internal_error() { // Arrange diff --git a/packages/udp-server/src/handlers/announce.rs b/packages/udp-server/src/handlers/announce.rs index f20aadbc03..2d0fbb3346 100644 --- a/packages/udp-server/src/handlers/announce.rs +++ b/packages/udp-server/src/handlers/announce.rs @@ -410,6 +410,7 @@ pub(crate) mod tests { use torrust_tracker_primitives::peer::fixture::PeerBuilder; use torrust_tracker_primitives::{ConfigurationInstanceId, ServiceRole}; use torrust_tracker_udp_core::event::ConnectionContext; + use torrust_tracker_udp_core::peer_builder::{ByteCountField, FromRequestError}; use torrust_tracker_udp_core::services::announce::UdpAnnounceError; use torrust_tracker_udp_protocol::{ AnnounceInterval, AnnounceResponse, AnnounceResponseFixedData, ConnectionId, InfoHash as AquaticInfoHash, @@ -592,7 +593,24 @@ pub(crate) mod tests { .await; // Assert: the announce is refused (the HTTP tracker refuses the same value) and no peer is stored. - assert!(actual.is_err(), "a negative `left` must be rejected, got: {actual:?}"); + assert!(matches!( + actual, + Err(boxed_error) if matches!( + *boxed_error, + ( + Error::AnnounceFailed { + source: UdpAnnounceError::InvalidAnnounceRequest { + source: FromRequestError::NegativeNumberOfBytes { + field: ByteCountField::Left, + value: -5, + }, + }, + }, + transaction_id, + UdpRequestKind::Announce { announce_request }, + ) if transaction_id == request.transaction_id && announce_request == request + ) + )); let peers = core_tracker_services .in_memory_torrent_repository .get_torrent_peers(&info_hash.0.into(), usize::MAX) From f499f9d4cab128bdb87edb3511f738a2fc896221 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:57:44 +0000 Subject: [PATCH 06/28] refactor(primitives)!: [#2850] hold the number of bytes in a u64 The domain `NumberOfBytes` and the HTTP protocol `NumberOfBytes` hold a private `u64` with `new(u64)` and `get()`, so a negative count cannot be represented. The UDP wire type stays `I64`, as BEP 15 defines it. - `Peer::is_seeder` compares `left` with zero in its three copies, and the bytes are serialized as a `u64`. - The UDP conversion maps the checked `u64` into the domain type. - The HTTP parser stores the `u64` it parses: the `i64::MAX` limit and `ParseAnnounceQueryError::NumberOfBytesOverflow` are removed, and the builder methods no longer convert or panic. - The HTTP-to-domain conversion in `http-core` is infallible. - The REST API peer resource fields `uploaded`, `downloaded` and `left` are `u64`. - The characterization test that pinned a negative `left` as a seeder is removed, with the `-1` rows of the role table. BREAKING CHANGE: `NumberOfBytes` in `primitives` and `http-protocol` has no public field and takes a `u64`; `NumberOfBytesOverflow` is removed; the REST peer resource byte fields are `u64`. Co-Authored-By: Claude Opus 5.5 --- packages/http-core/benches/helpers/util.rs | 6 +- packages/http-core/src/services/announce.rs | 6 +- .../http-protocol/src/v1/requests/announce.rs | 62 +++++++------------ packages/primitives/src/number_of_bytes.rs | 24 ++++++- packages/primitives/src/peer.rs | 26 +++----- .../src/v1/context/torrent/resources/peer.rs | 6 +- .../src/v1/conversion.rs | 6 +- packages/udp-core/src/peer_builder.rs | 17 +++-- tests/common/http_requests.rs | 2 +- 9 files changed, 71 insertions(+), 84 deletions(-) diff --git a/packages/http-core/benches/helpers/util.rs b/packages/http-core/benches/helpers/util.rs index 0205e16c86..1348a9216f 100644 --- a/packages/http-core/benches/helpers/util.rs +++ b/packages/http-core/benches/helpers/util.rs @@ -172,9 +172,9 @@ pub fn sample_announce_request_for_peer(peer: Peer) -> (Announce, ClientIpSource peer_id: peer.peer_id, port: peer.peer_addr.port(), ip: PeerIp::Absent, - uploaded: Some(ProtocolNumberOfBytes::new(peer.uploaded.0)), - downloaded: Some(ProtocolNumberOfBytes::new(peer.downloaded.0)), - left: Some(ProtocolNumberOfBytes::new(peer.left.0)), + uploaded: Some(ProtocolNumberOfBytes::new(peer.uploaded.get())), + downloaded: Some(ProtocolNumberOfBytes::new(peer.downloaded.get())), + left: Some(ProtocolNumberOfBytes::new(peer.left.get())), event: Some(match peer.event { AnnounceEvent::Started => ProtocolAnnounceEvent::Started, AnnounceEvent::Stopped => ProtocolAnnounceEvent::Stopped, diff --git a/packages/http-core/src/services/announce.rs b/packages/http-core/src/services/announce.rs index 790ca50021..4e6b7b3538 100644 --- a/packages/http-core/src/services/announce.rs +++ b/packages/http-core/src/services/announce.rs @@ -249,9 +249,9 @@ impl AnnounceService { peer_id: announce_request.peer_id, peer_addr: std::net::SocketAddr::new(*peer_ip, announce_request.port), updated: ::now(), - uploaded: NumberOfBytes::new(uploaded.0), - downloaded: NumberOfBytes::new(downloaded.0), - left: NumberOfBytes::new(left.0), + uploaded: NumberOfBytes::new(uploaded.get()), + downloaded: NumberOfBytes::new(downloaded.get()), + left: NumberOfBytes::new(left.get()), event: announce_request .event .as_ref() diff --git a/packages/http-protocol/src/v1/requests/announce.rs b/packages/http-protocol/src/v1/requests/announce.rs index 81d06426d0..aa8dd055d1 100644 --- a/packages/http-protocol/src/v1/requests/announce.rs +++ b/packages/http-protocol/src/v1/requests/announce.rs @@ -36,14 +36,23 @@ const IP: &str = "ip"; // HTTP wire semantics can evolve independently without forcing cross-protocol // or domain-wide refactors. // adr: docs/adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md +// +// BEP 3 gives the byte counts no width and no sign, so a `u64` holds every +// value the parser accepts and a negative count cannot be represented. +// adr: docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] -pub struct NumberOfBytes(pub i64); +pub struct NumberOfBytes(u64); impl NumberOfBytes { #[must_use] - pub const fn new(v: i64) -> Self { + pub const fn new(v: u64) -> Self { Self(v) } + + #[must_use] + pub const fn get(&self) -> u64 { + self.0 + } } /// Raw state of the optional BEP 3 `ip` parameter. @@ -193,13 +202,6 @@ pub enum ParseAnnounceQueryError { param_value: String, location: &'static Location<'static>, }, - /// The param value is out of range. - #[error("param value overflow {param_value} for {param_name} in {location}")] - NumberOfBytesOverflow { - param_name: String, - param_value: String, - location: &'static Location<'static>, - }, /// The `info_hash` is invalid. #[error("invalid param value {param_value} for {param_name} in {source}")] InvalidInfoHashParam { @@ -364,13 +366,13 @@ impl fmt::Display for Announce { PeerIp::Literal(ip) => params.push((IP, ip.to_string())), } if let Some(downloaded) = self.downloaded { - params.push(("downloaded", downloaded.0.to_string())); + params.push(("downloaded", downloaded.get().to_string())); } if let Some(uploaded) = self.uploaded { - params.push(("uploaded", uploaded.0.to_string())); + params.push(("uploaded", uploaded.get().to_string())); } if let Some(left) = self.left { - params.push(("left", left.0.to_string())); + params.push(("left", left.get().to_string())); } if let Some(event) = &self.event { params.push(("event", event.to_string())); @@ -475,34 +477,21 @@ impl AnnounceBuilder { self } - /// # Panics - /// - /// Panics if `downloaded` exceeds `i64::MAX`. #[must_use] - pub fn with_downloaded(mut self, downloaded: u64) -> Self { - self.announce.downloaded = Some(NumberOfBytes::new( - i64::try_from(downloaded).expect("downloaded value fits in i64"), - )); + pub const fn with_downloaded(mut self, downloaded: u64) -> Self { + self.announce.downloaded = Some(NumberOfBytes::new(downloaded)); self } - /// # Panics - /// - /// Panics if `uploaded` exceeds `i64::MAX`. #[must_use] - pub fn with_uploaded(mut self, uploaded: u64) -> Self { - self.announce.uploaded = Some(NumberOfBytes::new( - i64::try_from(uploaded).expect("uploaded value fits in i64"), - )); + pub const fn with_uploaded(mut self, uploaded: u64) -> Self { + self.announce.uploaded = Some(NumberOfBytes::new(uploaded)); self } - /// # Panics - /// - /// Panics if `left` exceeds `i64::MAX`. #[must_use] - pub fn with_left(mut self, left: u64) -> Self { - self.announce.left = Some(NumberOfBytes::new(i64::try_from(left).expect("left value fits in i64"))); + pub const fn with_left(mut self, left: u64) -> Self { + self.announce.left = Some(NumberOfBytes::new(left)); self } @@ -604,16 +593,7 @@ fn extract_number_of_bytes_from_param(param_name: &str, query: &Query) -> Result location: Location::caller(), })?; - let number_of_bytes = - i64::try_from(number_of_bytes).map_err(|_e| ParseAnnounceQueryError::NumberOfBytesOverflow { - param_name: param_name.to_owned(), - param_value: raw_param.clone(), - location: Location::caller(), - })?; - - let number_of_bytes = NumberOfBytes::new(number_of_bytes); - - Ok(Some(number_of_bytes)) + Ok(Some(NumberOfBytes::new(number_of_bytes))) } None => Ok(None), } diff --git a/packages/primitives/src/number_of_bytes.rs b/packages/primitives/src/number_of_bytes.rs index d3069b172a..4521a21c95 100644 --- a/packages/primitives/src/number_of_bytes.rs +++ b/packages/primitives/src/number_of_bytes.rs @@ -1,9 +1,29 @@ +/// A number of bytes: what a peer has uploaded, downloaded, or has left to +/// download. +/// +/// A number of bytes cannot be negative, so the type holds a `u64` and cannot +/// represent a negative count. Each delivery protocol refuses a negative value +/// when it converts its own wire type into this one. +/// +/// ```rust +/// use torrust_tracker_primitives::NumberOfBytes; +/// +/// let left = NumberOfBytes::new(16_384); +/// +/// assert_eq!(left.get(), 16_384); +/// ``` +// adr: docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] -pub struct NumberOfBytes(pub i64); +pub struct NumberOfBytes(u64); impl NumberOfBytes { #[must_use] - pub const fn new(v: i64) -> Self { + pub const fn new(v: u64) -> Self { Self(v) } + + #[must_use] + pub const fn get(&self) -> u64 { + self.0 + } } diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index 9854a18fa4..d54d784812 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -184,13 +184,13 @@ pub fn ser_announce_event(announce_event: &AnnounceEvent, ser.serialize_some(&event_ser) } -/// Serializes a `Announce Event` as a i64. +/// Serializes a `NumberOfBytes` as a u64. /// /// # Errors /// /// If will return an error if the internal serializer was to fail. pub fn ser_number_of_bytes(number_of_bytes: &NumberOfBytes, ser: S) -> Result { - ser.serialize_i64(number_of_bytes.0) + ser.serialize_u64(number_of_bytes.get()) } /// Serializes a `PeerId` as a `peer::Id`. @@ -214,7 +214,7 @@ pub trait ReadInfo { impl ReadInfo for Peer { fn is_seeder(&self) -> bool { - self.left.0 <= 0 && self.event != AnnounceEvent::Stopped + self.left.get() == 0 && self.event != AnnounceEvent::Stopped } fn is_leecher(&self) -> bool { @@ -240,7 +240,7 @@ impl ReadInfo for Peer { impl ReadInfo for Arc { fn is_seeder(&self) -> bool { - self.left.0 <= 0 && self.event != AnnounceEvent::Stopped + self.left.get() == 0 && self.event != AnnounceEvent::Stopped } fn is_leecher(&self) -> bool { @@ -267,7 +267,7 @@ impl ReadInfo for Arc { impl Peer { #[must_use] pub fn is_seeder(&self) -> bool { - self.left.0 <= 0 && self.event != AnnounceEvent::Stopped + self.left.get() == 0 && self.event != AnnounceEvent::Stopped } #[must_use] @@ -569,7 +569,7 @@ pub mod fixture { } #[must_use] - pub const fn with_bytes_left_to_download(mut self, left: i64) -> Self { + pub const fn with_bytes_left_to_download(mut self, left: u64) -> Self { self.peer.left = NumberOfBytes::new(left); self } @@ -698,7 +698,7 @@ pub mod test { use crate::peer::{Peer, PeerRole}; use crate::{AnnounceEvent, NumberOfBytes, PeerId}; - fn a_peer_with(left: i64, event: AnnounceEvent) -> Peer { + fn a_peer_with(left: u64, event: AnnounceEvent) -> Peer { Peer { peer_id: PeerId(*b"-qB4650-abcdefghijkl"), peer_addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(126, 0, 0, 1)), 8080), @@ -744,16 +744,6 @@ pub mod test { assert_eq!(peer.role(), PeerRole::Seeder); } - // A negative number of bytes left is not meaningful: issue #2850 makes it unrepresentable. - // This test pins how the signed domain value is classified until then; that change removes it. - #[test] - fn it_should_treat_a_negative_number_of_bytes_left_as_a_seeder() { - let peer = a_peer_with(-1, AnnounceEvent::Started); - - assert!(peer.is_seeder()); - assert_eq!(peer.role(), PeerRole::Seeder); - } - #[test] fn it_should_be_completed_only_when_its_last_event_is_completed() { assert!(a_peer_with(0, AnnounceEvent::Completed).is_completed()); @@ -832,9 +822,7 @@ pub mod test { let cases = [ (1, AnnounceEvent::Started, false), (0, AnnounceEvent::Started, true), - (-1, AnnounceEvent::Started, true), (0, AnnounceEvent::Stopped, false), - (-1, AnnounceEvent::Stopped, false), ]; for (left, event, is_seeder) in cases { diff --git a/packages/rest-api-protocol/src/v1/context/torrent/resources/peer.rs b/packages/rest-api-protocol/src/v1/context/torrent/resources/peer.rs index 2befdc4e8a..5ea6c33135 100644 --- a/packages/rest-api-protocol/src/v1/context/torrent/resources/peer.rs +++ b/packages/rest-api-protocol/src/v1/context/torrent/resources/peer.rs @@ -30,11 +30,11 @@ pub struct Peer { /// be removed in API v2. pub updated_at_ms: u128, /// The peer's uploaded bytes. - pub uploaded: i64, + pub uploaded: u64, /// The peer's downloaded bytes. - pub downloaded: i64, + pub downloaded: u64, /// The peer's left bytes (pending to download). - pub left: i64, + pub left: u64, /// The peer's event: `Started`, `Stopped`, `Completed`, `None` (`PascalCase`). pub event: String, } diff --git a/packages/rest-api-runtime-adapter/src/v1/conversion.rs b/packages/rest-api-runtime-adapter/src/v1/conversion.rs index 54b109aea9..1ddf0a3485 100644 --- a/packages/rest-api-runtime-adapter/src/v1/conversion.rs +++ b/packages/rest-api-runtime-adapter/src/v1/conversion.rs @@ -20,9 +20,9 @@ pub fn from_domain_peer(value: domain_peer::Peer) -> protocol_peer::Peer { updated: updated_at_ms, updated_milliseconds_ago: updated_at_ms, updated_at_ms, - uploaded: value.uploaded.0, - downloaded: value.downloaded.0, - left: value.left.0, + uploaded: value.uploaded.get(), + downloaded: value.downloaded.get(), + left: value.left.get(), event: format!("{:?}", value.event), } } diff --git a/packages/udp-core/src/peer_builder.rs b/packages/udp-core/src/peer_builder.rs index a72f73aa0e..431256e764 100644 --- a/packages/udp-core/src/peer_builder.rs +++ b/packages/udp-core/src/peer_builder.rs @@ -53,10 +53,9 @@ fn number_of_bytes( ) -> Result { let value = wire_number_of_bytes.0.get(); - match u64::try_from(value) { - Ok(_) => Ok(NumberOfBytes::new(value)), - Err(_) => Err(FromRequestError::NegativeNumberOfBytes { field, value }), - } + u64::try_from(value) + .map(NumberOfBytes::new) + .map_err(|_| FromRequestError::NegativeNumberOfBytes { field, value }) } /// Errors of the conversion from a wire announce request into a domain peer. @@ -227,10 +226,10 @@ mod tests { } #[rstest] - #[case::zero(0)] - #[case::unknown_size_of_libtorrent(16 * 1024)] - #[case::unknown_size_of_transmission(i64::MAX)] - fn it_should_accept_a_non_negative_number_of_bytes_left(#[case] left: i64) { + #[case::zero(0, 0)] + #[case::unknown_size_of_libtorrent(16 * 1024, 16 * 1024)] + #[case::unknown_size_of_transmission(i64::MAX, 9_223_372_036_854_775_807)] + fn it_should_accept_a_non_negative_number_of_bytes_left(#[case] left: i64, #[case] expected_left: u64) { // Arrange let mut request = announce_request(); request.bytes_left = torrust_tracker_udp_protocol::NumberOfBytes(left.into()); @@ -239,6 +238,6 @@ mod tests { let peer = from_request(&request, &peer_ip()).unwrap(); // Assert - assert_eq!(peer.left, NumberOfBytes::new(left)); + assert_eq!(peer.left, NumberOfBytes::new(expected_left)); } } diff --git a/tests/common/http_requests.rs b/tests/common/http_requests.rs index 049b50c8ea..e1c2242eba 100644 --- a/tests/common/http_requests.rs +++ b/tests/common/http_requests.rs @@ -42,7 +42,7 @@ async fn announce_event( peer_id: &[u8; 20], port: u16, event: Event, - bytes_left: Option, + bytes_left: Option, ) { let client = Client::new(tracker_url.clone(), Duration::from_secs(5)).expect("failed to create HTTP client"); From cab37c8ec59f62a8b22873b0576e5e4ce4c5f9fb Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:59:01 +0000 Subject: [PATCH 07/28] test: [#2850] cover the new byte-count range and the seeder rule - http-protocol: `u64::MAX` is accepted and a value above it is refused with `InvalidParam`, for each of `downloaded`, `uploaded` and `left`. - axum-http-server: an announce with `left` one above `i64::MAX`, refused before, is accepted and the peer is a leecher. - primitives: the role table covers a stopped peer with bytes left. Co-Authored-By: Claude Opus 5.5 --- .../receiving_an_announce_request.rs | 40 +++++++++++++++++++ .../http-protocol/src/v1/requests/announce.rs | 27 +++++++++++++ packages/primitives/src/peer.rs | 1 + 3 files changed, 68 insertions(+) diff --git a/packages/axum-http-server/tests/server/v1/contract/for_all_config_modes/receiving_an_announce_request.rs b/packages/axum-http-server/tests/server/v1/contract/for_all_config_modes/receiving_an_announce_request.rs index 7132b4964a..a1caa9058e 100644 --- a/packages/axum-http-server/tests/server/v1/contract/for_all_config_modes/receiving_an_announce_request.rs +++ b/packages/axum-http-server/tests/server/v1/contract/for_all_config_modes/receiving_an_announce_request.rs @@ -609,6 +609,46 @@ async fn should_return_no_peers_if_the_announced_peer_is_the_first_one() { env.stop().await; } +#[tokio::test] +async fn should_accept_a_number_of_bytes_left_above_the_largest_signed_64_bit_value() { + logging::setup(); + + let cfg = configuration::ephemeral_public(); + let core_config = Arc::new(cfg.core.clone()); + let http_tracker_config = Arc::new(cfg.http_trackers.unwrap()[0].clone()); + let env = Started::new(&core_config, &http_tracker_config).await; + + // One above `i64::MAX`: refused with an overflow error before issue #2850. + let left = 9_223_372_036_854_775_808; + + let response = Client::new(env.base_url(), Duration::from_secs(5)) + .unwrap() + .announce( + &AnnounceBuilder::default() + .with_info_hash(&InfoHash::from_str("9c38422213e30bff212b30c360d26f9a02136422").unwrap()) // DevSkim: ignore DS173237 + .with_left(left) + .query(), + ) + .await + .unwrap(); + + let announce_policy = env.container.tracker_core_container.core_config.announce_policy; + + assert_announce_response( + response, + &DeserializedNormal { + complete: 0, + incomplete: 1, // the peer for this test, a leecher + interval: announce_policy.interval.get(), + min_interval: announce_policy.interval_min.get(), + peers: vec![], + }, + ) + .await; + + env.stop().await; +} + #[tokio::test] async fn should_return_the_list_of_previously_announced_peers() { logging::setup(); diff --git a/packages/http-protocol/src/v1/requests/announce.rs b/packages/http-protocol/src/v1/requests/announce.rs index aa8dd055d1..bf779cbca3 100644 --- a/packages/http-protocol/src/v1/requests/announce.rs +++ b/packages/http-protocol/src/v1/requests/announce.rs @@ -1009,6 +1009,33 @@ mod tests { assert_eq!(number_of_bytes_in(&announce, param_name), Some(NumberOfBytes::new(0))); } + #[rstest] + #[case::downloaded(DOWNLOADED)] + #[case::uploaded(UPLOADED)] + #[case::left(LEFT)] + fn it_should_accept_the_largest_unsigned_64_bit_value(#[case] param_name: &str) { + let announce = announce_with(param_name, "18446744073709551615").unwrap(); + + assert_eq!(number_of_bytes_in(&announce, param_name), Some(NumberOfBytes::new(u64::MAX))); + } + + #[rstest] + #[case::downloaded(DOWNLOADED)] + #[case::uploaded(UPLOADED)] + #[case::left(LEFT)] + fn it_should_reject_a_value_above_the_largest_unsigned_64_bit_value(#[case] param_name: &str) { + let result = announce_with(param_name, "18446744073709551616"); + + assert!(matches!( + result, + Err(ParseAnnounceQueryError::InvalidParam { + param_name: rejected_param, + param_value, + .. + }) if rejected_param == param_name && param_value == "18446744073709551616" + )); + } + #[rstest] #[case::downloaded(DOWNLOADED)] #[case::uploaded(UPLOADED)] diff --git a/packages/primitives/src/peer.rs b/packages/primitives/src/peer.rs index d54d784812..7e62748682 100644 --- a/packages/primitives/src/peer.rs +++ b/packages/primitives/src/peer.rs @@ -823,6 +823,7 @@ pub mod test { (1, AnnounceEvent::Started, false), (0, AnnounceEvent::Started, true), (0, AnnounceEvent::Stopped, false), + (1, AnnounceEvent::Stopped, false), ]; for (left, event, is_seeder) in cases { From 7824001ba8faa8884ec8668398254c13d72c31b8 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 20:59:47 +0000 Subject: [PATCH 08/28] docs(axum-http-server): [#2850] describe the byte-count params as non-negative `downloaded`, `uploaded` and `left` accept zero, so they are non-negative integers, not positive ones. Co-Authored-By: Claude Opus 5.5 --- packages/axum-http-server/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/axum-http-server/src/lib.rs b/packages/axum-http-server/src/lib.rs index c81973b6cd..5f04478a9c 100644 --- a/packages/axum-http-server/src/lib.rs +++ b/packages/axum-http-server/src/lib.rs @@ -45,11 +45,11 @@ //! ---|---|---|---|---|--- //! [`info_hash`](torrust_tracker_http_protocol::v1::requests::announce::Announce::info_hash) | percent encoded of 20-byte array | The `Info Hash` of the torrent. | Yes | No | `%81%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00` //! [`ip`](torrust_tracker_http_protocol::v1::requests::announce::Announce::ip) | string |The IP address of the peer (BEP 3). | No | No | `2.137.87.41` -//! [`downloaded`](torrust_tracker_http_protocol::v1::requests::announce::Announce::downloaded) | positive integer |The number of bytes downloaded by the peer. | No | `0` | `0` -//! [`uploaded`](torrust_tracker_http_protocol::v1::requests::announce::Announce::uploaded) | positive integer | The number of bytes uploaded by the peer. | No | `0` | `0` +//! [`downloaded`](torrust_tracker_http_protocol::v1::requests::announce::Announce::downloaded) | non-negative integer |The number of bytes downloaded by the peer. | No | `0` | `0` +//! [`uploaded`](torrust_tracker_http_protocol::v1::requests::announce::Announce::uploaded) | non-negative integer | The number of bytes uploaded by the peer. | No | `0` | `0` //! [`peer_id`](torrust_tracker_http_protocol::v1::requests::announce::Announce::peer_id) | percent encoded of 20-byte array | The ID of the peer. | Yes | No | `-qB00000000000000001` //! [`port`](torrust_tracker_http_protocol::v1::requests::announce::Announce::port) | positive integer | The port used by the peer. | Yes | No | `17548` -//! [`left`](torrust_tracker_http_protocol::v1::requests::announce::Announce::left) | positive integer | The number of bytes pending to download. | No | `0` | `0` +//! [`left`](torrust_tracker_http_protocol::v1::requests::announce::Announce::left) | non-negative integer | The number of bytes pending to download. | No | `0` | `0` //! [`event`](torrust_tracker_http_protocol::v1::requests::announce::Announce::event) | positive integer | The event that triggered the `Announce` request: `started`, `completed`, `stopped` | No | `None` | `completed` //! [`compact`](torrust_tracker_http_protocol::v1::requests::announce::Announce::compact) | `0` or `1` | Whether the tracker should return a compact peer list. Compact by default per [BEP 23](https://www.bittorrent.org/beps/bep_0023.html). | No | `1` (compact) | `0` //! `numwant` | positive integer | **Not implemented**. The maximum number of peers you want in the reply. | No | `50` | `50` From 343fc66f1c0ad046aaf546066df907cbed8f9f7d Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 21:04:16 +0000 Subject: [PATCH 09/28] docs(issues): [#2850] record the manual verification Scenarios M1 to M7 on a running tracker: a negative counter gets a UDP error response with its transaction id and stores no peer; zero, positive and very large values give the same verdict over UDP and HTTP; HTTP accepts a `left` above `i64::MAX` and refuses one above `u64::MAX`; the REST API returns each value as sent. Co-Authored-By: Claude Opus 5.5 --- .../evidence/manual-run-output.txt | 88 ++++++++ .../evidence/tracker-log-rejections.txt | 3 + .../evidence/tracker.toml | 41 ++++ .../manual-verification-evidence.md | 206 ++++++++++++++++++ project-words.txt | 1 + 5 files changed, 339 insertions(+) create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/evidence/manual-run-output.txt create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker-log-rejections.txt create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker.toml create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/evidence/manual-run-output.txt b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/manual-run-output.txt new file mode 100644 index 0000000000..f2f5df36f6 --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/manual-run-output.txt @@ -0,0 +1,88 @@ +== M1 UDP left=-5 +21:01:41.525 (epoch 1794776501,525655) start: python3 -I docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py 6868 -5 +action=3 message='tracker announce error: Invalid announce request: `left` must not be negative, got -5' + +21:01:41.538 (epoch 1794776501,538609) end +21:01:41.540 (epoch 1794776501,540700) start: rest 1111111111111111111111111111111111111111 +"torrent not known" +21:01:41.549 (epoch 1794776501,549269) end +== M1 UDP uploaded=-1, downloaded=-1 +21:01:41.551 (epoch 1794776501,552011) start: python3 -I docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py 6868 0 -1 0 +action=3 message='tracker announce error: Invalid announce request: `uploaded` must not be negative, got -1' + +21:01:41.564 (epoch 1794776501,565137) end +21:01:41.567 (epoch 1794776501,567623) start: python3 -I docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py 6868 0 0 -1 +action=3 message='tracker announce error: Invalid announce request: `downloaded` must not be negative, got -1' + +21:01:41.580 (epoch 1794776501,581053) end +== M2 UDP left=0 +21:01:41.583 (epoch 1794776501,583373) start: python3 -I docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py 6868 0 7 9 +announce response: interval=120 leechers=0 seeders=1 + +21:01:41.596 (epoch 1794776501,597033) end +21:01:41.599 (epoch 1794776501,599533) start: rest 1111111111111111111111111111111111111111 +{"info_hash":"1111111111111111111111111111111111111111","seeders":1,"completed":0,"leechers":0,"peers":[{"peer_id":{"id":"0x2d5858303030312d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6881","updated":1794776501592,"updated_milliseconds_ago":1794776501592,"updated_at_ms":1794776501592,"uploaded":7,"downloaded":9,"left":0,"event":"Started"}]} +21:01:41.606 (epoch 1794776501,606355) end +== M3 UDP left=1000 +21:01:41.608 (epoch 1794776501,608669) start: python3 -I docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py 6868 1000 7 9 +announce response: interval=120 leechers=1 seeders=0 + +21:01:41.621 (epoch 1794776501,621562) end +21:01:41.623 (epoch 1794776501,623841) start: rest 1111111111111111111111111111111111111111 +{"info_hash":"1111111111111111111111111111111111111111","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030312d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6881","updated":1794776501617,"updated_milliseconds_ago":1794776501617,"updated_at_ms":1794776501617,"uploaded":7,"downloaded":9,"left":1000,"event":"Started"}]} +21:01:41.630 (epoch 1794776501,630610) end +== M3 UDP left=i64::MAX +21:01:41.632 (epoch 1794776501,633201) start: python3 -I docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py 6868 9223372036854775807 7 9 +announce response: interval=120 leechers=1 seeders=0 + +21:01:41.645 (epoch 1794776501,646100) end +21:01:41.648 (epoch 1794776501,648257) start: rest 1111111111111111111111111111111111111111 +{"info_hash":"1111111111111111111111111111111111111111","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030312d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6881","updated":1794776501642,"updated_milliseconds_ago":1794776501642,"updated_at_ms":1794776501642,"uploaded":7,"downloaded":9,"left":9223372036854775807,"event":"Started"}]} +21:01:41.654 (epoch 1794776501,655093) end +== M4 HTTP left=-5 +21:01:41.657 (epoch 1794776501,657321) start: http -5 7 9 +d14:failure reason153:Bad request. Cannot parse query params for announce request: invalid param value -5 for left in packages/http-protocol/src/v1/requests/announce.rs:593:27e +21:01:41.663 (epoch 1794776501,664911) end +== M4 HTTP left=0 +21:01:41.667 (epoch 1794776501,667495) start: http 0 7 9 +d8:completei1e10:incompletei0e8:intervali120e12:min intervali120e5:peerslee +21:01:41.673 (epoch 1794776501,673643) end +21:01:41.675 (epoch 1794776501,675665) start: rest 2222222222222222222222222222222222222222 +{"info_hash":"2222222222222222222222222222222222222222","seeders":1,"completed":0,"leechers":0,"peers":[{"peer_id":{"id":"0x2d5858303030322d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6882","updated":1794776501670,"updated_milliseconds_ago":1794776501670,"updated_at_ms":1794776501670,"uploaded":7,"downloaded":9,"left":0,"event":"Started"}]} +21:01:41.681 (epoch 1794776501,681275) end +== M4 HTTP left=1000 +21:01:41.683 (epoch 1794776501,683476) start: http 1000 7 9 +d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee +21:01:41.688 (epoch 1794776501,688995) end +21:01:41.691 (epoch 1794776501,691470) start: rest 2222222222222222222222222222222222222222 +{"info_hash":"2222222222222222222222222222222222222222","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030322d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6882","updated":1794776501686,"updated_milliseconds_ago":1794776501686,"updated_at_ms":1794776501686,"uploaded":7,"downloaded":9,"left":1000,"event":"Started"}]} +21:01:41.697 (epoch 1794776501,697457) end +== M4 HTTP left=i64::MAX +21:01:41.699 (epoch 1794776501,699962) start: http 9223372036854775807 7 9 +d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee +21:01:41.705 (epoch 1794776501,705486) end +21:01:41.707 (epoch 1794776501,707993) start: rest 2222222222222222222222222222222222222222 +{"info_hash":"2222222222222222222222222222222222222222","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030322d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6882","updated":1794776501703,"updated_milliseconds_ago":1794776501703,"updated_at_ms":1794776501703,"uploaded":7,"downloaded":9,"left":9223372036854775807,"event":"Started"}]} +21:01:41.713 (epoch 1794776501,713770) end +== M5 HTTP left=i64::MAX+1 +21:01:41.715 (epoch 1794776501,715984) start: http 9223372036854775808 7 9 +d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee +21:01:41.721 (epoch 1794776501,721490) end +21:01:41.723 (epoch 1794776501,723504) start: rest 2222222222222222222222222222222222222222 +{"info_hash":"2222222222222222222222222222222222222222","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030322d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6882","updated":1794776501718,"updated_milliseconds_ago":1794776501718,"updated_at_ms":1794776501718,"uploaded":7,"downloaded":9,"left":9223372036854775808,"event":"Started"}]} +21:01:41.730 (epoch 1794776501,730337) end +== M6 HTTP left=u64::MAX+1 +21:01:41.732 (epoch 1794776501,732432) start: http 18446744073709551616 7 9 +d14:failure reason171:Bad request. Cannot parse query params for announce request: invalid param value 18446744073709551616 for left in packages/http-protocol/src/v1/requests/announce.rs:593:27e +21:01:41.738 (epoch 1794776501,738250) end +21:01:41.740 (epoch 1794776501,740337) start: rest 2222222222222222222222222222222222222222 +{"info_hash":"2222222222222222222222222222222222222222","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030322d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6882","updated":1794776501718,"updated_milliseconds_ago":1794776501718,"updated_at_ms":1794776501718,"uploaded":7,"downloaded":9,"left":9223372036854775808,"event":"Started"}]} +21:01:41.745 (epoch 1794776501,746126) end +== M6b HTTP uploaded=u64::MAX, downloaded=u64::MAX +21:01:41.748 (epoch 1794776501,748423) start: http 1000 18446744073709551615 18446744073709551615 +d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee +21:01:41.753 (epoch 1794776501,754087) end +21:01:41.756 (epoch 1794776501,756260) start: rest 2222222222222222222222222222222222222222 +{"info_hash":"2222222222222222222222222222222222222222","seeders":0,"completed":0,"leechers":1,"peers":[{"peer_id":{"id":"0x2d5858303030322d303030303030303030303030","client":"XTorrent"},"peer_addr":"127.0.0.1:6882","updated":1794776501751,"updated_milliseconds_ago":1794776501751,"updated_at_ms":1794776501751,"uploaded":18446744073709551615,"downloaded":18446744073709551615,"left":1000,"event":"Started"}]} +21:01:41.762 (epoch 1794776501,763147) end +tracker exit=0 diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker-log-rejections.txt b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker-log-rejections.txt new file mode 100644 index 0000000000..5e2215172b --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker-log-rejections.txt @@ -0,0 +1,3 @@ +2026-11-15T21:01:41.534896Z ERROR process_request:handle_packet{server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } connection_id_validation=Strict request_id="ff2d4a84-c001-4ed8-83dc-f13dc344112f"}:handle_error{req_kind=Some(Announce { announce_request: AnnounceRequest { connection_id: ConnectionId(I64(7823993892321435050)), action_placeholder: AnnounceActionPlaceholder(I32(1)), transaction_id: TransactionId(I32(4321)), info_hash: InfoHash([17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]), peer_id: PeerId([45, 88, 88, 48, 48, 48, 49, 45, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), bytes_downloaded: NumberOfBytes(I64(0)), bytes_left: NumberOfBytes(I64(-5)), bytes_uploaded: NumberOfBytes(I64(0)), event: AnnounceEventBytes(I32(2)), ip_address: Ipv4AddrBytes([0, 0, 0, 0]), key: PeerKey(I32(7)), peers_wanted: NumberOfPeers(I32(-1)), port: Port(U16(6881)) } }) client_socket_addr=127.0.0.1:52312 server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } configuration_instance_id=ConfigurationInstanceId { service_role: UdpTracker, instance_index: 0 } public_url=None request_id=ff2d4a84-c001-4ed8-83dc-f13dc344112f cookie_valid_range=1794776380.534842..1794776502.534842 error=AnnounceFailed { source: InvalidAnnounceRequest { source: NegativeNumberOfBytes { field: Left, value: -5 } } } opt_transaction_id=Some(TransactionId(I32(4321)))}: UDP TRACKER: response error error=tracker announce error: Invalid announce request: `left` must not be negative, got -5 client_socket_addr=127.0.0.1:52312 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=ff2d4a84-c001-4ed8-83dc-f13dc344112f transaction_id=4321 +2026-11-15T21:01:41.561044Z ERROR process_request:handle_packet{server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } connection_id_validation=Strict request_id="a79b28bf-2fec-4e68-a79d-f0d1a7d4eb37"}:handle_error{req_kind=Some(Announce { announce_request: AnnounceRequest { connection_id: ConnectionId(I64(4532777801457619264)), action_placeholder: AnnounceActionPlaceholder(I32(1)), transaction_id: TransactionId(I32(4321)), info_hash: InfoHash([17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]), peer_id: PeerId([45, 88, 88, 48, 48, 48, 49, 45, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), bytes_downloaded: NumberOfBytes(I64(0)), bytes_left: NumberOfBytes(I64(0)), bytes_uploaded: NumberOfBytes(I64(-1)), event: AnnounceEventBytes(I32(2)), ip_address: Ipv4AddrBytes([0, 0, 0, 0]), key: PeerKey(I32(7)), peers_wanted: NumberOfPeers(I32(-1)), port: Port(U16(6881)) } }) client_socket_addr=127.0.0.1:43853 server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } configuration_instance_id=ConfigurationInstanceId { service_role: UdpTracker, instance_index: 0 } public_url=None request_id=a79b28bf-2fec-4e68-a79d-f0d1a7d4eb37 cookie_valid_range=1794776380.560998..1794776502.560998 error=AnnounceFailed { source: InvalidAnnounceRequest { source: NegativeNumberOfBytes { field: Uploaded, value: -1 } } } opt_transaction_id=Some(TransactionId(I32(4321)))}: UDP TRACKER: response error error=tracker announce error: Invalid announce request: `uploaded` must not be negative, got -1 client_socket_addr=127.0.0.1:43853 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=a79b28bf-2fec-4e68-a79d-f0d1a7d4eb37 transaction_id=4321 +2026-11-15T21:01:41.576846Z ERROR process_request:handle_packet{server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } connection_id_validation=Strict request_id="bafc40c4-a0ea-45a5-bdc4-2e0381e686d7"}:handle_error{req_kind=Some(Announce { announce_request: AnnounceRequest { connection_id: ConnectionId(I64(7096200961439010573)), action_placeholder: AnnounceActionPlaceholder(I32(1)), transaction_id: TransactionId(I32(4321)), info_hash: InfoHash([17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]), peer_id: PeerId([45, 88, 88, 48, 48, 48, 49, 45, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), bytes_downloaded: NumberOfBytes(I64(-1)), bytes_left: NumberOfBytes(I64(0)), bytes_uploaded: NumberOfBytes(I64(0)), event: AnnounceEventBytes(I32(2)), ip_address: Ipv4AddrBytes([0, 0, 0, 0]), key: PeerKey(I32(7)), peers_wanted: NumberOfPeers(I32(-1)), port: Port(U16(6881)) } }) client_socket_addr=127.0.0.1:49982 server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } configuration_instance_id=ConfigurationInstanceId { service_role: UdpTracker, instance_index: 0 } public_url=None request_id=bafc40c4-a0ea-45a5-bdc4-2e0381e686d7 cookie_valid_range=1794776380.576805..1794776502.576805 error=AnnounceFailed { source: InvalidAnnounceRequest { source: NegativeNumberOfBytes { field: Downloaded, value: -1 } } } opt_transaction_id=Some(TransactionId(I32(4321)))}: UDP TRACKER: response error error=tracker announce error: Invalid announce request: `downloaded` must not be negative, got -1 client_socket_addr=127.0.0.1:49982 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=bafc40c4-a0ea-45a5-bdc4-2e0381e686d7 transaction_id=4321 diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker.toml b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker.toml new file mode 100644 index 0000000000..c360825b04 --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker.toml @@ -0,0 +1,41 @@ +[metadata] +app = "torrust-tracker" +purpose = "configuration" +schema_version = "3.0.0" + +[logging] +trace_filter = "info" +trace_style = "full" + +[core] +inactive_peer_cleanup_interval = 120 +listed = false +private = false + +[core.database] +driver = "sqlite3" +path = "./sqlite3.db" + +[udp_tracker_server] +ip_bans_reset_interval_in_secs = 86400 +max_connection_id_errors_per_ip = 10 +connection_id_validation = "strict" + +[core.tracker_policy] +max_peer_timeout = 60 +persistent_torrent_completed_stat = true +remove_peerless_torrents = true + +[[udp_trackers]] +bind_address = "127.0.0.1:6868" +tracker_usage_statistics = true + +[[http_trackers]] +bind_address = "127.0.0.1:7070" +tracker_usage_statistics = true + +[http_api] +bind_address = "127.0.0.1:1212" + +[http_api.access_tokens] +admin = "MyAccessToken" diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md new file mode 100644 index 0000000000..732649ea5c --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md @@ -0,0 +1,206 @@ +--- +doc-type: manual-verification-evidence +issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +last-updated-utc: "2026-11-15 21:05" +--- + +# Manual Verification Evidence + + + +## Purpose + +Real use of a running tracker for the scenarios M1 to M7 of the issue specification: UDP and HTTP +announces with negative, zero, positive and very large byte counts, and the REST API output of the +announced peer. + +## Environment and Prerequisites + +- Date and time (UTC): 2026-11-15 21:01:41 to 21:01:42 (run 2; see "Failures and Follow-up" for + run 1). +- Artifact under test: the branch of issue #2850 at + `docs(axum-http-server): [#2850] describe the byte-count params as non-negative`, which follows + every production change (`fix(udp-core)!: [#2850] refuse a negative byte count in the + wire-to-domain conversion` and `refactor(primitives)!: [#2850] hold the number of bytes in a + u64`). `git status --short` showed only the new `evidence/` folder before the build. Debug build: + `cargo build --bin torrust-tracker`, stable Rust toolchain (`rustc 1.99.1`). +- Operating system: Linux 7.0.0-43-generic. +- Tracker configuration: [`evidence/tracker.toml`](evidence/tracker.toml): UDP on + `127.0.0.1:6868`, HTTP on `127.0.0.1:7070`, REST API on `127.0.0.1:1212` with the development + token, an SQLite database in the run folder, `info` logging. Before the run, no socket listened + on these ports or on the health check API's default `127.0.0.1:1313`. +- UDP announces: the probe of issue #2838, + [`udp_announce_probe.py`](../2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py), + run from this branch (arguments ` [uploaded] [downloaded]`; info hash `0x11` × 20, + peer port 6881, event `started`). HTTP announces: `curl` with info hash `0x22` × 20, peer port + 6882, event `started`. Each protocol uses its own info hash, so the UDP and HTTP peers never + share a swarm, and each accepted announce replaces the peer of the previous one. +- REST output: `GET /api/v1/torrent/` right after each accepted announce and before the + next announce. + +### Run Script + +The steps run one after another from this disposable script (in the session scratchpad, not in the +repository), each stamped with `date -u` and bash's `$EPOCHREALTIME`: + +```bash +#!/bin/bash +# Disposable: runs M1-M7 of issue #2850 one step at a time against a fresh tracker. +set -u +repo="$1"; run="$2" +probe="$repo/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py" +cfg="$repo/docs/issues/open/2850-non-negative-number-of-bytes/evidence/tracker.toml" +rm -rf "$run"; mkdir -p "$run"; cd "$run" +TORRUST_TRACKER_CONFIG_TOML_PATH="$cfg" "$repo/target/debug/torrust-tracker" > "$run/tracker.log" 2>&1 & +tracker_pid=$! +sleep 4 +ts() { echo "$(date -u +%T.%3N) (epoch $EPOCHREALTIME)"; } +step() { echo "$(ts) start: $*"; "$@"; echo; echo "$(ts) end"; } +udp_hash=1111111111111111111111111111111111111111 +http_hash=2222222222222222222222222222222222222222 +rest() { curl -s "http://127.0.0.1:1212/api/v1/torrent/$1?token=MyAccessToken"; } +http() { curl -s "http://127.0.0.1:7070/announce?info_hash=%22%22%22%22%22%22%22%22%22%22%22%22%22%22%22%22%22%22%22%22&peer_id=-XX0002-000000000000&port=6882&uploaded=$2&downloaded=$3&left=$1&event=started&compact=0"; } +echo "== M1 UDP left=-5" +step python3 -I "$probe" 6868 -5 +step rest $udp_hash +echo "== M1 UDP uploaded=-1, downloaded=-1" +step python3 -I "$probe" 6868 0 -1 0 +step python3 -I "$probe" 6868 0 0 -1 +echo "== M2 UDP left=0" +step python3 -I "$probe" 6868 0 7 9 +step rest $udp_hash +echo "== M3 UDP left=1000" +step python3 -I "$probe" 6868 1000 7 9 +step rest $udp_hash +echo "== M3 UDP left=i64::MAX" +step python3 -I "$probe" 6868 9223372036854775807 7 9 +step rest $udp_hash +echo "== M4 HTTP left=-5" +step http -5 7 9 +echo "== M4 HTTP left=0" +step http 0 7 9 +step rest $http_hash +echo "== M4 HTTP left=1000" +step http 1000 7 9 +step rest $http_hash +echo "== M4 HTTP left=i64::MAX" +step http 9223372036854775807 7 9 +step rest $http_hash +echo "== M5 HTTP left=i64::MAX+1" +step http 9223372036854775808 7 9 +step rest $http_hash +echo "== M6 HTTP left=u64::MAX+1" +step http 18446744073709551616 7 9 +step rest $http_hash +echo "== M6b HTTP uploaded=u64::MAX, downloaded=u64::MAX" +step http 1000 18446744073709551615 18446744073709551615 +step rest $http_hash +kill -TERM $tracker_pid; wait $tracker_pid +echo "tracker exit=$?" +``` + +The full output, with the repository path removed, is +[`evidence/manual-run-output.txt`](evidence/manual-run-output.txt). The tracker exited with code 0 +after `SIGTERM`. + +## Verification Processes + +### V1 - M1: UDP, negative counters + +- Status: `DONE` +- Steps: probe with `left = -5`, then the REST detail of the UDP info hash; probe with + `uploaded = -1`; probe with `downloaded = -1`. +- Observed: + + ```text + 21:01:41.525 start: probe 6868 -5 + action=3 message='tracker announce error: Invalid announce request: `left` must not be negative, got -5' + 21:01:41.540 start: rest 1111111111111111111111111111111111111111 + "torrent not known" + 21:01:41.551 start: probe 6868 0 -1 0 + action=3 message='tracker announce error: Invalid announce request: `uploaded` must not be negative, got -1' + 21:01:41.567 start: probe 6868 0 0 -1 + action=3 message='tracker announce error: Invalid announce request: `downloaded` must not be negative, got -1' + ``` + + The probe exits with status 1 when a response does not carry its request's transaction id + (4321), so each error response carried it. The tracker log has one `ERROR` line per rejection + (`grep -c "must not be negative"` printed `3`); the three lines, without colour codes, are in + [`evidence/tracker-log-rejections.txt`](evidence/tracker-log-rejections.txt). They show + `error=AnnounceFailed { source: InvalidAnnounceRequest { source: NegativeNumberOfBytes { field: Left, value: -5 } } }` + and `transaction_id=4321`. +- Conclusion: the negative counter gets a BEP 15 error response (action 3) with the transaction id; + the swarm is not created, so no peer is stored and `complete` does not grow. The symptom of + #2838 is gone. AC12. + +### V2 - M2: UDP, `left = 0` + +- Status: `DONE` +- Observed: `announce response: interval=120 leechers=0 seeders=1`; REST: `"seeders":1`, the peer + with `"uploaded":7,"downloaded":9,"left":0`. +- Conclusion: a seeder, as before. + +### V3 - M3: UDP, positive `left` + +- Status: `DONE` +- Observed: `left = 1000`: `leechers=1 seeders=0`, REST `"left":1000`. + `left = 9223372036854775807`: `leechers=1 seeders=0`, REST `"left":9223372036854775807`. +- Conclusion: leechers, including the value Transmission sends when the size is unknown. + +### V4 - M4: HTTP, the same values + +- Status: `DONE` +- Observed: + + ```text + left=-5: d14:failure reason153:Bad request. Cannot parse query params for announce request: invalid param value -5 for left in packages/http-protocol/src/v1/requests/announce.rs:593:27e + left=0: d8:completei1e10:incompletei0e8:intervali120e12:min intervali120e5:peerslee + left=1000: d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee + left=9223372036854775807: d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee + ``` + +- Conclusion: refused, seeder, leecher, leecher: the same verdicts as V1 to V3. AC13. + +### V5 - M5: HTTP, above `i64::MAX` + +- Status: `DONE` +- Observed: `left = 9223372036854775808`: + `d8:completei0e10:incompletei1e8:intervali120e12:min intervali120e5:peerslee`; REST + `"left":9223372036854775808`. +- Conclusion: accepted as a leecher; before this issue it was refused with `NumberOfBytesOverflow`. + AC10. + +### V6 - M6: HTTP, above `u64::MAX` + +- Status: `DONE` +- Observed: `left = 18446744073709551616`: + `d14:failure reason171:Bad request. Cannot parse query params for announce request: invalid param value 18446744073709551616 for left in packages/http-protocol/src/v1/requests/announce.rs:593:27e`. + The REST detail after it still shows the peer of V5 (`"left":9223372036854775808`), so the + refused announce changed nothing. +- Additional step (M6b): `uploaded = downloaded = 18446744073709551615`, `left = 1000`: accepted; + REST `"uploaded":18446744073709551615,"downloaded":18446744073709551615,"left":1000`. +- Conclusion: a bencoded `failure reason`, as expected; `u64::MAX` is accepted for every counter. + AC8. + +### V7 - M7: REST output + +- Status: `DONE` +- Observed: after every accepted announce of V2 to V6, the single-torrent detail returned + `left`, `uploaded` and `downloaded` as JSON numbers equal to the values just sent, including + `9223372036854775808` and `18446744073709551615` (above `i64::MAX`). The JSON field names and + shapes are the ones of the previous `i64` fields. Full responses in + [`evidence/manual-run-output.txt`](evidence/manual-run-output.txt). +- Conclusion: AC11. Values above 2^53 lose precision in JavaScript clients that parse them as + numbers; that already held for large `i64` values (see the specification, "Risks and + Trade-offs"). + +## Failures and Follow-up + +- Run 1 (21:01:25 to 21:01:26 UTC), with the same script but only `date -u +%T.%3N` stamps, gave + the same responses (the outputs of both runs are equal once the `updated*` fields and the stamps + are removed), but its last stamps were not monotonic (`21:01:26.941 end`, then + `21:01:26.111 start`), and the tracker's `updated_at_ms` of the last announce + (`1794776486014`, 21:01:26.014) was earlier than the stamp of the step that sent it. The + steps ran sequentially in one bash script, so the order is not in doubt, but the record could + not show it. The cause is not known; the system clock is NTP-synchronized. Run 1 is discarded, + and run 2 adds bash's `$EPOCHREALTIME` next to each stamp; its stamps are monotonic. diff --git a/project-words.txt b/project-words.txt index 2541c5a5ff..11a6fc4819 100644 --- a/project-words.txt +++ b/project-words.txt @@ -435,6 +435,7 @@ pathspecs peekable peerlist peersld +peerslee penalise pessimize pgrep From 461185b9b20397769177a6df05642dacab92c4dc Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 21:07:37 +0000 Subject: [PATCH 10/28] docs(issues): [#2850] record the agreed UDP benchmark tolerance The maintainer agreed a 5% tolerance over the highest baseline median for the UDP announce benchmark, after the baseline and before the after measurement. Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md | 3 +++ .../2850-non-negative-number-of-bytes/performance-evidence.md | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md index 5cfe8d41e6..0b848a23f4 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md @@ -769,6 +769,9 @@ of `http-core`, and the end-to-end UDP load test. tolerance. The tolerance is not set here: the maintainer agrees on it after the baseline shows the noise, and before the after measurement, and is then added to this section. The HTTP path adds no work, so its rule has no tolerance. +- Agreed tolerance (maintainer, 2026-11-15, after the baseline and before the after measurement): + the after UDP `announce_once` median may be up to 5% above the highest baseline median, that is + at most 318.70 ns (highest baseline median 303.52 ns; baseline spread 6.5%). ### Manual Verification Scenarios diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md index aed4dd6b82..d09e027b80 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md @@ -99,8 +99,8 @@ From the specification: - the after mean of the load test is not below the lowest baseline run (135,528.53); - the after HTTP `announce_once` median is not above the highest baseline median (342.05 ns); - the after UDP `announce_once` median is not above the highest baseline median (303.52 ns) plus a - tolerance for the three sign checks T2 adds. The tolerance is agreed with the maintainer before - the after measurement and recorded here. + tolerance for the three sign checks T2 adds. Agreed with the maintainer on 2026-11-15, after the + baseline and before the after measurement: 5%, so the after median must be at most 318.70 ns. ## After From 75ab5e62aec157a7ddfac737f2f2ed9e12a835a0 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 21:17:58 +0000 Subject: [PATCH 11/28] docs(issues): [#2850] record the after measurement and the progress The load test and the UDP announce benchmark pass the pass rule. The HTTP announce benchmark fails it by 0.3% on a path the change adds no work to; an interleaved A/B run of the two builds puts the difference inside the noise, and the verdict is left to the maintainer. The specification records the tasks, the acceptance evidence and the progress. Co-Authored-By: Claude Opus 5.5 --- .../ISSUE.md | 81 ++++++++++--------- .../performance-evidence.md | 60 +++++++++++++- 2 files changed, 97 insertions(+), 44 deletions(-) diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md index 0b848a23f4..dfc2423c2b 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md @@ -2,14 +2,14 @@ schema-version: 1 doc-type: issue issue-type: bug -status: planned +status: in-progress priority: p2 epic: null github-issue: 2850 spec-path: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -branch: "2850-non-negative-number-of-bytes-spec" +branch: "2850-non-negative-number-of-bytes" related-pr: null -last-updated-utc: "2026-11-15 21:07" +last-updated-utc: "2026-11-15 21:25" semantic-links: skill-links: - create-issue @@ -625,13 +625,13 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | ID | Status | Task | Notes / Expected Output | | --- | --- | --- | --- | -| T0 | TODO | Add the missing benchmark and record the baseline | [`docs/benchmarking.md`](../../../benchmarking.md) requires it before any production change. The `udp-core` benchmarks time only the connect, the connection cookie and the ban service, and `udp-server` only a scrape; no Criterion benchmark times a UDP announce, so add one (announce through the `udp-core` service, so the conversion is on the timed path). The HTTP announce is covered by `bench_announce_once` in `http-core`. Record the baseline of both, plus the end-to-end UDP load test (`aquatic_udp_load_test`), in `performance-evidence.md`, on the code the branch starts from plus documentation and benchmark-only commits: three Criterion runs (medians) and five 30-second load-test runs, with the checks of the machine that the guide lists. | -| T1 | TODO | Pin today's HTTP range with tests | Unit tests in `http-protocol` for each param: negative refused, `0` accepted, non-numeric refused. They pass before any production change | -| T2 | TODO | Make the UDP conversion fallible | Red first: the handler test of PR #2839 fails. Then `peer_builder::from_request` returns `Result` with its own error; the service uses `?`; `UdpAnnounceError` wraps it; `udp-server` classifies it as a bad request; tests taken from the branch of PR #2839. The domain type is still `i64`. This step alone fixes the bug of #2838 | -| T3 | TODO | Change the two types and their callers | `primitives` and `http-protocol` types hold a private `u64`; `is_seeder`, serializer, parser, builder, `http-core`, REST resource and adapter, benches and any test code that does not compile. `NumberOfBytesOverflow` removed. The workspace builds and all tests pass | -| T4 | TODO | Add the tests for the new range | `u64::MAX` and above in `http-protocol`; the contract test in `axum-http-server`; seeder and leecher tests in `primitives` | -| T5 | TODO | Check client-visible output and documentation | UDP error message for a negative counter; REST peer JSON; API description; "non-negative integer" in the `axum-http-server` documentation. Old and new listed in the pull request | -| T6 | TODO | Verification and evidence | Automatic checks, manual scenarios, the performance measurement again after T3 (same machine, build profile, configuration and settings as the baseline; every run in `performance-evidence.md`), acceptance review, completion review | +| T0 | DONE | Add the missing benchmark and record the baseline | [`docs/benchmarking.md`](../../../benchmarking.md) requires it before any production change. The `udp-core` benchmarks time only the connect, the connection cookie and the ban service, and `udp-server` only a scrape; no Criterion benchmark times a UDP announce, so add one (announce through the `udp-core` service, so the conversion is on the timed path). The HTTP announce is covered by `bench_announce_once` in `http-core`. Record the baseline of both, plus the end-to-end UDP load test (`aquatic_udp_load_test`), in `performance-evidence.md`, on the code the branch starts from plus documentation and benchmark-only commits: three Criterion runs (medians) and five 30-second load-test runs, with the checks of the machine that the guide lists. | +| T1 | DONE | Pin today's HTTP range with tests | Unit tests in `http-protocol` for each param: negative refused, `0` accepted, non-numeric refused. They pass before any production change | +| T2 | DONE | Make the UDP conversion fallible | Red first: the handler test of PR #2839 fails. Then `peer_builder::from_request` returns `Result` with its own error; the service uses `?`; `UdpAnnounceError` wraps it; `udp-server` classifies it as a bad request; tests taken from the branch of PR #2839. The domain type is still `i64`. This step alone fixes the bug of #2838 | +| T3 | DONE | Change the two types and their callers | `primitives` and `http-protocol` types hold a private `u64`; `is_seeder`, serializer, parser, builder, `http-core`, REST resource and adapter, benches and any test code that does not compile. `NumberOfBytesOverflow` removed. The workspace builds and all tests pass | +| T4 | DONE | Add the tests for the new range | `u64::MAX` and above in `http-protocol`; the contract test in `axum-http-server`; seeder and leecher tests in `primitives` | +| T5 | DONE | Check client-visible output and documentation | UDP error message for a negative counter; REST peer JSON; API description; "non-negative integer" in the `axum-http-server` documentation. Old and new listed in the pull request | +| T6 | DONE | Verification and evidence | Automatic checks, manual scenarios, the performance measurement again after T3 (same machine, build profile, configuration and settings as the baseline; every run in `performance-evidence.md`), acceptance review, completion review | T2 goes before T3 on purpose: it fixes the bug in the conversion while the domain type is unchanged, so it can be reviewed and tested alone. T3 is one commit, because the workspace does not @@ -687,15 +687,15 @@ with the narrow affected scope, and sign every commit with GPG. - [x] Folder-style spec drafted in `docs/issues/drafts/non-negative-number-of-bytes/ISSUE.md` - [x] Spec reviewed and approved by user/maintainer - [x] GitHub issue created and issue number added to this spec -- [ ] (Optional, recommended for complex issues) Spec-only PR merged into `develop` before implementation -- [ ] Implementation completed -- [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) -- [ ] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` -- [ ] Acceptance criteria reviewed after implementation and updated with evidence -- [ ] Evidence-based implementation completion review recorded: issue-local retrospective created for material discoveries, or progress log states why none was needed +- [x] (Optional, recommended for complex issues) Spec-only PR merged into `develop` before implementation +- [x] Implementation completed +- [x] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) +- [x] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` +- [x] Acceptance criteria reviewed after implementation and updated with evidence +- [x] Evidence-based implementation completion review recorded: issue-local retrospective created for material discoveries, or progress log states why none was needed - [ ] Reviewer validated acceptance criteria and updated checkboxes - [ ] Independent reviewer reports recorded in issue-local `agent-review-reports.md` when reviewers received this folder-style specification -- [ ] Committer verified spec progress is up to date before commit +- [x] Committer verified spec progress is up to date before commit - [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` ### Progress Log @@ -715,6 +715,7 @@ the model that produced them. - 2026-11-12 17:32 UTC - Claude Code (Fable 5.2) - The maintainer decided that one issue is enough (D6). Merged the EPIC draft and the two sub-issue drafts into this single issue specification; nothing was dropped from the research, the decisions or the source map. Not approved; no GitHub issue created. - 2026-11-12 17:40 UTC - Claude Code (Fable 5.2) - The maintainer approved the plan: this issue is the fix for #2838 and replaces the patch of PR #2839, and the ADR of #2842 is delivered by this issue's spec-only pull request instead of PR #2843. Created issue #2850, moved the specification to `docs/issues/open/`, carried over the four ADR commits and the specification and evidence of #2838, and rewrote D3, D5, D6, the bug-fix process and the coordination for that plan. The two other sessions were told and close their pull requests. - 2026-11-12 20:29 UTC - Claude Code (Fable 5.2) - Rebased the spec-only branch onto `develop` after PR #2841 (the primitives tests of #2824) merged and conflicted in the EPIC #1347 table. Updated the coordination note: those tests are on `develop` and name this issue. +- 2026-11-15 21:25 UTC - Claude Code (Opus 5.5) - Implemented T0 to T6 on branch `2850-non-negative-number-of-bytes`. T0 added `udp_tracker/announce_once`; the first baseline was discarded because uncommitted T1/T2 edits leaked into its build, and each measurement is now built in a clean worktree (`performance-evidence.md`, lesson added to `docs/benchmarking.md`). T2 named the field with the `ByteCountField` enum (one variant, one message, the field as a matchable value) and moved the peer conversion before the whitelist check, as the order tests of PR #2839 require. The maintainer agreed a 5% tolerance for the UDP benchmark before the after measurement. Load test and UDP pass; HTTP `announce_once` failed the one-sided rule by 0.3% on a path T3 does not add work to, and an interleaved A/B run put it inside the noise: the verdict is the maintainer's. Manual run 1 was discarded for non-monotonic timestamps. No design assumption was invalidated, so no retrospective file. ## Acceptance Criteria @@ -786,13 +787,13 @@ announce is sent, and use the single-torrent detail: the torrent list does not i | ID | Scenario | Human-oriented command/steps | Expected Result | Status | Evidence | | --- | --- | --- | --- | --- | --- | -| M1 | UDP, negative `left` | Probe of #2838 with `left = -5` | Error response with the transaction id; `complete` does not grow | TODO | `manual-verification-evidence.md` section V1 | -| M2 | UDP, `left = 0` | Probe with `left = 0` | Normal response; the peer is a seeder | TODO | `manual-verification-evidence.md` section V2 | -| M3 | UDP, positive `left` | Probe with `left = 1000` and with `left = 9223372036854775807` | Normal responses; the peers are leechers | TODO | `manual-verification-evidence.md` section V3 | -| M4 | HTTP, the same values | `curl` announces with `left=-5`, `left=0`, `left=1000` and `left=9223372036854775807` | Refused with a `failure reason`, seeder, leecher, leecher: the same verdicts as M1 to M3 | TODO | `manual-verification-evidence.md` section V4 | -| M5 | HTTP, above `i64::MAX` | `curl` announce with `left=9223372036854775808` | Normal response; the peer is a leecher | TODO | `manual-verification-evidence.md` section V5 | -| M6 | HTTP, above `u64::MAX` | `curl` announce with `left=18446744073709551616` | Bencoded `failure reason` | TODO | `manual-verification-evidence.md` section V6 | -| M7 | REST output | Right after each accepted announce of M2, M3, M4 and M5, and before the next announce, `GET` the single-torrent detail from the REST API | For each announce, `left`, `uploaded` and `downloaded` of the peer are JSON numbers with the values just sent, including the one above `i64::MAX` | TODO | `manual-verification-evidence.md` section V7 | +| M1 | UDP, negative `left` | Probe of #2838 with `left = -5` | Error response with the transaction id; `complete` does not grow | DONE | `manual-verification-evidence.md` section V1 | +| M2 | UDP, `left = 0` | Probe with `left = 0` | Normal response; the peer is a seeder | DONE | `manual-verification-evidence.md` section V2 | +| M3 | UDP, positive `left` | Probe with `left = 1000` and with `left = 9223372036854775807` | Normal responses; the peers are leechers | DONE | `manual-verification-evidence.md` section V3 | +| M4 | HTTP, the same values | `curl` announces with `left=-5`, `left=0`, `left=1000` and `left=9223372036854775807` | Refused with a `failure reason`, seeder, leecher, leecher: the same verdicts as M1 to M3 | DONE | `manual-verification-evidence.md` section V4 | +| M5 | HTTP, above `i64::MAX` | `curl` announce with `left=9223372036854775808` | Normal response; the peer is a leecher | DONE | `manual-verification-evidence.md` section V5 | +| M6 | HTTP, above `u64::MAX` | `curl` announce with `left=18446744073709551616` | Bencoded `failure reason` | DONE | `manual-verification-evidence.md` section V6 | +| M7 | REST output | Right after each accepted announce of M2, M3, M4 and M5, and before the next announce, `GET` the single-torrent detail from the REST API | For each announce, `left`, `uploaded` and `downloaded` of the peer are JSON numbers with the values just sent, including the one above `i64::MAX` | DONE | `manual-verification-evidence.md` section V7 | Notes: @@ -822,21 +823,21 @@ from. | AC ID | Status (`TODO`/`DONE`) | Evidence | | --- | --- | --- | -| AC1 | TODO | {test/log/PR link} | -| AC2 | TODO | {test/log/PR link} | -| AC3 | TODO | {test/log/PR link} | -| AC4 | TODO | {test/log/PR link} | -| AC5 | TODO | {test/log/PR link} | -| AC6 | TODO | {test/log/PR link} | -| AC7 | TODO | {test/log/PR link} | -| AC8 | TODO | {test/log/PR link} | -| AC9 | TODO | {test/log/PR link} | -| AC10 | TODO | {test/log/PR link} | -| AC11 | TODO | {test/log/PR link} | -| AC12 | TODO | {test/log/PR link} | -| AC13 | TODO | {test/log/PR link} | -| AC14 | TODO | {test/log/PR link} | -| AC15 | TODO | {test/log/PR link} | +| AC1 | DONE | `packages/primitives/src/number_of_bytes.rs` and `packages/http-protocol/src/v1/requests/announce.rs`: private `u64`, `new(u64)`, `get()`; commit "refactor(primitives)!: [#2850] hold the number of bytes in a u64" | +| AC2 | DONE | `packages/primitives/src/peer.rs`: the three copies read `self.left.get() == 0`; `peer_state` tests cover `left` 0 and 1 with `Started` and `Stopped`, for the peer and through `ReadInfo` on a shared peer | +| AC3 | DONE | `peer_builder::tests::it_should_reject_a_negative_number_of_bytes` (`left` -1 and `i64::MIN`, `uploaded` -1, `downloaded` -1) asserts `FromRequestError::NegativeNumberOfBytes { field, value }` | +| AC4 | DONE | `peer_builder::tests::it_should_accept_a_non_negative_number_of_bytes_left` (0, 16384, `i64::MAX`) | +| AC5 | DONE | `grep -rn validate_number_of_bytes packages` prints nothing; the check is the conversion `u64::try_from` in `peer_builder::number_of_bytes` | +| AC6 | DONE | `peer_builder.rs` imports nothing from `services`; `UdpAnnounceError::InvalidAnnounceRequest { source: FromRequestError }` | +| AC7 | DONE | `git diff --stat torrust/develop -- packages/udp-protocol` prints nothing | +| AC8 | DONE | The variant is removed; `when_a_number_of_bytes_param_is_parsed` tests in `http-protocol` (negative, non-numeric, above `u64::MAX` refused with `InvalidParam`; 0 and `u64::MAX` accepted); manual V4 and V6 | +| AC9 | DONE | The three builder methods are `const fn` that wrap the `u64`; no `# Panics` section | +| AC10 | DONE | `http-core` `peer_from_request` uses `NumberOfBytes::new(x.get())`; contract test `should_accept_a_number_of_bytes_left_above_the_largest_signed_64_bit_value`; manual V5 | +| AC11 | DONE | `rest-api-protocol` peer resource fields are `u64`; manual V7 shows the same JSON field names and numbers, including values above `i64::MAX`. No generated API description exists in the repository to update | +| AC12 | DONE | Handler test `it_should_reject_an_announce_with_a_negative_number_of_bytes_left` (exact error and transaction id, no peer stored); manual V1 (action 3, transaction id 4321, `torrent not known`) | +| AC13 | DONE | Manual V1 to V4: refused, seeder, leecher over both protocols | +| AC14 | DONE | Merged with the spec-only PR #2851; listed in `docs/adrs/index.md` | +| AC15 | DONE (classification); the closing keywords are in the pull request body | `udp-server` `event::tests::it_should_classify_a_negative_number_of_bytes_in_an_announce_as_a_bad_request` | ## Risks and Trade-offs @@ -877,7 +878,7 @@ After implementation, compare the result with this specification. Record invalidated assumptions, material design changes, unexpected validation findings, and reusable lessons. -- Retrospective: `Not yet assessed` +- Retrospective: not needed; see the progress log entry of 2026-11-15 21:25 UTC. The design held as specified; the discoveries were about measurement, recorded in `performance-evidence.md` and in `docs/benchmarking.md`. - If needed, create `implementation-retrospective.md` from the repository template at `docs/templates/IMPLEMENTATION-RETROSPECTIVE.md` in this issue specification's directory. diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md index d09e027b80..483a46f923 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md @@ -1,7 +1,7 @@ --- doc-type: performance-evidence issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -last-updated-utc: "2026-11-15 20:50" +last-updated-utc: "2026-11-15 21:20" --- # Performance Evidence - Non-Negative Number of Bytes @@ -67,8 +67,7 @@ used below. ## Baseline -Commit `7b5dd310f` ("test(udp-core): [#2850] add a UDP announce benchmark"), on `develop` at -`abd7a10ff`. Measured on 2026-11-15. +The commit "test(udp-core): [#2850] add a UDP announce benchmark", on `develop` at `abd7a10ff`. Measured on 2026-11-15. ### Criterion Medians @@ -104,4 +103,57 @@ From the specification: ## After -Not measured yet. +The commit "docs(issues): [#2850] record the agreed UDP benchmark tolerance", the branch after T2 to T5 (every production change) plus documentation commits, built in its own clean +worktree like the baseline. Same machine, toolchain, profile, commands, configuration and load-test +settings. Measured on 2026-11-15. The load average was higher than during the baseline (5.7 to +9.3 against 4.8 to 7.1). + +### Criterion Medians + +| Run | Start (UTC) | Load average (1 min) | UDP `announce_once` | HTTP `announce_once` | +| --- | --- | --- | --- | --- | +| 1 | 21:10:36 | 9.33 | 295.03 ns | 349.01 ns | +| 2 | 21:12:25 | 7.07 | 302.31 ns | 342.95 ns | +| 3 | 21:12:31 | 6.99 | 291.94 ns | 338.87 ns | + +### Load Test + +| Run | Start (UTC) | Load average (1 min) | Average responses per second | Error responses | +| --- | --- | --- | --- | --- | +| 1 | 21:12:38 | 6.83 | 140,954.65 | 0.00 | +| 2 | 21:13:13 | 7.07 | 142,965.47 | 0.00 | +| 3 | 21:13:47 | 7.06 | 142,760.97 | 0.00 | +| 4 | 21:14:21 | 7.13 | 144,295.54 | 0.00 | +| 5 | 21:14:55 | 7.39 | 146,743.32 | 0.00 | + +Mean 143,543.99. + +## Comparison With the Pass Rule + +| Instrument | Rule | After | Result | +| --- | --- | --- | --- | +| Load test | mean not below the lowest baseline run (135,528.53) | 143,543.99 (baseline mean 141,104.16) | Pass | +| UDP `announce_once` | each median at most 318.70 ns (highest baseline median 303.52 ns plus the agreed 5%) | 291.94 to 302.31 ns, median of the three 295.03 ns | Pass, also without the tolerance | +| HTTP `announce_once` | each median at most the highest baseline median (342.05 ns) | 338.87 to 349.01 ns, median of the three 342.95 ns | **Fail** by 0.90 ns (0.3%) on the median of the three; runs 1 and 2 are above the limit | + +### Investigation of the HTTP Result + +T3 adds no work to the HTTP announce path: the HTTP-to-domain conversion reads `get()` instead of +the public field, and the parser no longer runs the `i64::try_from` overflow check (one comparison +less). The benchmark times `AnnounceService::handle_announce`, which starts after parsing, so that +removed check is not even on its timed path. + +To separate the code from the noise of the shared machine, the HTTP benchmark was run again from +the two clean worktree builds, alternating baseline and after, three pairs in a row (21:15:42 to 21:15:59 +UTC, load average 5.7 to 6.0): + +| Pair | Baseline | After | +| --- | --- | --- | +| 1 | 364.02 ns | 351.12 ns | +| 2 | 342.19 ns | 340.83 ns | +| 3 | 328.78 ns | 351.09 ns | + +The after build is faster in two pairs and slower in one; the baseline alone spans 328.78 to 364.02 +ns (10.7%) within a minute. The difference of the original after run is inside this noise, so no +regression is attributed to the change. The one-sided rule is formally failed and the verdict is +the maintainer's: this record is listed in the pull request for that decision. From 3c9feb884c3754d4d5cc2ded632d42802a3b1fa4 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 21:18:30 +0000 Subject: [PATCH 12/28] docs(benchmarking): build each measurement from a clean worktree A baseline of issue #2850 was built from the working tree while edits of the next task were already in it. Building each measured commit in its own detached worktree keeps the build equal to the commit. Co-Authored-By: Claude Opus 5.5 --- docs/benchmarking.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/benchmarking.md b/docs/benchmarking.md index f8264ef03f..b32062bbcf 100644 --- a/docs/benchmarking.md +++ b/docs/benchmarking.md @@ -80,7 +80,11 @@ When an issue changes performance-critical code, measure it before and after: the after measurement. In issue #2505 the plan had neither, so the after measurement failed the rule and the cost was accepted only afterwards. 2. **Record the baseline before any production change**, on the code the branch starts from plus - only documentation and benchmark-only commits. + only documentation and benchmark-only commits. Build each measurement from a committed state in its + own detached worktree (`git worktree add --detach .tmp/ `), with its own `target` + directory, so that edits you keep making in the working branch cannot leak into the build. In + issue #2850 the first baseline was built from the working tree while the next task's edits were + already in it, and had to be discarded. 3. **Repeat the measurement after the change** on the same machine, with the same build profile, configuration, and load-test settings. Change benchmark code only as far as new signatures require: even code outside the timed loop can move a nanosecond-scale result. In issue #2479, From b02533c195a4401754a11af284ae2a360a149d8f Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Sun, 15 Nov 2026 21:23:00 +0000 Subject: [PATCH 13/28] docs(issues): [#2850] point #2838 and the EPIC #1347 table to PR #2872 The #2838 specification and row 12 of the EPIC #1347 sub-issue table now name the implementation PR of #2850, which closes #2838 on merge. Co-Authored-By: Claude Opus 5.5 --- .../open/1347-overhaul-packages-testing/EPIC.md | 5 +++-- .../ISSUE.md | 11 +++++++---- .../open/2850-non-negative-number-of-bytes/ISSUE.md | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/issues/open/1347-overhaul-packages-testing/EPIC.md b/docs/issues/open/1347-overhaul-packages-testing/EPIC.md index a66e470f00..e3f2932cb4 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-15 21:07" +last-updated-utc: "2026-11-15 21:40" semantic-links: skill-links: - create-issue @@ -97,7 +97,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | 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/closed/2824-1347-add-tests-primitives/ISSUE.md` | DONE | S0 (the spec, #2828), S1 (the `PeerRole` JSON casing fix, #2834), S2 (the `peer.rs` tests, #2841), S3 (the configuration defaults and bounded values, #2852) and S4 (`swarm_metadata.rs`, the no-change files, the mutation run, the manual checks, #2864) are merged; the issue is closed. Unit-only lines 60.56% → 94.07%. Findings F1 (fixed through #2811), F2 (fixed in S1), F3 (#2804), F4 (#2823), F6 (#2838, #2850) and F5 (draft spec PR #2865) have owners. | -| 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. | +| 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` | IN_PROGRESS | Bug found by the #2824 primitives tests work. Fixed by the standalone issue #2850 (`docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md`): its implementation PR #2872 (open) closes this issue on merge; 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. | ## Package Coverage Tracking @@ -351,6 +351,7 @@ For each subissue implementation, the completion policy is: - 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. - 2026-11-15 21:07 UTC - Claude Code - #2824 closed by #2864 (merged 2026-11-15 21:05 UTC); row 11 set to `DONE` and the spec archived to `docs/issues/closed/2824-1347-add-tests-primitives/`. +- 2026-11-15 21:40 UTC - Claude Code (Opus 5.5) - Row 12 (#2838): the fix is the implementation of the standalone issue #2850, PR #2872 (open), which closes #2838 on merge. It removes the `primitives` test that pinned a negative `left` as a seeder (finding F6 of #2824) and the `-1` rows of the role table. ## Acceptance Criteria diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md index 7469a3bead..38fbfef76d 100644 --- a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md @@ -2,14 +2,14 @@ schema-version: 1 doc-type: issue issue-type: bug -status: blocked +status: in-progress priority: p2 epic: 1347 github-issue: 2838 spec-path: docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md branch: "2838-udp-reject-negative-announce-bytes" -related-pr: null -last-updated-utc: "2026-11-12 19:55" +related-pr: 2872 +last-updated-utc: "2026-11-15 21:40" semantic-links: skill-links: - create-issue @@ -28,7 +28,9 @@ semantic-links: > The bug is fixed at its root by > [issue #2850](../2850-non-negative-number-of-bytes/ISSUE.md), whose implementation closes this > issue. The analysis, the field audit, the client evidence and the reproduction evidence below -> stay valid and are used by that issue. +> stay valid and are used by that issue. Its implementation is PR #2872 (2026-11-15), and its +> like-for-like recheck is in the +> [manual verification evidence of #2850](../2850-non-negative-number-of-bytes/manual-verification-evidence.md). ## Goal @@ -210,6 +212,7 @@ Follows [fix-bug](../../../../.github/skills/dev/debugging/fix-bug/SKILL.md): - 2026-11-12 09:15 UTC - Claude Code (Claude Sonnet 5.5) - Maintainer approved all three fields; issue #2838 created; fix, tests and recheck done. - 2026-11-12 16:40 UTC - Claude Code (Claude Fable 5.2) - Review round 1 on PR #2839 addressed: typed field enum, `BadRequest` event classification, placement tests, exact-variant handler test, V2 repeated on the committed tree. The maintainer accepted the service-level check as a tactical patch; a follow-up EPIC (draft, no issue yet) will make the domain byte count non-negative by construction. - 2026-11-12 17:41 UTC - Claude Code (Fable 5.2) - The maintainer decided not to merge the tactical patch of PR #2839. The bug is fixed at its root by issue #2850 (`docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md`), whose implementation closes this issue. This specification and its evidence were carried over from the branch of PR #2839 as the record of the analysis, the reproduction and the client evidence. Its implementation plan and commit points describe the patch and are superseded; the tests of that branch are taken over by #2850. +- 2026-11-15 21:40 UTC - Claude Code (Opus 5.5) - The implementation of #2850 is PR #2872, which closes this issue on merge. It took over the red handler test, the `peer_builder` rejection and acceptance cases, the order tests and the `BadRequest` classification test of PR #2839, adapted to the conversion error `FromRequestError`. The UDP recheck with the probe of this folder is section V1 of the #2850 manual verification evidence: `left = -5` now gets ``tracker announce error: Invalid announce request: `left` must not be negative, got -5`` with its transaction id, and no peer is stored. ## Acceptance Criteria diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md index dfc2423c2b..29aedac8d8 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md @@ -8,8 +8,8 @@ epic: null github-issue: 2850 spec-path: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md branch: "2850-non-negative-number-of-bytes" -related-pr: null -last-updated-utc: "2026-11-15 21:25" +related-pr: 2872 +last-updated-utc: "2026-11-15 21:40" semantic-links: skill-links: - create-issue @@ -716,6 +716,7 @@ the model that produced them. - 2026-11-12 17:40 UTC - Claude Code (Fable 5.2) - The maintainer approved the plan: this issue is the fix for #2838 and replaces the patch of PR #2839, and the ADR of #2842 is delivered by this issue's spec-only pull request instead of PR #2843. Created issue #2850, moved the specification to `docs/issues/open/`, carried over the four ADR commits and the specification and evidence of #2838, and rewrote D3, D5, D6, the bug-fix process and the coordination for that plan. The two other sessions were told and close their pull requests. - 2026-11-12 20:29 UTC - Claude Code (Fable 5.2) - Rebased the spec-only branch onto `develop` after PR #2841 (the primitives tests of #2824) merged and conflicted in the EPIC #1347 table. Updated the coordination note: those tests are on `develop` and name this issue. - 2026-11-15 21:25 UTC - Claude Code (Opus 5.5) - Implemented T0 to T6 on branch `2850-non-negative-number-of-bytes`. T0 added `udp_tracker/announce_once`; the first baseline was discarded because uncommitted T1/T2 edits leaked into its build, and each measurement is now built in a clean worktree (`performance-evidence.md`, lesson added to `docs/benchmarking.md`). T2 named the field with the `ByteCountField` enum (one variant, one message, the field as a matchable value) and moved the peer conversion before the whitelist check, as the order tests of PR #2839 require. The maintainer agreed a 5% tolerance for the UDP benchmark before the after measurement. Load test and UDP pass; HTTP `announce_once` failed the one-sided rule by 0.3% on a path T3 does not add work to, and an interleaved A/B run put it inside the noise: the verdict is the maintainer's. Manual run 1 was discarded for non-monotonic timestamps. No design assumption was invalidated, so no retrospective file. +- 2026-11-15 21:40 UTC - Claude Code (Opus 5.5) - Rebased onto `develop` and opened the implementation PR #2872 (closes #2850 and #2838). Updated the #2838 specification and row 12 of the EPIC #1347 table to point to it. ## Acceptance Criteria From 8344a0d0d14dbeb88bb59ef795bc75c67ab427e7 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 07:50:28 +0000 Subject: [PATCH 14/28] test: [#2850] pin that a number of bytes cannot be built from a signed integer Add compile-fail doctests to the domain and the HTTP protocol `NumberOfBytes`: one passes an `i64` to `new` (E0308) and one uses the tuple constructor from outside the crate (E0423). The HTTP type also gets a doctest of a successful construction. Making the field public fails the tuple-constructor doctest. Addresses review findings F1 and F2 of PR #2872. Co-Authored-By: Claude Opus 5.5 --- .../http-protocol/src/v1/requests/announce.rs | 27 +++++++++++++++++++ packages/primitives/src/number_of_bytes.rs | 18 +++++++++++++ 2 files changed, 45 insertions(+) diff --git a/packages/http-protocol/src/v1/requests/announce.rs b/packages/http-protocol/src/v1/requests/announce.rs index bf779cbca3..a977afe2dc 100644 --- a/packages/http-protocol/src/v1/requests/announce.rs +++ b/packages/http-protocol/src/v1/requests/announce.rs @@ -40,6 +40,33 @@ const IP: &str = "ip"; // BEP 3 gives the byte counts no width and no sign, so a `u64` holds every // value the parser accepts and a negative count cannot be represented. // adr: docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md +/// A byte count of an announce request: `uploaded`, `downloaded` or `left`. +/// +/// ```rust +/// use torrust_tracker_http_protocol::v1::requests::announce::NumberOfBytes; +/// +/// let left = NumberOfBytes::new(16_384); +/// +/// assert_eq!(left.get(), 16_384); +/// ``` +/// +/// The constructor takes no signed integer: +/// +/// ```rust,compile_fail,E0308 +/// use torrust_tracker_http_protocol::v1::requests::announce::NumberOfBytes; +/// +/// let signed: i64 = -1; +/// let _left = NumberOfBytes::new(signed); +/// ``` +/// +/// and the field is private, so code outside this crate cannot build the +/// value with the tuple constructor: +/// +/// ```rust,compile_fail,E0423 +/// use torrust_tracker_http_protocol::v1::requests::announce::NumberOfBytes; +/// +/// let _left = NumberOfBytes(16_384); +/// ``` #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] pub struct NumberOfBytes(u64); diff --git a/packages/primitives/src/number_of_bytes.rs b/packages/primitives/src/number_of_bytes.rs index 4521a21c95..f2dce41efc 100644 --- a/packages/primitives/src/number_of_bytes.rs +++ b/packages/primitives/src/number_of_bytes.rs @@ -12,6 +12,24 @@ /// /// assert_eq!(left.get(), 16_384); /// ``` +/// +/// The constructor takes no signed integer: +/// +/// ```rust,compile_fail,E0308 +/// use torrust_tracker_primitives::NumberOfBytes; +/// +/// let signed: i64 = -1; +/// let _left = NumberOfBytes::new(signed); +/// ``` +/// +/// and the field is private, so code outside this crate cannot build the +/// value with the tuple constructor: +/// +/// ```rust,compile_fail,E0423 +/// use torrust_tracker_primitives::NumberOfBytes; +/// +/// let _left = NumberOfBytes(16_384); +/// ``` // adr: docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] pub struct NumberOfBytes(u64); From b2bcae0445088809bcf788c483a8114c389fd33b Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 07:55:10 +0000 Subject: [PATCH 15/28] docs(pr-reviews): [#2850] audit review round 1 of PR #2872 Record Copilot's review 5916561572: F1 and F2 ask for compile-fail doctests of the domain and HTTP `NumberOfBytes` construction boundary. Both are fixed, replied to and resolved. Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 122 ++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 docs/pr-reviews/pr-2872-review/PR-REVIEW.md diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md new file mode 100644 index 0000000000..e62769e162 --- /dev/null +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -0,0 +1,122 @@ +--- +semantic-links: + skill-links: + - process-pr-review + related-artifacts: + - .github/skills/dev/pr-reviews/process-pr-review/SKILL.md +--- + +# PR #2872 Review Audit + +Source: pull-request reviews and inline review threads for https://github.com/torrust/torrust-tracker/pull/2872. + +## 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 Copilot's review `5916561572` (commented, "Changes recommended") at the head whose last +commit is `docs(issues): [#2850] point #2838 and the EPIC #1347 table to PR #2872`. Its two inline +findings keep the reviewer's IDs F1 and F2; the review body only summarizes them. + +| Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | +| ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | +| F1 | review-finding:pr-2872-f1 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | +| F2 | review-finding:pr-2872-f2 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | + +## Finding Details + +### F1 - The domain `NumberOfBytes` has no compile-fail test of its construction boundary + +- PR number: 2872 +- Source review ID: 5916561572 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583142394 +- Concern: the positive doctest and the UDP rejection tests would still pass if the field of + `torrust_tracker_primitives::NumberOfBytes` became public or a signed constructor were added, so + nothing pins AC1 for this type. Add compile-fail doctests for a signed argument and for the + tuple constructor, next to the existing successful example. +- Solution: added two doctests to `packages/primitives/src/number_of_bytes.rs`: + `compile_fail,E0308` passes an `i64` to `NumberOfBytes::new`, and `compile_fail,E0423` builds + the value with the tuple constructor from outside the crate. The existing successful example + stays first. +- Current-tree verification: `cargo test --doc -p torrust-tracker-primitives number_of_bytes` + ran 3 doctests, all passed. With the field changed to `pub u64` for a moment, the same command + reported the tuple-constructor doctest as `FAILED`; the file was then restored. +- Resolution reference: test: [#2850] pin that a number of bytes cannot be built from a signed integer +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583186952 + +### F2 - The HTTP `NumberOfBytes` has no compile-fail test of its construction boundary + +- PR number: 2872 +- Source review ID: 5916561572 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583142335 +- Concern: the new HTTP range tests exercise query parsing inside the module, so they cannot detect + a tuple constructor exposed to other crates, and they do not pin the refusal of a signed + constructor argument. Add compile-fail doctests for both, plus a successful unsigned + construction example. +- Solution: added a doc comment to `NumberOfBytes` in + `packages/http-protocol/src/v1/requests/announce.rs` with a successful construction doctest, a + `compile_fail,E0308` doctest that passes an `i64` to `new`, and a `compile_fail,E0423` doctest + that uses the tuple constructor from outside the crate. +- Current-tree verification: `cargo test --doc -p torrust-tracker-http-protocol NumberOfBytes` ran + 3 doctests, all passed; the pre-commit hook's `cargo test --doc --workspace` passed. +- Resolution reference: test: [#2850] pin that a number of bytes cannot be built from a signed integer +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583187197 + +## Processing Log + +- 2026-11-16 07:51 UTC - Started this audit for Copilot's review `5916561572` (submitted + 2026-11-16T07:47:32Z), before any reply. The fix for F1 and F2 is one commit, because the two + findings ask for the same doctests on the two types. +- 2026-11-16 07:54 UTC - Round 1 processed. The fix was pushed by `git-bot-push` (head + `test: [#2850] pin that a number of bytes cannot be built from a signed integer`); each of the + two threads has a reply (posted 2026-11-16T07:54 UTC) and was resolved (`isResolved: true`); a + fresh GraphQL fetch shows 0 unresolved threads. `validate-audit-record.py --pr-number 2872` + returned `status: ok`, 2 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. From 1d7d9a81378c51c3daebbf3f467f2ff515a8b099 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:12:56 +0000 Subject: [PATCH 16/28] docs(issues): [#2850] set each stamp to no later than its own commit The progress-log entries and `last-updated-utc` stamps added on 2026-11-15 were later than the commits that carry them: 21:40 for opening PR #2872 (opened at 21:22), 21:25 and 21:20 for the after measurement (committed at 21:17), and 21:05 for the manual verification (committed at 21:04). Set each to the time of its event. Addresses review finding F2 of da2ce7 on PR #2872. Co-Authored-By: Claude Opus 5.5 --- docs/issues/open/1347-overhaul-packages-testing/EPIC.md | 4 ++-- .../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md | 4 ++-- .../open/2850-non-negative-number-of-bytes/ISSUE.md | 8 ++++---- .../manual-verification-evidence.md | 2 +- .../performance-evidence.md | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/issues/open/1347-overhaul-packages-testing/EPIC.md b/docs/issues/open/1347-overhaul-packages-testing/EPIC.md index e3f2932cb4..c6d92246eb 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-15 21:40" +last-updated-utc: "2026-11-15 21:22" semantic-links: skill-links: - create-issue @@ -351,7 +351,7 @@ For each subissue implementation, the completion policy is: - 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. - 2026-11-15 21:07 UTC - Claude Code - #2824 closed by #2864 (merged 2026-11-15 21:05 UTC); row 11 set to `DONE` and the spec archived to `docs/issues/closed/2824-1347-add-tests-primitives/`. -- 2026-11-15 21:40 UTC - Claude Code (Opus 5.5) - Row 12 (#2838): the fix is the implementation of the standalone issue #2850, PR #2872 (open), which closes #2838 on merge. It removes the `primitives` test that pinned a negative `left` as a seeder (finding F6 of #2824) and the `-1` rows of the role table. +- 2026-11-15 21:22 UTC - Claude Code (Opus 5.5) - Row 12 (#2838): the fix is the implementation of the standalone issue #2850, PR #2872 (open), which closes #2838 on merge. It removes the `primitives` test that pinned a negative `left` as a seeder (finding F6 of #2824) and the `-1` rows of the role table. ## Acceptance Criteria diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md index 38fbfef76d..e5f7a2841e 100644 --- a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2838 spec-path: docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md branch: "2838-udp-reject-negative-announce-bytes" related-pr: 2872 -last-updated-utc: "2026-11-15 21:40" +last-updated-utc: "2026-11-15 21:22" semantic-links: skill-links: - create-issue @@ -212,7 +212,7 @@ Follows [fix-bug](../../../../.github/skills/dev/debugging/fix-bug/SKILL.md): - 2026-11-12 09:15 UTC - Claude Code (Claude Sonnet 5.5) - Maintainer approved all three fields; issue #2838 created; fix, tests and recheck done. - 2026-11-12 16:40 UTC - Claude Code (Claude Fable 5.2) - Review round 1 on PR #2839 addressed: typed field enum, `BadRequest` event classification, placement tests, exact-variant handler test, V2 repeated on the committed tree. The maintainer accepted the service-level check as a tactical patch; a follow-up EPIC (draft, no issue yet) will make the domain byte count non-negative by construction. - 2026-11-12 17:41 UTC - Claude Code (Fable 5.2) - The maintainer decided not to merge the tactical patch of PR #2839. The bug is fixed at its root by issue #2850 (`docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md`), whose implementation closes this issue. This specification and its evidence were carried over from the branch of PR #2839 as the record of the analysis, the reproduction and the client evidence. Its implementation plan and commit points describe the patch and are superseded; the tests of that branch are taken over by #2850. -- 2026-11-15 21:40 UTC - Claude Code (Opus 5.5) - The implementation of #2850 is PR #2872, which closes this issue on merge. It took over the red handler test, the `peer_builder` rejection and acceptance cases, the order tests and the `BadRequest` classification test of PR #2839, adapted to the conversion error `FromRequestError`. The UDP recheck with the probe of this folder is section V1 of the #2850 manual verification evidence: `left = -5` now gets ``tracker announce error: Invalid announce request: `left` must not be negative, got -5`` with its transaction id, and no peer is stored. +- 2026-11-15 21:22 UTC - Claude Code (Opus 5.5) - The implementation of #2850 is PR #2872, which closes this issue on merge. It took over the red handler test, the `peer_builder` rejection and acceptance cases, the order tests and the `BadRequest` classification test of PR #2839, adapted to the conversion error `FromRequestError`. The UDP recheck with the probe of this folder is section V1 of the #2850 manual verification evidence: `left = -5` now gets ``tracker announce error: Invalid announce request: `left` must not be negative, got -5`` with its transaction id, and no peer is stored. ## Acceptance Criteria diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md index 29aedac8d8..75ed6bbd04 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2850 spec-path: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md branch: "2850-non-negative-number-of-bytes" related-pr: 2872 -last-updated-utc: "2026-11-15 21:40" +last-updated-utc: "2026-11-15 21:22" semantic-links: skill-links: - create-issue @@ -715,8 +715,8 @@ the model that produced them. - 2026-11-12 17:32 UTC - Claude Code (Fable 5.2) - The maintainer decided that one issue is enough (D6). Merged the EPIC draft and the two sub-issue drafts into this single issue specification; nothing was dropped from the research, the decisions or the source map. Not approved; no GitHub issue created. - 2026-11-12 17:40 UTC - Claude Code (Fable 5.2) - The maintainer approved the plan: this issue is the fix for #2838 and replaces the patch of PR #2839, and the ADR of #2842 is delivered by this issue's spec-only pull request instead of PR #2843. Created issue #2850, moved the specification to `docs/issues/open/`, carried over the four ADR commits and the specification and evidence of #2838, and rewrote D3, D5, D6, the bug-fix process and the coordination for that plan. The two other sessions were told and close their pull requests. - 2026-11-12 20:29 UTC - Claude Code (Fable 5.2) - Rebased the spec-only branch onto `develop` after PR #2841 (the primitives tests of #2824) merged and conflicted in the EPIC #1347 table. Updated the coordination note: those tests are on `develop` and name this issue. -- 2026-11-15 21:25 UTC - Claude Code (Opus 5.5) - Implemented T0 to T6 on branch `2850-non-negative-number-of-bytes`. T0 added `udp_tracker/announce_once`; the first baseline was discarded because uncommitted T1/T2 edits leaked into its build, and each measurement is now built in a clean worktree (`performance-evidence.md`, lesson added to `docs/benchmarking.md`). T2 named the field with the `ByteCountField` enum (one variant, one message, the field as a matchable value) and moved the peer conversion before the whitelist check, as the order tests of PR #2839 require. The maintainer agreed a 5% tolerance for the UDP benchmark before the after measurement. Load test and UDP pass; HTTP `announce_once` failed the one-sided rule by 0.3% on a path T3 does not add work to, and an interleaved A/B run put it inside the noise: the verdict is the maintainer's. Manual run 1 was discarded for non-monotonic timestamps. No design assumption was invalidated, so no retrospective file. -- 2026-11-15 21:40 UTC - Claude Code (Opus 5.5) - Rebased onto `develop` and opened the implementation PR #2872 (closes #2850 and #2838). Updated the #2838 specification and row 12 of the EPIC #1347 table to point to it. +- 2026-11-15 21:17 UTC - Claude Code (Opus 5.5) - Implemented T0 to T6 on branch `2850-non-negative-number-of-bytes`. T0 added `udp_tracker/announce_once`; the first baseline was discarded because uncommitted T1/T2 edits leaked into its build, and each measurement is now built in a clean worktree (`performance-evidence.md`, lesson added to `docs/benchmarking.md`). T2 named the field with the `ByteCountField` enum (one variant, one message, the field as a matchable value) and moved the peer conversion before the whitelist check, as the order tests of PR #2839 require. The maintainer agreed a 5% tolerance for the UDP benchmark before the after measurement. Load test and UDP pass; HTTP `announce_once` failed the one-sided rule by 0.3% on a path T3 does not add work to, and an interleaved A/B run put it inside the noise: the verdict is the maintainer's. Manual run 1 was discarded for non-monotonic timestamps. No design assumption was invalidated, so no retrospective file. +- 2026-11-15 21:22 UTC - Claude Code (Opus 5.5) - Rebased onto `develop` and opened the implementation PR #2872 (closes #2850 and #2838). Updated the #2838 specification and row 12 of the EPIC #1347 table to point to it. ## Acceptance Criteria @@ -879,7 +879,7 @@ After implementation, compare the result with this specification. Record invalidated assumptions, material design changes, unexpected validation findings, and reusable lessons. -- Retrospective: not needed; see the progress log entry of 2026-11-15 21:25 UTC. The design held as specified; the discoveries were about measurement, recorded in `performance-evidence.md` and in `docs/benchmarking.md`. +- Retrospective: not needed; see the progress log entry of 2026-11-15 21:17 UTC. The design held as specified; the discoveries were about measurement, recorded in `performance-evidence.md` and in `docs/benchmarking.md`. - If needed, create `implementation-retrospective.md` from the repository template at `docs/templates/IMPLEMENTATION-RETROSPECTIVE.md` in this issue specification's directory. diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md index 732649ea5c..a316f5509f 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -last-updated-utc: "2026-11-15 21:05" +last-updated-utc: "2026-11-15 21:04" --- # Manual Verification Evidence diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md index 483a46f923..a225211bc6 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md @@ -1,7 +1,7 @@ --- doc-type: performance-evidence issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -last-updated-utc: "2026-11-15 21:20" +last-updated-utc: "2026-11-15 21:17" --- # Performance Evidence - Non-Negative Number of Bytes From 35212e9c7e3fdf9899fb57019213177c44a90c21 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:14:48 +0000 Subject: [PATCH 17/28] chore(cspell): [#2850] ignore the bencode fragment `peerslee` per file `peerslee` is `5:peers`, an empty list and the closing `e` of a bencoded announce response, not a term, so it leaves the project dictionary. The manual verification record ignores it with a spelling directive, as the #1349 record does, and the raw captures under the issue's `evidence/` folder are ignored by path. Addresses review finding F3 of da2ce7 on PR #2872. Co-Authored-By: Claude Opus 5.5 --- cspell.json | 1 + .../manual-verification-evidence.md | 2 +- project-words.txt | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cspell.json b/cspell.json index 6615fff9a1..1b5320c24f 100644 --- a/cspell.json +++ b/cspell.json @@ -23,6 +23,7 @@ "contrib/bencode/benches/*.bencode", "contrib/dev-tools/su-exec/**", "packages/tracker-core/docs/benchmarking/machine/*.txt", + "docs/issues/*/2850-non-negative-number-of-bytes/evidence/*.txt", ".github/labels.json", "/project-words.txt", "repomix-output.xml", diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md index a316f5509f..a031580939 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md @@ -6,7 +6,7 @@ last-updated-utc: "2026-11-15 21:04" # Manual Verification Evidence - + ## Purpose diff --git a/project-words.txt b/project-words.txt index 11a6fc4819..2541c5a5ff 100644 --- a/project-words.txt +++ b/project-words.txt @@ -435,7 +435,6 @@ pathspecs peekable peerlist peersld -peerslee penalise pessimize pgrep From 4baddaf370a2eda8c2d81276fe4215db48fa2eb5 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:15:23 +0000 Subject: [PATCH 18/28] docs(issues): [#2850] drop the removed overflow variant from the SI-3 draft The SI-3 draft maps `ParseAnnounceQueryError` variants to source lines. `NumberOfBytesOverflow` no longer exists, so drop it, and point the three remaining variants at their current lines (219, 221 and 227). Addresses review finding F4 of da2ce7 on PR #2872. Co-Authored-By: Claude Opus 5.5 --- .../error-locations-si-3-http-tracker-request-errors/ISSUE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md b/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md index 6ac6e48d61..1f87e856ff 100644 --- a/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md +++ b/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md @@ -9,7 +9,7 @@ github-issue: null spec-path: docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md branch: "{issue-number}-error-locations-si-3-http-tracker-request-errors" related-pr: null -last-updated-utc: "2026-11-11 17:39" +last-updated-utc: "2026-11-16 08:14" semantic-links: skill-links: - create-issue @@ -51,7 +51,7 @@ Variants that print `{location}` (11, `options.md` fact 1): | File | Variants | | --- | --- | | `http-protocol/src/v1/query.rs:103` | `ParseQueryError::InvalidParam` | -| `http-protocol/src/v1/requests/announce.rs:182`, `:184`, `:190`, `:197` | `ParseAnnounceQueryError::{MissingParams, MissingParam, InvalidParam, NumberOfBytesOverflow}` | +| `http-protocol/src/v1/requests/announce.rs:219`, `:221`, `:227` | `ParseAnnounceQueryError::{MissingParams, MissingParam, InvalidParam}` | | `http-protocol/src/v1/requests/scrape.rs:41`, `:43` | `ParseScrapeQueryError::{MissingParams, MissingParam}` | | `http-protocol/src/v1/services/peer_ip_resolver.rs:117-120`, `:125` | `PeerIpResolutionError::{MissingRightMostXForwardedForIp, MissingClientIp}` (three-line attribute at `:117`) | | `http-protocol/src/v1/auth.rs:13`, `:16` | `auth::Error::{InvalidKeyFormat, CannotExtractKeyParam}` | From 46991b20cad59b3374ba6bccd36308e51d475145 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:17:38 +0000 Subject: [PATCH 19/28] docs(issues): [#2850] record the red and green runs of the regression tests The manual verification record now holds the failing run of the handler test at its red commit, built in a clean worktree, and the passing runs of every regression test of the fix at the branch head, with commands, toolchain and output. The raw outputs are in the issue's `evidence/` folder. Addresses review finding F1 of da2ce7 on PR #2872. Co-Authored-By: Claude Opus 5.5 --- .../evidence/regression-green-run.txt | 99 +++++++++++++++++++ .../evidence/regression-red-run.txt | 23 +++++ .../manual-verification-evidence.md | 49 ++++++++- 3 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-green-run.txt create mode 100644 docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-red-run.txt diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-green-run.txt b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-green-run.txt new file mode 100644 index 0000000000..e7708b637d --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-green-run.txt @@ -0,0 +1,99 @@ +rustc 1.99.1 (58cf8f9c3 2026-10-13) +start 2026-11-16 08:16:11 UTC +$ cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left +running 1 test +test handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 225 filtered out; finished in 0.02s +$ cargo test -p torrust-tracker-udp-server --lib it_should_classify_a_negative_number_of_bytes_in_an_announce_as_a_bad_request +running 1 test +test event::tests::it_should_classify_a_negative_number_of_bytes_in_an_announce_as_a_bad_request ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 225 filtered out; finished in 0.00s +$ cargo test -p torrust-tracker-udp-core --lib number_of_bytes +running 9 tests +test peer_builder::tests::it_should_accept_a_non_negative_number_of_bytes_left::case_1_zero ... ok +test peer_builder::tests::it_should_accept_a_non_negative_number_of_bytes_left::case_3_unknown_size_of_transmission ... ok +test peer_builder::tests::it_should_accept_a_non_negative_number_of_bytes_left::case_2_unknown_size_of_libtorrent ... ok +test peer_builder::tests::it_should_reject_a_negative_number_of_bytes::case_1_left ... ok +test peer_builder::tests::it_should_reject_a_negative_number_of_bytes::case_2_left_min ... ok +test peer_builder::tests::it_should_reject_a_negative_number_of_bytes::case_4_downloaded ... ok +test peer_builder::tests::it_should_reject_a_negative_number_of_bytes::case_3_uploaded ... ok +test services::announce::tests::it_should_validate_the_connection_id_before_the_number_of_bytes ... ok +test services::announce::tests::it_should_reject_a_negative_number_of_bytes_before_revealing_whether_the_torrent_is_whitelisted ... ok +test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 99 filtered out; finished in 0.00s +$ cargo test -p torrust-tracker-udp-core --lib it_should_validate_the_connection_id_before_the_number_of_bytes +running 1 test +test services::announce::tests::it_should_validate_the_connection_id_before_the_number_of_bytes ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 107 filtered out; finished in 0.00s +$ cargo test -p torrust-tracker-udp-core --lib it_should_reject_a_negative_number_of_bytes_before_revealing_whether_the_torrent_is_whitelisted +running 1 test +test services::announce::tests::it_should_reject_a_negative_number_of_bytes_before_revealing_whether_the_torrent_is_whitelisted ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 107 filtered out; finished in 0.00s +$ cargo test -p torrust-tracker-primitives --lib peer +running 43 tests +test peer::test::peer_id::it_should_be_converted_from_exactly_twenty_bytes_keeping_the_bytes ... ok +test peer::test::peer::should_be_comparable ... ok +test peer::test::peer_id::it_should_be_created_from_a_peer_id ... ok +test peer::test::peer_id::it_should_know_the_client_that_generated_a_registered_peer_id_prefix ... ok +test peer::test::peer_id::it_should_give_mutable_access_to_the_peer_id_bytes ... ok +test peer::test::peer_collection::it_should_collect_peers_into_a_vector_of_their_encoding_in_order ... ok +test announce::tests::announce_data::it_should_default_to_no_peers_empty_statistics_and_the_default_policy ... ok +test peer::test::peer_id_encoding::it_should_reject_any_byte_vector_whose_length_is_not_twenty ... ok +test peer::test::peer_state::it_should_be_a_seeder_when_it_has_no_bytes_left_to_download ... ok +test peer::test::peer_serialization::it_should_serialize_every_field_in_its_json_form ... ok +test peer::test::peer_role::it_should_have_the_seeder_as_the_opposite_of_the_leecher ... ok +test peer::test::peer_role::it_should_be_parsed_from_its_lowercase_name ... ok +test peer::test::peer_state::read_info::it_should_expose_the_peer_state_through_the_read_info_trait ... ok +test peer::test::torrent_peer_id::should_fail_trying_to_convert_from_a_byte_vector_with_less_than_20_bytes - should panic ... ok +test peer::test::peer_state::it_should_be_completed_only_when_its_last_event_is_completed ... ok +test peer::test::unix_time_value_serialization::it_should_serialize_the_largest_timestamp_that_fits_in_u64_milliseconds ... ok +test peer::test::torrent_peer_id::should_fail_trying_to_convert_from_a_byte_vector_with_more_than_20_bytes - should panic ... ok +test peer::test::peer_state::it_should_be_marked_as_completed_without_changing_anything_else ... ok +test peer::test::peer_state::it_should_be_converted_into_a_seeder_without_changing_anything_else ... ok +test peer::test::peer_role_serialization::it_should_serialize_a_seeder_in_lowercase_like_its_display_format ... ok +test peer::test::peer_id::it_should_not_know_the_client_of_an_unregistered_peer_id_prefix ... ok +test peer::test::torrent_peer_id::should_be_converted_to_hex_string ... ok +test policy::tests::it_should_keep_the_given_peer_timeout_and_default_the_rest ... ok +test peer::test::peer_state::read_info::it_should_expose_the_peer_state_through_the_read_info_trait_of_a_shared_peer ... ok +test peer::test::peer_state::read_info::it_should_classify_the_role_through_the_read_info_trait_like_the_peer_does ... ok +test peer::test::peer_state::it_should_be_a_leecher_when_it_has_bytes_left_to_download ... ok +test peer::test::peer_role::it_should_be_parsed_ignoring_the_case_of_its_name ... ok +test peer::test::torrent_peer_id::should_be_converted_into_string_type_using_the_hex_string_format ... ok +test peer::test::peer_role::it_should_fail_to_parse_a_name_that_is_not_a_role_and_report_the_rejected_text ... ok +test peer::test::peer_state::it_should_be_a_leecher_when_it_has_stopped_even_with_no_bytes_left_to_download ... ok +test peer::test::unix_time_value_serialization::it_should_fail_instead_of_truncating_a_timestamp_beyond_u64_milliseconds ... ok +test peer::test::peer_serialization::it_should_serialize_the_none_announce_event_as_its_name ... ok +test peer::test::peer_state::it_should_keep_its_port_when_its_ip_address_changes ... ok +test peer::test::peer_id::it_should_serialize_an_unknown_client_as_null ... ok +test peer::test::peer_id_encoding::it_should_encode_any_twenty_bytes_as_a_hex_string_with_the_0x_prefix ... ok +test peer::test::peer_role::it_should_have_the_leecher_as_the_opposite_of_the_seeder ... ok +test peer::test::unix_time_value_serialization::it_should_serialize_the_timestamp_as_unix_milliseconds ... ok +test peer::test::peer_serialization::it_should_serialize_the_stopped_announce_event_as_its_name ... ok +test peer::test::peer_role_serialization::it_should_serialize_a_leecher_in_lowercase_like_its_display_format ... ok +test peer::test::peer_id::it_should_serialize_the_hex_string_and_the_client_name ... ok +test peer::test::peer_state::it_should_be_converted_into_a_completed_peer_without_changing_anything_else ... ok +test peer::test::peer_state::it_should_be_a_seeder_when_it_has_completed_the_download ... ok +test peer::test::peer_serialization::it_should_serialize_the_started_announce_event_as_its_name ... ok +test result: ok. 43 passed; 0 failed; 0 ignored; 0 measured; 65 filtered out; finished in 0.01s +$ cargo test -p torrust-tracker-http-protocol --lib when_a_number_of_bytes_param_is_parsed +running 15 tests +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_accept_the_largest_unsigned_64_bit_value::case_2_uploaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_accept_zero::case_1_downloaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_accept_the_largest_unsigned_64_bit_value::case_1_downloaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_accept_zero::case_2_uploaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_accept_the_largest_unsigned_64_bit_value::case_3_left ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_negative_value::case_1_downloaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_negative_value::case_2_uploaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_accept_zero::case_3_left ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_negative_value::case_3_left ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_non_numeric_value::case_1_downloaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_non_numeric_value::case_2_uploaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_non_numeric_value::case_3_left ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_value_above_the_largest_unsigned_64_bit_value::case_1_downloaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_value_above_the_largest_unsigned_64_bit_value::case_2_uploaded ... ok +test v1::requests::announce::tests::announce_request::when_a_number_of_bytes_param_is_parsed::it_should_reject_a_value_above_the_largest_unsigned_64_bit_value::case_3_left ... ok +test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 57 filtered out; finished in 0.00s +$ cargo test -p torrust-tracker-axum-http-server --test integration should_accept_a_number_of_bytes_left_above_the_largest_signed_64_bit_value +running 1 test +test server::v1::contract::for_all_config_modes::receiving_an_announce_request::should_accept_a_number_of_bytes_left_above_the_largest_signed_64_bit_value ... ok +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 62 filtered out; finished in 1.03s +end 2026-11-16 08:16:38 UTC diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-red-run.txt b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-red-run.txt new file mode 100644 index 0000000000..280d068d84 --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/evidence/regression-red-run.txt @@ -0,0 +1,23 @@ + Finished `test` profile [optimized + debuginfo] target(s) in 35.59s + Running unittests src/lib.rs (../perf-2850/baseline-src/target/debug/deps/torrust_tracker_udp_server-ca95c22c02df2f30) + +running 1 test +test handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left ... FAILED + +failures: + +---- handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left stdout ---- + +thread 'handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left' (1294794) panicked at packages/udp-server/src/handlers/announce.rs:595:17: +a negative `left` must be rejected, got: Ok(AnnounceIpv4(AnnounceResponse { fixed: AnnounceResponseFixedData { transaction_id: TransactionId(I32(0)), announce_interval: AnnounceInterval(I32(120)), leechers: NumberOfPeers(I32(0)), seeders: NumberOfPeers(I32(1)) }, peers: [] })) +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace + + +failures: + handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 224 filtered out; finished in 0.04s + +error: test failed, to rerun pass `-p torrust-tracker-udp-server --lib` +exit=101 +end 2026-11-16 08:16:41 UTC diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md index a031580939..a128bd4eaf 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -last-updated-utc: "2026-11-15 21:04" +last-updated-utc: "2026-11-16 08:17" --- # Manual Verification Evidence @@ -194,6 +194,53 @@ after `SIGTERM`. numbers; that already held for large `i64` values (see the specification, "Risks and Trade-offs"). +## Regression Tests: Red and Green Runs + +The fix-bug process records the failing run of the maintained regression test before the fix and +the passing runs after it. Both runs were made on 2026-11-16 with `rustc 1.99.1 (58cf8f9c3 +2026-10-13)` and `cargo 1.99.1`, debug test profile. + +### Red: the handler test before the fix + +- Commit: `test(udp-server): [#2850] reject a negative left in an announce (red)`, checked out in + its own detached `git worktree` (no local edits), the commit right before + `fix(udp-core)!: [#2850] refuse a negative byte count in the wire-to-domain conversion`. +- Command: + + ```sh + cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left + ``` + +- Output (08:16:06 to 08:16:41 UTC, full text in + [`evidence/regression-red-run.txt`](evidence/regression-red-run.txt)): the test `FAILED` with + exit code 101, and the panic shows the bug of #2838, a negative `left` counted as a seeder: + + ```text + a negative `left` must be rejected, got: Ok(AnnounceIpv4(AnnounceResponse { fixed: AnnounceResponseFixedData { transaction_id: TransactionId(I32(0)), announce_interval: AnnounceInterval(I32(120)), leechers: NumberOfPeers(I32(0)), seeders: NumberOfPeers(I32(1)) }, peers: [] })) + ``` + +- The fix commit then also tightened this test to match the exact error, the transaction id and + the request kind; that final form is the one of the green run. + +### Green: the regression tests after the fix + +- Commit: the branch head with + `docs(issues): [#2850] drop the removed overflow variant from the SI-3 draft` as its last + commit, which includes every production change. +- Commands and output (08:16:11 to 08:16:38 UTC, full text in + [`evidence/regression-green-run.txt`](evidence/regression-green-run.txt)), each `ok`: + + | Command | Result | + | --- | --- | + | `cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left` | 1 passed | + | `cargo test -p torrust-tracker-udp-server --lib it_should_classify_a_negative_number_of_bytes_in_an_announce_as_a_bad_request` | 1 passed | + | `cargo test -p torrust-tracker-udp-core --lib number_of_bytes` | 9 passed (the `peer_builder` cases and the two check-order tests) | + | `cargo test -p torrust-tracker-udp-core --lib it_should_validate_the_connection_id_before_the_number_of_bytes` | 1 passed | + | `cargo test -p torrust-tracker-udp-core --lib it_should_reject_a_negative_number_of_bytes_before_revealing_whether_the_torrent_is_whitelisted` | 1 passed | + | `cargo test -p torrust-tracker-primitives --lib peer` | 43 passed (including the seeder and role-table tests) | + | `cargo test -p torrust-tracker-http-protocol --lib when_a_number_of_bytes_param_is_parsed` | 15 passed | + | `cargo test -p torrust-tracker-axum-http-server --test integration should_accept_a_number_of_bytes_left_above_the_largest_signed_64_bit_value` | 1 passed | + ## Failures and Follow-up - Run 1 (21:01:25 to 21:01:26 UTC), with the same script but only `date -u +%T.%3N` stamps, gave From 43a07abe16fc2128b410b264a329afc4af0a99ba Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:23:25 +0000 Subject: [PATCH 20/28] docs(pr-reviews): [#2850] audit review round 2 of PR #2872 Record da2ce7's review 5916791851 as audit findings F3 to F7 (the reviewer's F1 to F5): the red and green regression runs, the late stamps, the `peerslee` dictionary entry, the stale draft row and the PR description. All five are fixed, replied to and resolved. Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 87 +++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index e62769e162..e00ecfd018 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -8,6 +8,8 @@ semantic-links: # PR #2872 Review Audit + + Source: pull-request reviews and inline review threads for https://github.com/torrust/torrust-tracker/pull/2872. ## Ownership @@ -43,10 +45,20 @@ Round 1 is Copilot's review `5916561572` (commented, "Changes recommended") at t commit is `docs(issues): [#2850] point #2838 and the EPIC #1347 table to PR #2872`. Its two inline findings keep the reviewer's IDs F1 and F2; the review body only summarizes them. +Round 2 is da2ce7's review `5916791851` (approved) at the head whose last commit is +`docs(pr-reviews): [#2850] audit review round 1 of PR #2872`. Its five inline findings are numbered +F1 to F5 by the reviewer; F1 and F2 collide with round 1, so they get the audit IDs F3 to F7 in +source order, with the reviewer's ID kept in each detail entry. The review body only summarizes them. + | Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | | ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | | F1 | review-finding:pr-2872-f1 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | | F2 | review-finding:pr-2872-f2 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | +| F3 | review-finding:pr-2872-f3 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F4 | review-finding:pr-2872-f4 | Human | Minor | metadata | ORIGINAL | FIXED | RESOLVED | +| F5 | review-finding:pr-2872-f5 | Human | Nit | maintainability | ORIGINAL | FIXED | RESOLVED | +| F6 | review-finding:pr-2872-f6 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F7 | review-finding:pr-2872-f7 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -91,6 +103,71 @@ findings keep the reviewer's IDs F1 and F2; the review body only summarizes them - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583187197 +### F3 - The branch's red and green regression runs are not recorded + +- PR number: 2872 +- Source review ID: 5916791851 +- Reviewer finding ID: F1 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583310003 +- Concern: the spec's Bug-Fix Process and the fix-bug skill ask for the failing run of the regression test on this branch before the fix and the passing runs after it; the issue's evidence held only the manual recheck. +- Solution: added the section "Regression Tests: Red and Green Runs" to `docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md`, with the raw outputs in `evidence/regression-red-run.txt` and `evidence/regression-green-run.txt`. The red run was made at the red commit in its own detached worktree; the green run at the branch head after the F4 to F6 fixes. +- Current-tree verification: red: `cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left` at `test(udp-server): [#2850] reject a negative left in an announce (red)` exited 101 with the test `FAILED` and `seeders: NumberOfPeers(I32(1))` in the response (2026-11-16 08:16:06 to 08:16:41 UTC). Green: the eight commands of the table passed, 73 results, 0 failed (08:16:11 to 08:16:38 UTC). +- Resolution reference: docs(issues): [#2850] record the red and green runs of the regression tests +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583390892 + +### F4 - Progress-log and frontmatter stamps are later than the commits that carry them + +- PR number: 2872 +- Source review ID: 5916791851 +- Reviewer finding ID: F2 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583310011 +- Concern: the 21:40 UTC stamps (2850 spec entry and frontmatter, 2838 spec, EPIC) come from a commit authored at 21:23 UTC, after the PR was opened at 21:22 UTC; the 21:25 UTC entry and `performance-evidence.md`'s 21:20 come from a commit authored at 21:17 UTC. +- Solution: set the 21:40 stamps to 21:22 and the 21:25 and 21:20 stamps to 21:17. A sweep of every stamp the branch adds against its commit's author time found one more: `manual-verification-evidence.md` at 21:05 in a commit authored at 21:04, set to 21:04. +- Current-tree verification: a script listed each `last-updated-utc` and progress-log stamp added by each branch commit next to that commit's author time; after the fix, `grep` finds no `21:40` and no `21:25 UTC` in the three specs and the evidence. +- Resolution reference: docs(issues): [#2850] set each stamp to no later than its own commit +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583391235 + +### F5 - `peerslee` is a bencode fragment, not a term + +- PR number: 2872 +- Source review ID: 5916791851 +- Reviewer finding ID: F3 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583310019 +- Concern: `peerslee` is `5:peers`, an empty list and a closing `e`, so a dictionary entry admits a non-word in every file; the tree already ignores it per file. +- Solution: removed it from `project-words.txt`, added it to the spelling directive of `manual-verification-evidence.md`, and added `docs/issues/*/2850-non-negative-number-of-bytes/evidence/*.txt` to the `ignorePaths` of `cspell.json`. +- Current-tree verification: `grep -c peerslee project-words.txt` printed `0`; `linter cspell` passed ("All files passed spell checking!"). +- Resolution reference: chore(cspell): [#2850] ignore the bencode fragment `peerslee` per file +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583391581 + +### F6 - A draft spec still lists the removed `NumberOfBytesOverflow` + +- PR number: 2872 +- Source review ID: 5916791851 +- Reviewer finding ID: F4 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583310025 +- Concern: `docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md` line 54 maps `NumberOfBytesOverflow`, which no longer exists, and its line numbers were already off. +- Solution: dropped the variant from the row and pointed the three remaining variants at their current lines. +- Current-tree verification: `grep -n` on the `ParseAnnounceQueryError` enum shows `MissingParams` at 219, `MissingParam` at 221 and `InvalidParam` at 227; the row now cites `:219`, `:221`, `:227`. +- Resolution reference: docs(issues): [#2850] drop the removed overflow variant from the SI-3 draft +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583391911 + +### F7 - The description does not mention the compile-fail doctests or the audit + +- PR number: 2872 +- Source review ID: 5916791851 +- Reviewer finding ID: F5 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583310033 +- Concern: the PR description, which the merge tool copies into the merge commit, did not list the review-round commits or a `cargo test --doc` run that covers the compile-fail doctests. +- Solution: edited the description: a "Review rounds" list names the commits of both rounds by subject, and the validation list names the `cargo test --doc --workspace` run of the pre-commit hook and the red and green runs. The fix is outside the tree, so the reference is the PR conversation response that states it. +- Current-tree verification: `gh-bot pr edit 2872 --body-file` succeeded; the description shows the "Review rounds" list. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2872#issuecomment-6911164755 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583392250 + ## Processing Log - 2026-11-16 07:51 UTC - Started this audit for Copilot's review `5916561572` (submitted @@ -101,6 +178,16 @@ findings keep the reviewer's IDs F1 and F2; the review body only summarizes them two threads has a reply (posted 2026-11-16T07:54 UTC) and was resolved (`isResolved: true`); a fresh GraphQL fetch shows 0 unresolved threads. `validate-audit-record.py --pr-number 2872` returned `status: ok`, 2 rows, 0 failures, before the resolution. +- 2026-11-16 08:21 UTC - Round 2: da2ce7's review `5916791851` (submitted 2026-11-16T08:11:06Z, + approved, five findings). The fixes of F3 to F6 were committed and pushed by `git-bot-push` (head + `docs(issues): [#2850] record the red and green runs of the regression tests`), the description + was edited for F7 and comment + https://github.com/torrust/torrust-tracker/pull/2872#issuecomment-6911164755 states it, and the + five threads were replied to (2026-11-16T08:20:34Z to 08:20:43Z). Late start: the round-2 rows + were added to this record after those replies, not before them. +- 2026-11-16 08:21 UTC - Round 2 processed. `validate-audit-record.py --pr-number 2872` returned + `status: ok`, 7 rows, 3 log entries, 0 failures; then the five threads were resolved + (`isResolved: true`) and a fresh GraphQL fetch shows 0 unresolved threads. ## Completion Rules From 02bfbe17a14417c767dd3cb1dac1b28c0ce12da6 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:34:49 +0000 Subject: [PATCH 21/28] docs(issues): [#2850] count 10 located variants in the SI-3 draft With `NumberOfBytesOverflow` gone, the draft's table lists 10 variants that print `{location}`, but its text still said 11 in four places. Count 10, and say why it differs from fact 1 of `options.md`. Addresses review finding F6 of da2ce7's second review on PR #2872. Co-Authored-By: Claude Opus 5.5 --- .../ISSUE.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md b/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md index 1f87e856ff..9df3d423a4 100644 --- a/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md +++ b/docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md @@ -9,7 +9,7 @@ github-issue: null spec-path: docs/issues/drafts/error-locations-si-3-http-tracker-request-errors/ISSUE.md branch: "{issue-number}-error-locations-si-3-http-tracker-request-errors" related-pr: null -last-updated-utc: "2026-11-16 08:14" +last-updated-utc: "2026-11-16 08:34" semantic-links: skill-links: - create-issue @@ -46,7 +46,8 @@ no HTTP tracker `failure reason` produced by request parsing holds a source path This is the largest client-visible exposure found by the audit. The bencoded `failure reason` of an HTTP tracker response embeds the error text, and a BitTorrent client shows it to its user. -Variants that print `{location}` (11, `options.md` fact 1): +Variants that print `{location}` (10; `options.md` fact 1 counts 11, including +`ParseAnnounceQueryError::NumberOfBytesOverflow`, which issue #2850 removed): | File | Variants | | --- | --- | @@ -70,7 +71,7 @@ Text path to the client: `From`, `From `From` (`requests/announce.rs:318-329`, `scrape.rs:59`) and, in `responses/error.rs:54` and `:62`, `From` and `From`. -Six of the 11 formats print no input (`MissingParams` twice, the two `PeerIpResolutionError` +Six of the 10 formats print no input (`MissingParams` twice, the two `PeerIpResolutionError` variants and the two `auth::Error` variants; `options.md` fact 3 has the full list), so removing `in {location}` needs new wording there. @@ -81,7 +82,7 @@ publish planned in #2583), so the change adds no release step. ### In Scope -- Remove `location` from the 11 variants and their formats; reword the messages that lose their +- Remove `location` from the 10 variants and their formats; reword the messages that lose their only context so that each names what failed. - Replace the three `LocatedError` sources with the plain source error (`#[source]`), and stop formatting a source the workspace does not control (`torrust_info_hash::ConversionError`) into the @@ -149,7 +150,7 @@ Status values: `TODO`, `IN_PROGRESS`, `BLOCKED`, `DONE`. | --- | --- | --- | --- | | T1 | TODO | Reproduce and record | Responses of the malformed requests with a library path, in `manual-verification-evidence.md`. | | T2 | TODO | Red tests | Unit tests at the `FromStr`/`TryFrom` seams and HTTP-server tests for the failure reasons; red output recorded. | -| T3 | TODO | Remove `location` from the 11 variants | Fields, formats and captures removed in `http-protocol` and the `axum-http-server` extractors; messages reworded where needed. | +| T3 | TODO | Remove `location` from the 10 variants | Fields, formats and captures removed in `http-protocol` and the `axum-http-server` extractors; messages reworded where needed. | | T4 | TODO | Replace the three `LocatedError` sources | Plain `#[source]` errors; client text does not print the inner source; `torrust-located-error` removed from `http-protocol/Cargo.toml`. | | T5 | TODO | Green and recheck | Green output, then the T1 requests repeated against the running tracker. | | T6 | TODO | Review the reworded messages | A table of old and new `failure reason` texts in the evidence file, for the maintainer to approve the wording. | From a5ebc8e6d3fe93a6c69b82d0d8ab3c386a41b606 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:35:39 +0000 Subject: [PATCH 22/28] docs(issues): [#2850] call the regression-run captures excerpts The red and green captures are filtered: the red one starts at cargo's `Finished` line, and the green one keeps only the toolchain, stamps, commands and test lines. Call them excerpts and say what each keeps, instead of "full text". Addresses review finding F7 of da2ce7's second review on PR #2872. Co-Authored-By: Claude Opus 5.5 --- .../manual-verification-evidence.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md index a128bd4eaf..283d1e10d4 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md @@ -1,7 +1,7 @@ --- doc-type: manual-verification-evidence issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -last-updated-utc: "2026-11-16 08:17" +last-updated-utc: "2026-11-16 08:34" --- # Manual Verification Evidence @@ -211,8 +211,10 @@ the passing runs after it. Both runs were made on 2026-11-16 with `rustc 1.99.1 cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left ``` -- Output (08:16:06 to 08:16:41 UTC, full text in - [`evidence/regression-red-run.txt`](evidence/regression-red-run.txt)): the test `FAILED` with +- Output (08:16:06 to 08:16:41 UTC; excerpt in + [`evidence/regression-red-run.txt`](evidence/regression-red-run.txt): cargo's output without its + `Compiling` and `Blocking` lines, from `Finished` to the exit code and the end stamp; the command, + toolchain and start stamp are the ones above): the test `FAILED` with exit code 101, and the panic shows the bug of #2838, a negative `left` counted as a seeder: ```text @@ -227,8 +229,9 @@ the passing runs after it. Both runs were made on 2026-11-16 with `rustc 1.99.1 - Commit: the branch head with `docs(issues): [#2850] drop the removed overflow variant from the SI-3 draft` as its last commit, which includes every production change. -- Commands and output (08:16:11 to 08:16:38 UTC, full text in - [`evidence/regression-green-run.txt`](evidence/regression-green-run.txt)), each `ok`: +- Commands and output (08:16:11 to 08:16:38 UTC; excerpt in + [`evidence/regression-green-run.txt`](evidence/regression-green-run.txt): the toolchain, the start + and end stamps, each command, and only its `running`, `test` and `test result` lines), each `ok`: | Command | Result | | --- | --- | From 7f022a9c0ded77910a910d56a8a0052e1b322dc1 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:36:19 +0000 Subject: [PATCH 23/28] docs(pr-reviews): [#2850] count 72 tests in the green regression run The eight `test result` lines of the green run pass 1, 1, 9, 1, 1, 43, 15 and 1 tests: 72, not 73. Correct audit row F3's verification. Addresses review finding F8 of da2ce7's second review on PR #2872. Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index e00ecfd018..50c02e477f 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -111,7 +111,7 @@ source order, with the reviewer's ID kept in each detail entry. The review body - Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583310003 - Concern: the spec's Bug-Fix Process and the fix-bug skill ask for the failing run of the regression test on this branch before the fix and the passing runs after it; the issue's evidence held only the manual recheck. - Solution: added the section "Regression Tests: Red and Green Runs" to `docs/issues/open/2850-non-negative-number-of-bytes/manual-verification-evidence.md`, with the raw outputs in `evidence/regression-red-run.txt` and `evidence/regression-green-run.txt`. The red run was made at the red commit in its own detached worktree; the green run at the branch head after the F4 to F6 fixes. -- Current-tree verification: red: `cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left` at `test(udp-server): [#2850] reject a negative left in an announce (red)` exited 101 with the test `FAILED` and `seeders: NumberOfPeers(I32(1))` in the response (2026-11-16 08:16:06 to 08:16:41 UTC). Green: the eight commands of the table passed, 73 results, 0 failed (08:16:11 to 08:16:38 UTC). +- Current-tree verification: red: `cargo test -p torrust-tracker-udp-server --lib it_should_reject_an_announce_with_a_negative_number_of_bytes_left` at `test(udp-server): [#2850] reject a negative left in an announce (red)` exited 101 with the test `FAILED` and `seeders: NumberOfPeers(I32(1))` in the response (2026-11-16 08:16:06 to 08:16:41 UTC). Green: the eight commands of the table passed, 72 tests, 0 failed (08:16:11 to 08:16:38 UTC). - Resolution reference: docs(issues): [#2850] record the red and green runs of the regression tests - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583390892 From 0e10d722c075bc34e8aeb8acc89b8663867c0cd9 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 08:40:21 +0000 Subject: [PATCH 24/28] docs(pr-reviews): [#2850] audit review round 3 of PR #2872 Record da2ce7's second review 5917052481 as audit findings F8 to F10 (the reviewer's F6 to F8) and Copilot's review 5916992112, which has no findings. All three are fixed, replied to and resolved. Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index 50c02e477f..8f8320df36 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -50,6 +50,10 @@ Round 2 is da2ce7's review `5916791851` (approved) at the head whose last commit F1 to F5 by the reviewer; F1 and F2 collide with round 1, so they get the audit IDs F3 to F7 in source order, with the reviewer's ID kept in each detail entry. The review body only summarizes them. +Round 3 is da2ce7's second review `5917052481` (approved) at the head whose last commit is +`docs(pr-reviews): [#2850] audit review round 2 of PR #2872`. Its three inline findings F6 to F8 +collide with existing audit IDs, so they get F8 to F10 in source order, with the reviewer's ID kept. + | Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | | ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | | F1 | review-finding:pr-2872-f1 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | @@ -59,6 +63,9 @@ source order, with the reviewer's ID kept in each detail entry. The review body | F5 | review-finding:pr-2872-f5 | Human | Nit | maintainability | ORIGINAL | FIXED | RESOLVED | | F6 | review-finding:pr-2872-f6 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | | F7 | review-finding:pr-2872-f7 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F8 | review-finding:pr-2872-f8 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F9 | review-finding:pr-2872-f9 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F10 | review-finding:pr-2872-f10 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -168,6 +175,45 @@ source order, with the reviewer's ID kept in each detail entry. The review body - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583392250 +### F8 - The SI-3 draft still counts 11 variants after its row lost one + +- PR number: 2872 +- Source review ID: 5917052481 +- Reviewer finding ID: F6 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583490622 +- Concern: with `NumberOfBytesOverflow` gone the draft's table lists 10 variants, but its text says 11 on lines 49, 84 and 152. +- Solution: changed the count to 10 and said on line 49 why fact 1 of `options.md` counts 11. The sweep found a fourth count, line 73 ("Six of the 11 formats"), changed to 10 as well. +- Current-tree verification: `grep -n` for `11` in the draft finds no variant count left; the table lists 1 + 3 + 2 + 2 + 2 = 10 variants. +- Resolution reference: docs(issues): [#2850] count 10 located variants in the SI-3 draft +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583544077 + +### F9 - The two regression-run captures are excerpts, not the full text + +- PR number: 2872 +- Source review ID: 5917052481 +- Reviewer finding ID: F7 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583490625 +- Concern: the record called both captures the full text, but the red one starts at cargo's `Finished` line and the green one keeps only selected lines. +- Solution: both lines of `manual-verification-evidence.md` now say "excerpt" and what each capture keeps. +- Current-tree verification: the red capture's first line is cargo's `Finished` line; the green capture has no `Finished` or `Running` line; the record describes both. +- Resolution reference: docs(issues): [#2850] call the regression-run captures excerpts +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583544352 + +### F10 - The green runs passed 72 tests, not 73 + +- PR number: 2872 +- Source review ID: 5917052481 +- Reviewer finding ID: F8 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583490631 +- Concern: row F3's verification and the reply on its thread said 73 results; the eight `test result` lines add up to 72. +- Solution: row F3 now says 72 tests, and a correcting reply was posted on F3's thread (https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583545035). +- Current-tree verification: `grep -c "\.\.\. ok" evidence/regression-green-run.txt` prints 72. +- Resolution reference: docs(pr-reviews): [#2850] count 72 tests in the green regression run +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583544693 + ## Processing Log - 2026-11-16 07:51 UTC - Started this audit for Copilot's review `5916561572` (submitted @@ -188,6 +234,15 @@ source order, with the reviewer's ID kept in each detail entry. The review body - 2026-11-16 08:21 UTC - Round 2 processed. `validate-audit-record.py --pr-number 2872` returned `status: ok`, 7 rows, 3 log entries, 0 failures; then the five threads were resolved (`isResolved: true`) and a fresh GraphQL fetch shows 0 unresolved threads. +- 2026-11-16 08:35 UTC - Copilot's review `5916992112` (submitted 2026-11-16T08:27:42Z) reports + no open issues; it only restates the HTTP benchmark decision of the description; no row. +- 2026-11-16 08:38 UTC - Round 3: da2ce7's review `5917052481` (submitted 2026-11-16T08:32:27Z, + approved, three Nit findings). The fixes of F8 to F10 were pushed by `git-bot-push` (head + `docs(pr-reviews): [#2850] count 72 tests in the green regression run`) and the three threads + were replied to, plus a correcting reply on F3's thread; the rows were added after the replies. +- 2026-11-16 08:39 UTC - Round 3 processed. `validate-audit-record.py --pr-number 2872` returned + `status: ok`, 10 rows, 6 log entries, 0 failures; then the three threads were resolved and a + fresh GraphQL fetch shows 0 unresolved threads. ## Completion Rules From 8a035fb733d329329cf86bbd6188c36c7cc297a6 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 09:52:15 +0000 Subject: [PATCH 25/28] docs(pr-reviews): [#2850] audit review round 4 of PR #2872 Stamp the round-3 log entry at 08:39 UTC, the minute of the replies it reports, and record da2ce7's finding F9 as audit row F11. Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index 8f8320df36..afce24de39 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -54,6 +54,10 @@ Round 3 is da2ce7's second review `5917052481` (approved) at the head whose last `docs(pr-reviews): [#2850] audit review round 2 of PR #2872`. Its three inline findings F6 to F8 collide with existing audit IDs, so they get F8 to F10 in source order, with the reviewer's ID kept. +Round 4 is da2ce7's third review `5917226013` (approved) at the head whose last commit is +`docs(pr-reviews): [#2850] audit review round 3 of PR #2872`. Its one inline finding F9 collides +with an existing audit ID, so it gets F11, with the reviewer's ID kept. + | Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | | ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | | F1 | review-finding:pr-2872-f1 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | @@ -66,6 +70,7 @@ collide with existing audit IDs, so they get F8 to F10 in source order, with the | F8 | review-finding:pr-2872-f8 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | | F9 | review-finding:pr-2872-f9 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | | F10 | review-finding:pr-2872-f10 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F11 | review-finding:pr-2872-f11 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -214,6 +219,21 @@ collide with existing audit IDs, so they get F8 to F10 in source order, with the - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583544693 +### F11 - The round-3 log entry is stamped before the replies it reports + +- PR number: 2872 +- Source review ID: 5917226013 +- Reviewer finding ID: F9 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4583618217 +- Concern: the round-3 log entry was stamped 08:38 UTC, but the replies it reports were posted at + 08:39:19 to 08:39:27 UTC, so the entry recorded events after its own stamp. +- Solution: the round-3 entry is now stamped 08:39 UTC, the minute of the replies. +- Current-tree verification: the processing log has no `08:38 UTC` stamp; the round-3 entry and + the replies share the minute 08:39. +- Resolution reference: docs(pr-reviews): [#2850] audit review round 4 of PR #2872 +- Follow-up PR URL: N/A +- Reply URL: pending + ## Processing Log - 2026-11-16 07:51 UTC - Started this audit for Copilot's review `5916561572` (submitted @@ -236,13 +256,17 @@ collide with existing audit IDs, so they get F8 to F10 in source order, with the (`isResolved: true`) and a fresh GraphQL fetch shows 0 unresolved threads. - 2026-11-16 08:35 UTC - Copilot's review `5916992112` (submitted 2026-11-16T08:27:42Z) reports no open issues; it only restates the HTTP benchmark decision of the description; no row. -- 2026-11-16 08:38 UTC - Round 3: da2ce7's review `5917052481` (submitted 2026-11-16T08:32:27Z, +- 2026-11-16 08:39 UTC - Round 3: da2ce7's review `5917052481` (submitted 2026-11-16T08:32:27Z, approved, three Nit findings). The fixes of F8 to F10 were pushed by `git-bot-push` (head `docs(pr-reviews): [#2850] count 72 tests in the green regression run`) and the three threads were replied to, plus a correcting reply on F3's thread; the rows were added after the replies. - 2026-11-16 08:39 UTC - Round 3 processed. `validate-audit-record.py --pr-number 2872` returned `status: ok`, 10 rows, 6 log entries, 0 failures; then the three threads were resolved and a fresh GraphQL fetch shows 0 unresolved threads. +- 2026-11-16 09:51 UTC - Started round 4 for da2ce7's review `5917226013` (submitted + 2026-11-16T08:48:26Z, approved, one Nit finding), before any reply. Copilot's review `5917198610` + (submitted 2026-11-16T08:45:58Z) reports no open issues and only restates the HTTP benchmark + decision, which the maintainer accepted; no row. ## Completion Rules From 4adeeb22ca9274f88002d8c662c64ebe0bedb9b0 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 09:56:22 +0000 Subject: [PATCH 26/28] docs(pr-reviews): [#2850] record the reply and resolution of round 4 Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index afce24de39..a3983252ce 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -232,7 +232,7 @@ with an existing audit ID, so it gets F11, with the reviewer's ID kept. the replies share the minute 08:39. - Resolution reference: docs(pr-reviews): [#2850] audit review round 4 of PR #2872 - Follow-up PR URL: N/A -- Reply URL: pending +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4584227007 ## Processing Log @@ -267,6 +267,11 @@ with an existing audit ID, so it gets F11, with the reviewer's ID kept. 2026-11-16T08:48:26Z, approved, one Nit finding), before any reply. Copilot's review `5917198610` (submitted 2026-11-16T08:45:58Z) reports no open issues and only restates the HTTP benchmark decision, which the maintainer accepted; no row. +- 2026-11-16 09:56 UTC - Round 4 processed. The fix was pushed by `git-bot-push` (head + `docs(pr-reviews): [#2850] audit review round 4 of PR #2872`) and the thread was replied to + (2026-11-16T09:55:09Z). `validate-audit-record.py --pr-number 2872` returned `status: ok`, 11 + rows, 8 log entries, 0 failures; then the thread was resolved and a fresh GraphQL fetch shows 0 + unresolved threads. ## Completion Rules From 39234c3cfb01cc34e86148383395bb87f540f9cf Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 10:17:08 +0000 Subject: [PATCH 27/28] docs(issues): [#2850] record the maintainer's benchmark and client-visible decisions Record in the spec and in performance-evidence.md that the maintainer accepted the HTTP announce_once result and approved the client-visible changes on 2026-11-16, and where the decisions were given. Audit da2ce7's finding F11 as row F12. Co-Authored-By: Claude Opus 5.5 --- .../ISSUE.md | 6 ++++- .../performance-evidence.md | 5 +++- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 26 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md index 75ed6bbd04..5d35fe28cc 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md @@ -9,7 +9,7 @@ github-issue: 2850 spec-path: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md branch: "2850-non-negative-number-of-bytes" related-pr: 2872 -last-updated-utc: "2026-11-15 21:22" +last-updated-utc: "2026-11-16 10:16" semantic-links: skill-links: - create-issue @@ -717,6 +717,7 @@ the model that produced them. - 2026-11-12 20:29 UTC - Claude Code (Fable 5.2) - Rebased the spec-only branch onto `develop` after PR #2841 (the primitives tests of #2824) merged and conflicted in the EPIC #1347 table. Updated the coordination note: those tests are on `develop` and name this issue. - 2026-11-15 21:17 UTC - Claude Code (Opus 5.5) - Implemented T0 to T6 on branch `2850-non-negative-number-of-bytes`. T0 added `udp_tracker/announce_once`; the first baseline was discarded because uncommitted T1/T2 edits leaked into its build, and each measurement is now built in a clean worktree (`performance-evidence.md`, lesson added to `docs/benchmarking.md`). T2 named the field with the `ByteCountField` enum (one variant, one message, the field as a matchable value) and moved the peer conversion before the whitelist check, as the order tests of PR #2839 require. The maintainer agreed a 5% tolerance for the UDP benchmark before the after measurement. Load test and UDP pass; HTTP `announce_once` failed the one-sided rule by 0.3% on a path T3 does not add work to, and an interleaved A/B run put it inside the noise: the verdict is the maintainer's. Manual run 1 was discarded for non-monotonic timestamps. No design assumption was invalidated, so no retrospective file. - 2026-11-15 21:22 UTC - Claude Code (Opus 5.5) - Rebased onto `develop` and opened the implementation PR #2872 (closes #2850 and #2838). Updated the #2838 specification and row 12 of the EPIC #1347 table to point to it. +- 2026-11-16 10:16 UTC - Claude Code (Opus 5.5) - Recorded two maintainer decisions of 2026-11-16, both given to this session in its conversation with the maintainer: the client-visible changes listed in PR #2872 are approved, and the HTTP `announce_once` result is accepted ("Performance Evidence" and `performance-evidence.md`). ## Acceptance Criteria @@ -774,6 +775,9 @@ of `http-core`, and the end-to-end UDP load test. - Agreed tolerance (maintainer, 2026-11-15, after the baseline and before the after measurement): the after UDP `announce_once` median may be up to 5% above the highest baseline median, that is at most 318.70 ns (highest baseline median 303.52 ns; baseline spread 6.5%). +- HTTP verdict (maintainer, 2026-11-16, after the after measurement): the HTTP `announce_once` + result, 0.3% above the highest baseline median and inside the noise of the interleaved A/B + run, is accepted. The decision was given to the implementing agent session (Claude Code) in its conversation with the maintainer; there is no separate statement on the pull request. ### Manual Verification Scenarios diff --git a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md index a225211bc6..ca6ddfbf3a 100644 --- a/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md +++ b/docs/issues/open/2850-non-negative-number-of-bytes/performance-evidence.md @@ -1,7 +1,7 @@ --- doc-type: performance-evidence issue-spec: docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md -last-updated-utc: "2026-11-15 21:17" +last-updated-utc: "2026-11-16 10:16" --- # Performance Evidence - Non-Negative Number of Bytes @@ -157,3 +157,6 @@ The after build is faster in two pairs and slower in one; the baseline alone spa ns (10.7%) within a minute. The difference of the original after run is inside this noise, so no regression is attributed to the change. The one-sided rule is formally failed and the verdict is the maintainer's: this record is listed in the pull request for that decision. + +Decision (maintainer, 2026-11-16): the HTTP `announce_once` result is accepted; no regression is +attributed to the change. The decision was given to the implementing agent session (Claude Code) in its conversation with the maintainer; there is no separate statement on the pull request. diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index a3983252ce..8c9c906543 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -58,6 +58,10 @@ Round 4 is da2ce7's third review `5917226013` (approved) at the head whose last `docs(pr-reviews): [#2850] audit review round 3 of PR #2872`. Its one inline finding F9 collides with an existing audit ID, so it gets F11, with the reviewer's ID kept. +Round 5 is da2ce7's fourth review `5918318903` (approved) at the head whose last commit is +`docs(pr-reviews): [#2850] record the reply and resolution of round 4`. Its one inline finding F11 +collides with an existing audit ID, so it gets F12, with the reviewer's ID kept. + | Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | | ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | | F1 | review-finding:pr-2872-f1 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | @@ -71,6 +75,7 @@ with an existing audit ID, so it gets F11, with the reviewer's ID kept. | F9 | review-finding:pr-2872-f9 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | | F10 | review-finding:pr-2872-f10 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | | F11 | review-finding:pr-2872-f11 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F12 | review-finding:pr-2872-f12 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | ## Finding Details @@ -234,6 +239,25 @@ with an existing audit ID, so it gets F11, with the reviewer's ID kept. - Follow-up PR URL: N/A - Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4584227007 +### F12 - The HTTP benchmark acceptance is not recorded in the repository + +- PR number: 2872 +- Source review ID: 5918318903 +- Reviewer finding ID: F11 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4584446219 +- Concern: the description says the maintainer accepted the HTTP `announce_once` result, but it + still asked for the confirmation, and `performance-evidence.md` and the spec left the verdict + open, so the merged record would not hold the decision. +- Solution: `performance-evidence.md` and the spec's "Performance Evidence" section record the + decision, its date and where it was given (the implementing session's conversation with the + maintainer); a spec progress entry records it together with the approval of the client-visible + changes; the question was dropped from the description. +- Current-tree verification: `grep -n "HTTP verdict"` finds the line in the spec; the description + no longer contains "Please confirm". +- Resolution reference: docs(issues): [#2850] record the maintainer's benchmark and client-visible decisions +- Follow-up PR URL: N/A +- Reply URL: pending + ## Processing Log - 2026-11-16 07:51 UTC - Started this audit for Copilot's review `5916561572` (submitted @@ -272,6 +296,8 @@ with an existing audit ID, so it gets F11, with the reviewer's ID kept. (2026-11-16T09:55:09Z). `validate-audit-record.py --pr-number 2872` returned `status: ok`, 11 rows, 8 log entries, 0 failures; then the thread was resolved and a fresh GraphQL fetch shows 0 unresolved threads. +- 2026-11-16 10:16 UTC - Started round 5 for da2ce7's review `5918318903` (submitted + 2026-11-16T10:15:34Z, approved, one Nit finding), before any reply. ## Completion Rules From 277a3ec38e0b32201bb3c5c8c6d1b6b163ba2611 Mon Sep 17 00:00:00 2001 From: josecelano-bot Date: Mon, 16 Nov 2026 10:21:24 +0000 Subject: [PATCH 28/28] docs(pr-reviews): [#2850] record the reply and resolution of round 5 Co-Authored-By: Claude Opus 5.5 --- docs/pr-reviews/pr-2872-review/PR-REVIEW.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md index 8c9c906543..49a71cde44 100644 --- a/docs/pr-reviews/pr-2872-review/PR-REVIEW.md +++ b/docs/pr-reviews/pr-2872-review/PR-REVIEW.md @@ -256,7 +256,7 @@ collides with an existing audit ID, so it gets F12, with the reviewer's ID kept. no longer contains "Please confirm". - Resolution reference: docs(issues): [#2850] record the maintainer's benchmark and client-visible decisions - Follow-up PR URL: N/A -- Reply URL: pending +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2872#discussion_r4584492157 ## Processing Log @@ -298,6 +298,12 @@ collides with an existing audit ID, so it gets F12, with the reviewer's ID kept. unresolved threads. - 2026-11-16 10:16 UTC - Started round 5 for da2ce7's review `5918318903` (submitted 2026-11-16T10:15:34Z, approved, one Nit finding), before any reply. +- 2026-11-16 10:21 UTC - Round 5 processed. The fix was pushed by `git-bot-push` (head + `docs(issues): [#2850] record the maintainer's benchmark and client-visible decisions`), the + description was edited to drop the question, and the thread was replied to + (2026-11-16T10:20:20Z). `validate-audit-record.py --pr-number 2872` returned `status: ok`, 12 + rows, 10 log entries, 0 failures; then the thread was resolved and a fresh GraphQL fetch shows 0 + unresolved threads. ## Completion Rules