diff --git a/docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md b/docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md new file mode 100644 index 0000000000..6b428a203c --- /dev/null +++ b/docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md @@ -0,0 +1,234 @@ +--- +semantic-links: + skill-links: + - create-adr + related-artifacts: + - docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md + - docs/adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md + - docs/adrs/20260723184019_separate_configuration_value_invariants_from_consistency_validation.md + - docs/adrs/20260721100000_use_newtypes_for_constrained_configuration_field_types.md + - docs/adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md + - docs/adrs/20260727000000_events_are_objective_facts.md + - docs/adrs/20260617093046_reject_wildcard_external_ip.md + - docs/adrs/20261005124222_cap_scrape_info_hashes_per_protocol.md + - docs/adrs/20260716000000_accept_only_ip_addresses_in_http_announce_ip_param.md + - packages/http-protocol/src/v1/requests/announce.rs + - packages/udp-protocol/src/request.rs + - packages/primitives/src/peer.rs + - docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md + - docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md + - docs/packages.md +--- + + + +# Reject Malformed Inbound Protocol Values Unless Real Clients Need the Tolerance + +## Scope + +Repository-level. The decision applies to every delivery protocol that receives client requests +(`udp-protocol`, `udp-server`, `http-protocol`, `axum-http-server`) and to the domain types in +`primitives` that those protocols feed, so it belongs in `docs/adrs/`. + +## Description + +BitTorrent is decentralized and has no conformance authority. Implementations that accept the +widest range of client behavior interoperate with the most clients ("be liberal in what you +accept"). A tracker that is liberal everywhere, however, hides client bugs, lets different delivery +protocols disagree about the same value, and pushes values into the domain that its code never +considered. + +The first case found is the announce `left` field. BEP 15 encodes it as a 64-bit integer, +which the implementation document it cites types as `int64_t`, and the UDP announce accepts a +negative value. The HTTP announce parses `left` as `u64` and rejects +it. `Peer::is_seeder` (`packages/primitives/src/peer.rs`) treats `left <= 0` as a seeder, so a +negative value from a UDP client counts the peer as a seeder (the `complete` count), while the same +value over HTTP is an error. Nobody decided this; it follows from the parsers being written independently. + +The existing ADRs cover the other direction. [Bound protocol-agnostic values by the tightest +delivery protocol](20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md) +is about values the tracker sends. The [value-invariant +ADR](20260723184019_separate_configuration_value_invariants_from_consistency_validation.md) and the +[newtype ADR](20260721100000_use_newtypes_for_constrained_configuration_field_types.md) say how to +reject a bad configuration value. None of them says what to do with a value a client sends. + +## Agreement + +1. **Strict by default.** A value a client sends that its protocol specification does not allow is + rejected with the protocol's normal error response (a BEP 15 error packet over UDP, a bencoded + `failure reason` over HTTP). It is not clamped, defaulted, or silently ignored. + +2. **Judge each field on its own.** A value that looks unusual may be legitimate: BEP 15 + `num_want = -1` means "use the default", and `left`, `downloaded` and `uploaded` are 64-bit + integers in BEP 15, and the sources do not document why they are signed. The question for each field is what its + specification allows, not whether the value is negative or large. "Reject all negatives" is + not the rule. + +3. **Tolerate only with recorded evidence.** The tracker tolerates a malformed value only when + there is evidence that a meaningful share of real clients relies on it. Evidence is one of: a + named client and version that sends the value (an issue report, a packet capture, or the + client's source), or the rejection metric described in point 5. A tolerance without evidence is + not added, and a "might break some client" argument alone is not evidence. + +4. **Record every tolerance in code and in this ADR.** A tolerance is one row in the register + below, and its code carries a comment that links to this ADR. The row says the field, the + protocols, the tolerated values, what they are normalized to, the evidence, the metric, and + when to reconsider it. Adding or removing a row is an amendment to this ADR and goes through a + PR like any other change. + +5. **Make the decision measurable.** The tracker counts every request rejected for a malformed + inbound value, labeled by delivery protocol, field and a bounded client family, so the number + of affected real clients can be read before a tolerance is added. Every tolerance has its own + counter, emitted as an objective event per [Events Are Objective Facts](20260727000000_events_are_objective_facts.md) (or, where a metric is not feasible, a rate-limited log) so the register can be + reviewed with data and a tolerance that no client uses is removed. + +6. **Implement the public specification strictly; refuse at the first project-owned type.** + Following a public protocol specification faithfully has priority over failing fast. A type + that mirrors a BEP keeps the shape the BEP gives it and is not narrowed, because the + specification is not our decision and its reasons may be unknown. The wire parser therefore + accepts what the BEP type allows. A value the specification allows but the domain does not is + refused at the first conversion into a type the project owns (application or domain layer), + as issue #2850 plans for a negative `left` with a fallible conversion in `udp-core`. The malformed value + never reaches `primitives` or `tracker-core`. A tolerance normalizes to a value the domain + already accepts. Domain types protect their invariants with newtypes and constructors (for + example a non-negative number of bytes) and carry no special cases for malformed input. See + [Keep protocol and domain types decoupled](20260527175600_keep_protocol_and_domain_types_decoupled.md). + +7. **The protocols agree on the verdict for a value both wire formats can express.** UDP and + HTTP must not disagree about whether such a value is accepted. A range that only one wire + format can express follows that protocol's own specification: the protocols may differ at the + wire level and are equal in the domain, as in [Cap scrape info hashes per + protocol](20261005124222_cap_scrape_info_hashes_per_protocol.md). Rejecting a malformed value + is not by itself a reason to ban the client; banning stays with the rules of the UDP ban + service. Each field has a parity test that sends the same values through both protocols up to the + point where the request is accepted or refused, which includes the wire-to-domain conversion + and not only the parser. + +8. **Validate each kind of rule in the layer that owns it, as early as possible.** Syntax is + validated in the delivery layer (the wire parser), application invariants in the service, and + domain invariants in the domain. Public protocol packages follow + [Package Conventions](../packages.md#package-conventions), principle 2: `*-protocol` + packages strictly implement BEP specifications. + +9. **Protect invariants with constructors or newtypes, not standalone validation functions.** A + value that must hold an invariant has a type whose constructor enforces it, so a valid value + cannot be bypassed and the check is not repeated by every caller. + +### First application: byte counts + +Announce `left`, `downloaded` and `uploaded` apply the rules above. This records the intended +design; the code change is tracked in issue #2850 +([specification](../issues/open/2850-non-negative-number-of-bytes/ISSUE.md)). + +- Domain `NumberOfBytes` (in `primitives`) is a private `u64` with no upper bound. +- UDP wire type `NumberOfBytes(I64)` and `Request::parse_bytes` stay unchanged. A negative value + is refused in a fallible `peer_builder::from_request` in `udp-core`; its error is wrapped by + `UdpAnnounceError`. No standalone validation function is added: PR #2839, which proposed one, + was closed without merging in favour of this design. +- The HTTP protocol type becomes a private `u64` and its `i64::MAX` limit + (`NumberOfBytesOverflow`) is removed, because the limit only existed to fit the old shared + `i64` type. HTTP then accepts `0..=u64::MAX` and UDP `0..=i64::MAX`; the domain is the same for + both. +- REST resource fields for byte counts are `u64`. + +Research behind the signed UDP fields: BEP 15 and the XBT Tracker document say only "64-bit +integer" for these fields, never signed or unsigned. The libtorrent document (cited by BEP 15 as +an existing implementation) uses `int64_t` for the byte counts, but `uint32_t` for `ip` and `key` +and `uint16_t` for `port`, so unsigned types exist in the format. BEP 3 says only "encoded in +base ten ascii". No document says why the counts are signed or what a tracker must do with a +negative value. The "Evidence on real clients and other trackers" section of the +[#2838 specification](../issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md) shows that, before the metadata is known, libtorrent sends `left = 16384` +and Transmission sends `left = i64::MAX`; neither sends a negative value. + +### Register of tolerances + +| Field | Protocols | Tolerated values | Normalized to | Evidence | Metric | Reconsider when | +| ----- | --------- | ---------------- | ------------- | -------- | ------ | --------------- | +| _None yet_ | | | | | | | + +### Existing leniencies (inventory, not yet applied to this rule) + +These were found while writing this ADR. They predate it, so none has recorded evidence or a +metric. Each is to be kept (and registered with its evidence), changed to reject, or aligned across +protocols in its own issue; this ADR does not change any of them. + +| Field | UDP | HTTP | Note | +| ----- | --- | ---- | ---- | +| Announce `left`, `downloaded`, `uploaded` | accepts negative (signed 64-bit) | rejects negative and above `i64::MAX` (the limit exists only to fit an `i64` type) | First application: bug #2838; UDP still accepts it; the planned change is issue #2850 | +| Announce `port` = 0 | rejected by the parser | no zero check found in the parser (to verify) | Possible disagreement. BEP 15 does not forbid port 0, so under rule 6 this parser check deserves a review. The event check (`0..=3`) mirrors BEP 15 | +| Announce `num_want` / `numwant` | any `i32`; zero or negative means as many as possible, a positive value is capped at the tracker limit (`PeersWanted::from_client_request`) | `u32` only, so `-1` is rejected; `0` asks for no peers (`PeersWanted::only`) | `-1` is legitimate for UDP (BEP 15 default). UDP is lenient for values below `-1`. Zero means different things on the two protocols. HTTP `-1` is unspecified | +| Announce event outside the defined set | rejected | rejected | Consistent | +| Announce `ip` that is not an IP address | field ignored always | rejected (`PeerIpDnsNameUnsupported`, `PeerIpInvalid`); an absent or empty value uses the connection IP | Not a leniency on HTTP today. [The `ip` ADR](20260716000000_accept_only_ip_addresses_in_http_announce_ip_param.md) records an older policy, a silent fallback to the connection IP; the code now rejects. The difference between that ADR and the code needs its own follow-up; no metric | +| Scrape above the info-hash cap | extra hashes dropped | extra hashes dropped | Recorded in [the scrape cap ADR](20261005124222_cap_scrape_info_hashes_per_protocol.md); no metric | + +## Alternatives Considered + +### Tolerant by default + +Accept and normalize anything that can be interpreted. Rejected: it maximizes compatibility but +hides client bugs, discourages good implementations, and has already produced a protocol +disagreement and a domain type that must handle values it should never receive. + +### Strict by default with no exceptions + +Rejected. A widely deployed client that cannot be fixed would be locked out of a tracker, which +defeats a tracker's purpose. The evidence rule keeps the choice open without making tolerance the +default. + +### Per-protocol policy + +Let each delivery protocol decide its own tolerance. Rejected: it is how the `left` disagreement +arose, and one swarm served over several protocols should not depend on which one a client used. + +### Make tolerance a configuration option + +Rejected for now. An operator switch multiplies the combinations to test and does not produce the +evidence this ADR asks for. It can be reconsidered for one specific tolerance if the evidence +shows operators disagree. + +### Normalize in the domain instead of the parser + +Rejected. It spreads protocol knowledge into `primitives`, against [Keep protocol and domain types +decoupled](20260527175600_keep_protocol_and_domain_types_decoupled.md), and the same value would +need handling in every consumer. + +## Consequences + +- **Positive**: one explicit, reviewable rule for every inbound field; UDP and HTTP stop + disagreeing by accident. +- **Positive**: the domain can rely on valid values, so `is_seeder` and similar code stay simple. +- **Positive**: tolerance decisions are driven by data (the rejection counters) and can be undone. +- **Negative**: a client with a malformed value is rejected until someone shows evidence and a + tolerance is registered, so the maintainers will occasionally get a compatibility bug report. +- **Negative**: the rejection counter and per-tolerance metrics are new work, and the client-family + label needs a bounded cardinality. +- **Negative**: the existing leniencies in the inventory are inconsistent with the rule until each + is handled. + +## Affected Code + +- [`packages/http-protocol/src/v1/requests/announce.rs`](../../packages/http-protocol/src/v1/requests/announce.rs): + HTTP announce parsing. +- [`packages/udp-protocol/src/request.rs`](../../packages/udp-protocol/src/request.rs): UDP request + parsing. +- [`packages/primitives/src/peer.rs`](../../packages/primitives/src/peer.rs): `Peer::is_seeder`. + +This ADR changes no code. Follow-up issues apply it field by field. + +## Date + +2026-11-11 + +## References + +- [Issue #2842](https://github.com/torrust/torrust-tracker/issues/2842) — this ADR +- [EPIC #1347](https://github.com/torrust/torrust-tracker/issues/1347) — package testing overhaul, where the `left` finding came up +- [BEP 3: The BitTorrent Protocol Specification](https://www.bittorrent.org/beps/bep_0003.html) +- [BEP 15: UDP Tracker Protocol](https://www.bittorrent.org/beps/bep_0015.html) +- [Issue #2850](https://github.com/torrust/torrust-tracker/issues/2850) — first application, the design recorded above; it fixes [issue #2838](https://github.com/torrust/torrust-tracker/issues/2838). [PR #2839](https://github.com/torrust/torrust-tracker/pull/2839) was the first, tactical attempt: reject a negative `left`, `uploaded` or `downloaded` in a UDP announce +- [Events Are Objective Facts](20260727000000_events_are_objective_facts.md) — how rejections and tolerances are reported +- [Reject wildcard IPs as invalid `external_ip` values](20260617093046_reject_wildcard_external_ip.md) — the same fail-fast stance for configuration +- [Use Exact IP Counters for UDP Banning](../../packages/udp-core/docs/adrs/20260829204258_use_exact_ip_counters_for_udp_banning.md) — ban rules, independent of this decision +- [Bound protocol-agnostic values by the tightest delivery protocol](20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md) +- [Separate Configuration Value Invariants from Consistency Validation](20260723184019_separate_configuration_value_invariants_from_consistency_validation.md) +- [Use Newtypes for Domain-Constrained Configuration Field Types](20260721100000_use_newtypes_for_constrained_configuration_field_types.md) diff --git a/docs/adrs/index.md b/docs/adrs/index.md index ff3fe2c840..6c393b4738 100644 --- a/docs/adrs/index.md +++ b/docs/adrs/index.md @@ -62,6 +62,7 @@ supersession rules. | [20261105132341](20261105132341_define_the_stats_and_metrics_endpoints_and_require_help_and_type_in_prometheus_output.md) | 2026-11-05 | Define the stats and metrics endpoints and require HELP and TYPE in Prometheus output | `/stats` is not deprecated and serves the aggregated statistics, `/metrics` serves the extendable labelled metrics, and every exported Prometheus text must carry `# HELP` and `# TYPE` (legacy `/stats` text aligned by #2734, amended 2026-11-06). | | [20261106102632](20261106102632_scope_the_cli_output_contract_and_keep_exit_codes_to_zero_one_two.md) | 2026-11-06 | Scope the CLI output contract and keep exit codes to 0, 1 and 2 | The contract covers operator binaries and the AI-agent and CI tools, not developer diagnostics; commands use only exit codes 0/1/2, and a distinct outcome is a `kind`: a result with exit 0 when it is the answer asked for, a stderr diagnostic with exit 1 when the command could not answer. | | [20261111095222](20261111095222_close_idle_connections_without_a_408_response.md) | 2026-11-11 | Close idle connections without a 408 response | A connection that sends no complete first request is closed silently after the first-request timeout; no `408 Request Timeout` is sent. | +| [20261111170611](20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md) | 2026-11-11 | Reject malformed inbound protocol values unless real clients need the tolerance | Clients that send values the protocol does not allow are rejected by default; a tolerance needs recorded evidence, a register entry and a metric, and applies the same over UDP and HTTP. | ## ADR Lifecycle diff --git a/docs/issues/open/1347-overhaul-packages-testing/EPIC.md b/docs/issues/open/1347-overhaul-packages-testing/EPIC.md index 5c0fb35a3a..6a5da925d1 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-11 14:32" +last-updated-utc: "2026-11-14 08:06" semantic-links: skill-links: - create-issue @@ -97,7 +97,8 @@ 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/open/2824-1347-add-tests-primitives/ISSUE.md` | IN_PROGRESS | Spec-only PR carries the specification and the T1 baseline and inventory; S0 (the spec, #2828) is merged and S1 (the `PeerRole` JSON casing fix, #2834) is merged and S2 (the `peer.rs` tests, #2841) is merged and S3 (the configuration defaults and bounded values) is in review; S4 follows. Findings F1 (fixed through #2811), F3 (#2804) and the `AddAssign` and `peer::Id::new` follow-ups are handed off to their own issues. | -| 12 | 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. | +| 12 | #2838 - UDP tracker accepts announces with a negative left, uploaded or downloaded | `docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md` | BLOCKED | Bug found by the #2824 primitives tests work. Planned fix: the standalone issue #2850 (`docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md`), whose implementation will close it; until then the bug is present on `develop`. The patch of PR #2839 was not merged. | +| 13 | Additional package-testing subissues | Create a folder-style spec when a concrete package need is identified | TODO | Permitted but not required upfront; retain scope in this EPIC. | ## Package Coverage Tracking 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 new file mode 100644 index 0000000000..7469a3bead --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md @@ -0,0 +1,275 @@ +--- +schema-version: 1 +doc-type: issue +issue-type: bug +status: blocked +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" +semantic-links: + skill-links: + - create-issue + - fix-bug + related-artifacts: + - .github/skills/dev/debugging/fix-bug/SKILL.md + - .github/skills/dev/planning/create-issue/SKILL.md + - docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md +--- + + + +# Issue #2838 - UDP tracker accepts announces with a negative `left` (and `uploaded`/`downloaded`) + +> **Superseded plan (2026-11-12).** The tactical patch described here (PR #2839) was not merged. +> 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. + +## Goal + +The UDP tracker refuses an announce whose `left`, `uploaded` or `downloaded` is negative with a +BEP 15 error response, as the HTTP tracker already does, so one announce gets the same verdict on +both protocols. + +## Background + +Found during the EPIC #1347 `primitives` tests work (issue #2824), whose session tracks it as +finding F6. That finding is not recorded in the #2824 spec at the time of writing. + +What happens today, step by step: + +1. A UDP client sends an announce packet. `bytes_left`, `bytes_uploaded` and `bytes_downloaded` are + decoded as signed 64-bit integers (request fields in `packages/udp-protocol/src/announce.rs`; + the type `NumberOfBytes(I64)` is defined in `packages/udp-protocol/src/common.rs`). +2. `packages/udp-core/src/peer_builder.rs` copies them unchanged into `peer::Peer` + (`NumberOfBytes(i64)`). +3. `Peer::is_seeder` (`packages/primitives/src/peer.rs`) is `left.0 <= 0 && event != Stopped`, so a + negative `left` makes the peer a **seeder**. +4. The tracker stores the peer, counts it in `complete` (seeders) and returns a normal announce + response. + +The HTTP path refuses the same value: `extract_number_of_bytes_from_param` +(`packages/http-protocol/src/v1/requests/announce.rs`) parses `u64` and returns `InvalidParam` +for `uploaded`, `downloaded` and `left`. So the same announce is refused over HTTP and accepted +over UDP. + +Contract violated: a byte count cannot be negative (BEP 3 defines these as counts of bytes; BEP 15 +only gives the wire width, 64-bit integer, and is silent about negatives). Impact: a client can +register itself as a seeder without having anything (`left = -5`), inflating `complete` in +announce and scrape responses and in the metrics; nothing else is observably wrong. + +Maintainer decision (2026-11-11): be strict and reject it. + +### Field audit (decided here, per field) + +| Field (UDP wire) | Wire type | Legitimate negative? | Decision | +| ---------------------------------- | --------- | -------------------- | ------------------------------------------- | +| `left` | i64 | No | Reject if `< 0` (maintainer decision) | +| `uploaded` | i64 | No | Reject if `< 0` (recommended, same as HTTP) | +| `downloaded` | i64 | No | Reject if `< 0` (recommended, same as HTTP) | +| `num_want` (`peers_wanted`) | i32 | Yes: `-1` = default | Keep signed; already handled | +| `connection_id`, `transaction_id` | i64, i32 | Opaque identifiers | Unchanged | +| `key` | i32 | Opaque identifier | Unchanged | +| `event` | i32 | Enum | Unchanged (out of scope) | + +`uploaded` and `downloaded` are only stored on the peer today; they drive no logic, so rejecting +them is a consistency choice (same verdict as HTTP), not a defect fix. It is split as a separate +decision for the maintainer (recorded in the "Progress Log": he approved all three fields). + +### Evidence on real clients and other trackers + +Collected by a research subagent reading raw sources (links verified by it, not re-fetched by the +author, except where noted). Nothing here is claimed from memory. + +| Finding | Source | Verdict | +| ------- | ------ | ------- | +| BEP 15: `downloaded`, `left`, `uploaded` are "64-bit integer"; `num_want` "-1 // default"; errors are action 3. Silent on negatives and unknown size. | | Spec does not forbid or define negatives | +| libtorrent, no metadata yet: `req.left = value_or(bytes_left(), 16*1024)`; writes int64 | `src/torrent.cpp`, `src/udp_tracker_connection.cpp` (RC_2_0), | Sends positive 16384, never negative | +| Transmission, no metainfo: `leftUntilComplete = has_metainfo() ? total_size() - has_total() : INT64_MAX` | `libtransmission/announcer.cc` ~l.940, `announcer-udp.cc` ~l.248, | Sends INT64_MAX, never negative | +| opentracker: only tests whether `left` is zero | `ot_udp.c` l.113-139 (a mirror, ; upstream not reachable) | Accepts; negative = leecher | +| aquatic_udp: parses i64; Seeding if `left == 0` else Leeching; no validation found | `crates/udp/src/swarm.rs` l.741-752, | Accepts; negative = leecher | +| chihaya: reads `left` as unsigned (`Uint64`) then `SanitizeAnnounce` (not read) | `frontend/udp/parser.go`, | Negative becomes a huge number; rejection unverified | +| webtorrent bittorrent-tracker: parses to a double, no range check | `lib/server/parse-udp.js`, | Accepts | + +Reading of the evidence: no client checked sends a negative `left` (the two magnet-link cases send +`16384` and `INT64_MAX`, both non-negative and accepted by the strict rule). No tracker checked +rejects negatives, so strict is stricter than the ecosystem; opentracker and aquatic treat a +negative as a leecher, which is the lenient alternative. Not verified: qBittorrent, Deluge, +rtorrent, aria2 (qBittorrent uses libtorrent, an unverified inference); BEP 3 text; chihaya's +sanitizer; any known bug report (none found). + +## Scope + +### In Scope + +- Reject, in the UDP announce path, a request with negative `left` (and, if approved, `uploaded` + and `downloaded`) with an error response carrying the request's transaction id. +- The rejected announce must not register a peer or change any swarm statistic. +- Emit the existing UDP error event/log for the rejection, so operators can see how often real + clients trip it (the evidence-collection mechanism; no new metric type). +- Tests at the UDP handler boundary and at the `udp-core` service boundary. + +### Out of Scope + +- Changing `peer::Peer::is_seeder` or `NumberOfBytes` (signed domain type; stays as is). The + primitives tests work (issue #2824) plans a characterization test for it; that test is not in + the tree at the time of writing. +- `num_want`, ids, `key`, `event` handling. +- The repo-wide "strict by default on inbound protocol values" ADR (separate work; this issue is + its first case and cites it once it exists). + +## Architectural Decisions + +- Related ADRs: `docs/adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md` + (outbound values); the planned inbound-tolerance ADR (`inbound-tolerance-adr`, not yet merged). +- ADRs to create: None known. + +Proposed design: validate in `udp-core` `AnnounceService::handle_announce`, after cookie validation +and before whitelist authorization (so a bad request reveals nothing about the whitelist), with a +new `UdpAnnounceError` variant (`NegativeNumberOfBytes { field, value }`). The error maps to an +`ErrorResponse` through the existing handler error path. + +Alternatives considered: + +- (a) Validate in the `udp-protocol` decoder. Not chosen for this patch. An earlier version of this + spec said the decoder's parse errors drop the transaction id; that was wrong: + `Request::parse_bytes` already returns sendable errors for port 0 and invalid events. The + maintainer accepted the service-level check as a tactical patch, and a follow-up EPIC will + decide the layer. +- (b) Make the domain `NumberOfBytes` non-negative. Wide blast radius (HTTP, REST and UDP use the + signed type); deferred to the same follow-up EPIC. + +## Design and Ownership Review + +Not applicable. + +## Bug-Fix Process + +Follows [fix-bug](../../../../.github/skills/dev/debugging/fix-bug/SKILL.md): + +1. Analysis: hypothesis above (no validation between wire decode and `Peer`). +2. Reproduction against the real tracker over a UDP socket, then at the handler boundary + (`evidence/udp_announce_probe.py`; results in `manual-verification-evidence.md`). +3. Regression-test boundary: the `udp-server` handler test (UDP boundary the maintainer asked for) + plus a `udp-core` service test for the exact error variant. +4. Red commit (`test(udp-server): ...`), then a separate `fix(udp-core): ...` commit. +5. Green, then the like-for-like real-artifact recheck. + +## Regression Test Strategy + +- Handler test + `handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left` + (already written, red: the announce returns `Ok` with `seeders: 1`). +- At the fix: the handler test asserts the exact error variant and that the failure carries the + request's transaction id (the shared handler error path turns it into the `ErrorResponse`); + `udp-core` tests cover `uploaded` and `downloaded`, the boundaries (`0`, `16384` and `i64::MAX` + accepted; `-1` and `i64::MIN` rejected) and the placement (after cookie validation, before the + whitelist). No IPv6 case: the check runs before any use of the client address. + +## Implementation Plan + +| ID | Status | Task | Notes / Expected Output | +| --- | ------ | ------------------------------------------------------------- | -------------------------------------------- | +| T1 | DONE | Reproduce over UDP and record evidence | `manual-verification-evidence.md` V1 | +| T2 | DONE | Add red handler test for negative `left` | Test fails: announce returns `Ok` | +| T3 | DONE | Fix: validation + error variant in `udp-core` | Red test green; exact variant asserted | +| T4 | DONE | Extend tests (uploaded/downloaded, boundaries, placement) | Per approved field scope; no IPv6 case | +| T5 | DONE | Green run and like-for-like recheck over UDP | V2 in evidence file | +| T6 | DONE | Document the behavior | Error text and spec; no UDP docs list per-field validation | + +## Commit Points + +| Task | Coherent change set | Commit policy | +| ---- | ---------------------------------------------------- | ---------------------------------------------------- | +| T1-2 | Spec, evidence and red test | Commit after focused validation and required review. | +| T3 | `fix(udp-core)`: reject negative bytes | Commit after focused validation and required review. | +| T4 | Extra tests | Commit after focused validation and required review. | + +## Progress Tracking + +### Workflow Checkpoints + +- [x] Folder-style spec drafted in `docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md` +- [x] Spec reviewed and approved by user/maintainer +- [x] GitHub issue created and issue number added to this spec +- [ ] Implementation completed (superseded: done on the branch of PR #2839, which was not merged; the implementation is now issue #2850) +- [ ] Automatic verification completed (`linter all`, relevant tests, and any pre-push checks) (superseded: ran on the branch of PR #2839, not merged) +- [ ] Manual verification scenarios executed and recorded in issue-local `manual-verification-evidence.md` (superseded: V1 and V1b describe `develop`; V2 ran on the branch of PR #2839, not merged) +- [ ] Acceptance criteria reviewed after implementation and updated with evidence (superseded: reviewed against the branch of PR #2839, not merged) +- [ ] Implementation completion review recorded +- [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` + +### Progress Log + +- 2026-11-11 17:30 UTC - Claude Code (Claude Sonnet 5.5) - Spec drafted, defect reproduced, red test added; awaiting maintainer decision. +- 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. + +## Acceptance Criteria + +Superseded (PR #2839, not merged): these criteria were met on the branch of PR #2839 only. None is +met on `develop`. Issue #2850 carries the criteria for the fix. + +- [ ] AC1: a UDP announce with `left < 0` gets an error response (action 3) with the request's + transaction id, and no peer is registered. +- [ ] AC2: same for `uploaded < 0` and `downloaded < 0` (if approved). +- [ ] AC3: `left = 0`, `left = i64::MAX`, and `num_want = -1` are still accepted. +- [ ] AC4: the rejection emits the existing UDP error event and log. +- [ ] `linter all` exits with code `0` +- [ ] Relevant tests pass +- [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` + +## Verification Plan + +### Automatic Checks + +- `linter all` +- `cargo test -p torrust-tracker-udp-core -p torrust-tracker-udp-server` + +### Manual Verification Scenarios + +| ID | Scenario | Human-oriented command/steps | Expected Result | Status | Evidence | +| --- | ------------------------------------------ | -------------------------------------------------------------- | ------------------------------------- | ------ | -------------------------------------------- | +| M1 | Negative `left` over UDP (before the fix) | Run the tracker; `python3 -I evidence/udp_announce_probe.py` | Reproduced: response with seeders = 1 | DONE | `manual-verification-evidence.md` section V1 | +| M2 | Same probe after the fix | Same command on the fixed build | Error response, seeders = 0 | TODO | Superseded (PR #2839, not merged): `manual-verification-evidence.md` section V2 ran on the branch of PR #2839 | + +### Disposable Verification Scripts + +- `evidence/udp_announce_probe.py`: sends one connect and one announce with chosen `left`. Python + because it is a throwaway raw-socket probe of one packet, not product behavior; the durable check + is the Rust handler test. Owner: this issue's author; remove at close-out. + +### Acceptance Verification + +| AC ID | Status | Evidence | +| ----- | ------ | -------- | +| AC1 | TODO | Superseded (PR #2839, not merged). On that branch: udp-core `it_should_reject_a_negative_number_of_bytes`; udp-server handler test; V2 | +| AC2 | TODO | Superseded (PR #2839, not merged). On that branch: same tests, `uploaded`/`downloaded` cases; V2 | +| AC3 | TODO | Superseded (PR #2839, not merged). On that branch: `it_should_accept_a_non_negative_number_of_bytes_left` (0, 16384, i64::MAX) | +| AC4 | TODO | Superseded (PR #2839, not merged). On that branch: V2 log lines; `it_should_classify_a_negative_number_of_bytes_in_an_announce_as_a_bad_request` | + +The tests named above exist only on the branch `2838-udp-reject-negative-announce-bytes`; they are +not in the tree. + +## Risks and Trade-offs + +- A client that sends a negative `left` for an unknown size would start failing. Evidence shows + libtorrent (16384) and Transmission (INT64_MAX) do not; other clients are unverified. Mitigation: + the rejection is logged and counted through the existing UDP error event, so a regression report + is visible, and the check is a single revertible condition. +- Stricter than every tracker examined; accepted by the maintainer's decision. + +## Implementation Completion Review + +- Retrospective: `Not yet assessed` + +## References + +- EPIC #1347 (primitives tests, finding F6) +- Related ADRs: `docs/adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md` diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/probe-after-fix.txt b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/probe-after-fix.txt new file mode 100644 index 0000000000..fae09e375a --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/probe-after-fix.txt @@ -0,0 +1,15 @@ +16:32:52.528 start: python3 -I evidence/udp_announce_probe.py 6868 1000 +announce response: interval=120 leechers=1 seeders=0 +16:32:52.540 end +16:32:52.543 start: python3 -I evidence/udp_announce_probe.py 6868 -5 +action=3 message='tracker announce error: Invalid announce request: `left` must not be negative, got -5' +16:32:52.555 end +16:32:52.557 start: python3 -I evidence/udp_announce_probe.py 6868 0 +announce response: interval=120 leechers=0 seeders=1 +16:32:52.570 end +16:32:52.572 start: python3 -I 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' +16:32:52.585 end +16:32:52.588 start: python3 -I 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' +16:32:52.600 end diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/probe-before-fix.txt b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/probe-before-fix.txt new file mode 100644 index 0000000000..6002f43a17 --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/probe-before-fix.txt @@ -0,0 +1,9 @@ +17:28:55.118 +left=1000 +announce response: interval=120 leechers=1 seeders=0 +17:28:55.132 +left=-5 +announce response: interval=120 leechers=0 seeders=1 +17:28:55.145 +left=0 +announce response: interval=120 leechers=0 seeders=1 diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/red-test-output.txt b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/red-test-output.txt new file mode 100644 index 0000000000..02e6ffcccd --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/red-test-output.txt @@ -0,0 +1,8 @@ +thread 'handlers::announce::tests::announce_request::using_ipv4::it_should_reject_an_announce_with_a_negative_number_of_bytes_left' (1728527) 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 + +-- +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 223 filtered out; finished in 0.02s + +error: test failed, to rerun pass `-p torrust-tracker-udp-server --lib` diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/tracker-log-after-fix.txt b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/tracker-log-after-fix.txt new file mode 100644 index 0000000000..8b35569c13 --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/tracker-log-after-fix.txt @@ -0,0 +1,3 @@ +2026-11-12T16:32:52.551837Z ERROR process_request:handle_packet{server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } connection_id_validation=Strict request_id="8c12f0e4-869e-41a1-9167-cd68cd05c118"}:handle_error{req_kind=Some(Announce { announce_request: AnnounceRequest { connection_id: ConnectionId(I64(6317256492440616017)), 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:37317 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=8c12f0e4-869e-41a1-9167-cd68cd05c118 cookie_valid_range=1794501051.551796..1794501173.551796 error=AnnounceFailed { 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:37317 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=8c12f0e4-869e-41a1-9167-cd68cd05c118 transaction_id=4321 +2026-11-12T16:32:52.581471Z ERROR process_request:handle_packet{server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } connection_id_validation=Strict request_id="74334122-f76a-4914-88c1-90c4b5745cca"}:handle_error{req_kind=Some(Announce { announce_request: AnnounceRequest { connection_id: ConnectionId(I64(-712296129322009379)), 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:43037 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=74334122-f76a-4914-88c1-90c4b5745cca cookie_valid_range=1794501051.5814247..1794501173.5814247 error=AnnounceFailed { 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:43037 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=74334122-f76a-4914-88c1-90c4b5745cca transaction_id=4321 +2026-11-12T16:32:52.596784Z ERROR process_request:handle_packet{server_service_binding=ServiceBinding { protocol: UDP, bind_address: 127.0.0.1:6868 } connection_id_validation=Strict request_id="fcf58cb0-9978-4132-989b-f4dfb1f58b3a"}:handle_error{req_kind=Some(Announce { announce_request: AnnounceRequest { connection_id: ConnectionId(I64(6588044239080337533)), 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:37907 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=fcf58cb0-9978-4132-989b-f4dfb1f58b3a cookie_valid_range=1794501051.5967395..1794501173.5967395 error=AnnounceFailed { 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:37907 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=fcf58cb0-9978-4132-989b-f4dfb1f58b3a transaction_id=4321 diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/tracker.toml b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/tracker.toml new file mode 100644 index 0000000000..4c96c1190a --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/tracker.toml @@ -0,0 +1,42 @@ +# skill-link: run-tracker-locally +# skill-link: use-rest-api +[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 = "/tmp/claude-1000/run/sqlite3.db" + +[udp_tracker_server] +ip_bans_reset_interval_in_secs = 86400 +max_connection_id_errors_per_ip = 10 +connection_id_validation = "strict" + +# How long the tracker takes to stop after SIGTERM or SIGINT. The values are the defaults. +# `max(http_drain_in_secs, udp_request_drain_in_secs) + event_listener_drain_in_secs` must be +# below `deadline_in_secs`; the tracker refuses to start otherwise. +[application.shutdown] +deadline_in_secs = 25 +http_drain_in_secs = 15 +udp_request_drain_in_secs = 5 +event_listener_drain_in_secs = 5 + +[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 diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py new file mode 100644 index 0000000000..d28d9e95f9 --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py @@ -0,0 +1,63 @@ +"""Disposable probe: send one UDP connect + one announce with a chosen signed `left`. + +Usage: python3 -I udp_announce_probe.py [uploaded] [downloaded] +Prints the announce response (action, seeders, leechers) or the error message. +Exits with status 1, without printing a result, when a response does not carry the +transaction id of its request. Also exits with status 1, printing the decoded error +message, when the connect response's action is not 0, and, printing the length, when a +response is shorter than the fields it must carry. +""" +import socket +import struct +import sys + +port, left = int(sys.argv[1]), int(sys.argv[2]) +uploaded = int(sys.argv[3]) if len(sys.argv) > 3 else 0 +downloaded = int(sys.argv[4]) if len(sys.argv) > 4 else 0 + +s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +s.settimeout(3) +addr = ("127.0.0.1", port) + +CONNECT_TID, ANNOUNCE_TID = 1234, 4321 + + +def check_transaction_id(name, sent, received): + if received != sent: + sys.exit(f"{name}: transaction id mismatch: sent {sent}, received {received}") + + +def check_length(name, data, minimum): + if len(data) < minimum: + sys.exit(f"{name}: response too short: {len(data)} bytes, expected at least {minimum}") + + +s.sendto(struct.pack(">qii", 0x41727101980, 0, CONNECT_TID), addr) +connect_response = s.recvfrom(64)[0] +check_length("connect", connect_response, 8) +action, tid = struct.unpack(">ii", connect_response[:8]) +check_transaction_id("connect", CONNECT_TID, tid) +if action != 0: + sys.exit(f"connect: action={action} message={connect_response[8:].decode(errors='replace')!r}") +check_length("connect", connect_response, 16) +(connection_id,) = struct.unpack(">q", connect_response[8:16]) + +packet = struct.pack( + ">qii20s20sqqqiIiiH", # cspell:disable-line + connection_id, 1, ANNOUNCE_TID, + b"\x11" * 20, b"-XX0001-000000000000", + downloaded, left, uploaded, + 2, # event: started + 0, 7, -1, 6881, +) +s.sendto(packet, addr) +data = s.recvfrom(2048)[0] +check_length("announce", data, 8) +action, tid = struct.unpack(">ii", data[:8]) +check_transaction_id("announce", ANNOUNCE_TID, tid) +if action == 1: + check_length("announce", data, 20) + interval, leechers, seeders = struct.unpack(">iii", data[8:20]) + print(f"announce response: interval={interval} leechers={leechers} seeders={seeders}") +else: + print(f"action={action} message={data[8:].decode(errors='replace')!r}") diff --git a/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/manual-verification-evidence.md b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/manual-verification-evidence.md new file mode 100644 index 0000000000..bb2f653093 --- /dev/null +++ b/docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/manual-verification-evidence.md @@ -0,0 +1,141 @@ +--- +doc-type: manual-verification-evidence +issue-spec: docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md +last-updated-utc: "2026-11-14 08:07" +--- + +# Manual Verification Evidence + +## Environment and Prerequisites + +- Date and time (UTC): 2026-11-11 17:28-17:30 +- Artifact under test: `develop` plus the `test(udp-server): reject a negative left in an announce (red)` patch + (no production change); debug build of `torrust-tracker` (`cargo build --bin torrust-tracker`). +- Operating system: Linux 7.0.0-43-generic; stable Rust toolchain, rustc 1.99.1. +- Setup: tracker config [`evidence/tracker.toml`](evidence/tracker.toml) (the shipped + `tracker.development.sqlite3.toml` with a temp database, HTTP/API removed, UDP on + `127.0.0.1:6868`); probe [`evidence/udp_announce_probe.py`](evidence/udp_announce_probe.py). +- Replay prerequisite, added after the recorded runs: the configuration stores the database in + `/tmp/claude-1000/run/sqlite3.db` and the tracker does not create the parent directory. Create + it first with `mkdir -p /tmp/claude-1000/run`, or change `path` in the configuration. +- Replay-only adjustment of the configuration, made after the recorded runs: the second UDP + listener on `0.0.0.0:6969` was removed from `evidence/tracker.toml`. No probe used it (all target + `127.0.0.1:6868`), and it exposed the replay tracker beyond localhost. The recorded runs were + made with it present and are unaffected. +- The probe was changed after the recorded runs: it now exits with status 1 when a response does + not carry the transaction id of its request, and also when the connect response's action is not + 0 (it then prints the decoded error message instead of unpacking a connection id from a short or + error packet). It also exits with status 1, printing the length, when a response is shorter + than the fields it must carry. Its output for a correct response is unchanged. + +## Verification Processes + +### V1 - Negative `left` over UDP (before the fix) + +- Goal: observe whether the UDP tracker accepts `left = -5` and counts the peer as a seeder. +- Initial state: fresh tracker, empty database. +- Status: `DONE` +- Outcome: **Reproduced** (the wrong outcome itself was observed). + +#### Steps Performed + +1. `TORRUST_TRACKER_CONFIG_TOML_PATH= ./target/debug/torrust-tracker` +2. For `left` in `1000`, `-5`, `0`: + `python3 -I evidence/udp_announce_probe.py 6868 ` + (same info hash, same peer id, `event = started`, so each announce replaces the peer). + +#### Observed Result + +Full output: [`evidence/probe-before-fix.txt`](evidence/probe-before-fix.txt). + +```text +left=1000 +announce response: interval=120 leechers=1 seeders=0 +left=-5 +announce response: interval=120 leechers=0 seeders=1 +left=0 +announce response: interval=120 leechers=0 seeders=1 +``` + +#### Conclusion + +`left = -5` is accepted and the peer is counted as a seeder, identically to `left = 0`. Expected +after the fix: an error response (action 3) and no peer registered. + +### V1b - Red regression test at the UDP handler boundary + +- Boundary: `udp-server` handler test; it is the smallest deterministic test at the UDP boundary + that runs the real announce service and in-memory repository. +- Command: `cargo test -p torrust-tracker-udp-server --lib negative_number_of_bytes_left` + (stable toolchain). Output: [`evidence/red-test-output.txt`](evidence/red-test-output.txt). + +```text +a negative `left` must be rejected, got: Ok(AnnounceIpv4(AnnounceResponse { ... leechers: 0, seeders: 1 ... })) +test result: FAILED. 0 passed; 1 failed +``` + +### V2 - Final like-for-like recheck (after the fix) + +> Superseded (PR #2839, not merged): this run used a tracker built from the branch of PR #2839. +> That fix is not on `develop`, where the behaviour is still the one of V1. The recheck is repeated +> by issue #2850 against its own implementation. + +- Status: `DONE` +- Date and time (UTC): 2026-11-12 16:32 +- Build: a clean tree (`git status --short` printed nothing before the build) at the commit + `fix(udp-server): [#2838] classify a negative byte count as a bad request`, which is the last + production change and follows `fix(udp-core): [#2838] reject a negative number of bytes in an + announce` and `refactor(udp-core): [#2838] type the rejected byte-count field`; + `cargo build --bin torrust-tracker`, stable Rust toolchain, same config and probe as V1. +- An earlier run of this recheck (2026-11-12 09:12) was made on an uncommitted tree before the + review fixes; it is superseded by this one. + +#### Steps Performed + +1. `TORRUST_TRACKER_CONFIG_TOML_PATH=evidence/tracker.toml ./target/debug/torrust-tracker` +2. The five probe commands below, one after another (each announce replaces the same peer). The + probe arguments are ` [uploaded] [downloaded]`. + +#### Observed Result + +Probe output with step times, verbatim from +[`evidence/probe-after-fix.txt`](evidence/probe-after-fix.txt): + +```text +16:32:52.528 start: python3 -I evidence/udp_announce_probe.py 6868 1000 +announce response: interval=120 leechers=1 seeders=0 +16:32:52.540 end +16:32:52.543 start: python3 -I evidence/udp_announce_probe.py 6868 -5 +action=3 message='tracker announce error: Invalid announce request: `left` must not be negative, got -5' +16:32:52.555 end +16:32:52.557 start: python3 -I evidence/udp_announce_probe.py 6868 0 +announce response: interval=120 leechers=0 seeders=1 +16:32:52.570 end +16:32:52.572 start: python3 -I 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' +16:32:52.585 end +16:32:52.588 start: python3 -I 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' +16:32:52.600 end +``` + +Tracker log: `grep -c "must not be negative"` on the tracker log printed `3`, one line per +rejection. The three lines are in +[`evidence/tracker-log-after-fix.txt`](evidence/tracker-log-after-fix.txt); the first, shortened +(the request dump is elided): + +```text +2026-11-12T16:32:52.551837Z ERROR process_request:handle_packet{...}:handle_error{req_kind=Some(Announce { ... bytes_left: NumberOfBytes(I64(-5)) ... }) ... error=AnnounceFailed { 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:37317 server_socket_addr=127.0.0.1:6868 service_binding=udp://127.0.0.1:6868 request_id=8c12f0e4-869e-41a1-9167-cd68cd05c118 transaction_id=4321 +``` + +Green tests on the same tree: `cargo test -p torrust-tracker-udp-core -p torrust-tracker-udp-server --lib` +(stable toolchain): 108 passed and 225 passed, 0 failed. + +#### Conclusion + +The symptom observed in V1 is gone; valid values (`left` 0 and 1000) behave as before. The UDP +error event classification (`ErrorKind::BadRequest`) is covered by a unit test, not by this run. + +## Failures and Follow-up + +None. diff --git a/docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md b/docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md new file mode 100644 index 0000000000..0356582f76 --- /dev/null +++ b/docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md @@ -0,0 +1,154 @@ +--- +schema-version: 1 +doc-type: issue +issue-type: task +status: planned +priority: p2 +epic: null +github-issue: 2842 +spec-path: docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md +branch: "2842-inbound-tolerance-adr" +related-pr: null +last-updated-utc: "2026-11-12 17:41" +semantic-links: + skill-links: + - create-issue + - create-adr + related-artifacts: + - .github/skills/dev/planning/create-issue/SKILL.md + - .github/skills/dev/planning/create-adr/SKILL.md + - docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md +--- + + + +# Issue #2842 - ADR: reject malformed inbound protocol values unless real clients need the tolerance + +## Goal + +Record a repository-level ADR that says when the tracker tolerates a non-conforming client request +and when it rejects it, so UDP and HTTP stop disagreeing by accident. + +## Background + +Found while writing the `primitives` tests for EPIC #1347. The UDP announce accepts a negative +`left` (signed 64-bit on the wire), while HTTP rejects it, and `Peer::is_seeder` treats a negative +`left` as a seeder. Bug #2838 is that case; its fix (issue #2850) needs a rule to +apply. No ADR covers inbound values: the existing +[tightest-protocol ADR](../../../adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md) +covers values the tracker sends. + +Maintainer position (2026-11-11): tolerant implementations accept the widest range of clients, +but the maintainer prefers strictness to encourage good implementations, unless a meaningful +share of real clients relies on the tolerant behavior. + +## Scope + +### In Scope + +- One ADR in `docs/adrs/` with the rule, a register of tolerances (empty), and an inventory of the + existing inbound leniencies found in `http-protocol`, `udp-protocol` and `udp-server`. +- The row in `docs/adrs/index.md`. + +### Out of Scope + +- Any production-code change, including the `left` fix, the rejection metrics, and aligning the + other inventory items. Each becomes its own issue after the ADR is merged. + +## Architectural Decisions + +- Related ADRs: the tightest-protocol, value-invariant, newtype, protocol/domain decoupling, + scrape-cap and announce-`ip` ADRs (linked from the ADR). +- ADRs to create: `20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md`. + +## Design and Ownership Review + +Not applicable. + +## Bug-Fix Process + +Not applicable. + +## Regression Test Strategy + +Not applicable. + +## Implementation Plan + +| ID | Status | Task | Notes / Expected Output | +| --- | ------ | -------------------------------------------- | ------------------------------------------------- | +| T1 | DONE | Draft the ADR and inventory | ADR file written, inventory checked against code | +| T2 | TODO | Maintainer review and decisions | Open questions in the PR resolved | +| T3 | TODO | Index row, `linter all`, PR | Docs-only PR, `Closes #` | +| T4 | TODO | Propose follow-up issues from the inventory | One issue per leniency to apply the rule | + +## Commit Points + +| Task | Coherent change set | Commit policy | +| ---- | ------------------------------------ | ---------------------------------------------------- | +| T1 | ADR file plus index row | Commit after `linter all`. | +| T3 | Issue spec moved to `docs/issues/open/` | Commit after `linter all`. | + +## Progress Tracking + +### Workflow Checkpoints + +- [x] Folder-style spec drafted in `docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md` +- [x] Spec reviewed and approved by user/maintainer +- [x] GitHub issue created and issue number added to this spec +- [ ] Implementation completed +- [ ] Automatic verification completed (`linter all`) +- [ ] Acceptance criteria reviewed after implementation and updated with evidence +- [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` + +### Progress Log + +- 2026-11-11 17:10 UTC - Claude Code (Claude Sonnet 5.5) - Drafted spec and ADR. +- 2026-11-12 14:00 UTC - Claude Code (Claude Sonnet 5.5) - Maintainer approved the spec; issue #2842 created. +- 2026-11-12 17:41 UTC - Claude Code (Fable 5.2) - The maintainer decided that this ADR is delivered by the spec-only pull request of issue #2850, its first application, instead of PR #2843. The four commits of PR #2843 were carried over unchanged; a following commit points the ADR at issue #2850. + +## Acceptance Criteria + +- [ ] AC1: The ADR states the rule (strict by default, evidence-based tolerance, recorded in code + and ADR, measurable, same over every delivery protocol, decided per field). +- [ ] AC2: The ADR cites bug #2838 and its fix, issue #2850, as the first application and the existing + related ADRs. +- [ ] AC3: The inventory matches the current code (each row verified or marked "to verify"). +- [ ] AC4: No production code changes. +- [ ] `linter all` exits with code `0` + +## Verification Plan + +### Automatic Checks + +- `linter all` (markdown, cspell, links) + +### Manual Verification Scenarios + +Not applicable: documentation-only change, no behavior to exercise. + +### Acceptance Verification + +| AC ID | Status | Evidence | +| ----- | ------ | -------- | +| AC1 | TODO | ADR PR | +| AC2 | TODO | ADR PR | +| AC3 | TODO | ADR PR | +| AC4 | TODO | PR diff | + +## Risks and Trade-offs + +- The inventory can go stale; it is labeled as a snapshot and each row links to its follow-up. +- The rule commits the project to adding a rejection metric; that work is tracked separately. + +## Implementation Completion Review + +- Retrospective: `Not yet assessed` + +## References + +- Related issues: #1347 (EPIC), #2838 (the bug), #2850 (its fix, whose spec-only pull request + delivers this ADR) +- Related PRs: #2843 (first pull request of this ADR, closed without merging; its commits were + carried over) +- Related ADRs: `docs/adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md` 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 new file mode 100644 index 0000000000..a6b4050527 --- /dev/null +++ b/docs/issues/open/2850-non-negative-number-of-bytes/ISSUE.md @@ -0,0 +1,920 @@ +--- +schema-version: 1 +doc-type: issue +issue-type: bug +status: planned +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" +related-pr: null +last-updated-utc: "2026-11-14 08:47" +semantic-links: + skill-links: + - create-issue + - fix-bug + related-artifacts: + - .github/skills/dev/debugging/fix-bug/SKILL.md + - .github/skills/dev/planning/create-issue/SKILL.md + - packages/primitives/src/number_of_bytes.rs + - packages/primitives/src/peer.rs + - packages/udp-protocol/src/request.rs + - packages/udp-protocol/src/common.rs + - packages/udp-core/src/peer_builder.rs + - packages/udp-core/src/services/announce.rs + - packages/http-protocol/src/v1/requests/announce.rs + - packages/http-core/src/services/announce.rs + - packages/rest-api-runtime-adapter/src/v1/conversion.rs + - packages/rest-api-protocol/src/v1/context/torrent/resources/peer.rs + - packages/udp-server/src/event.rs + - packages/udp-server/src/handlers/announce.rs + - packages/udp-server/src/handlers/error.rs + - packages/http-core/benches/helpers/util.rs + - packages/axum-http-server/src/lib.rs + - docs/packages.md + - deny.toml + - docs/adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md + - docs/adrs/20261005124222_cap_scrape_info_hashes_per_protocol.md + - docs/adrs/20261005145329_return_result_only_for_concretely_fallible_public_apis.md + - docs/adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md + - docs/adrs/20260721100000_use_newtypes_for_constrained_configuration_field_types.md + - docs/adrs/20260723184019_separate_configuration_value_invariants_from_consistency_validation.md + - docs/adrs/20260629000000_adopt_independent_package_versioning.md + - docs/adrs/20260727000000_events_are_objective_facts.md + - .github/skills/dev/rust-code-quality/handle-errors-in-code/SKILL.md + - docs/benchmarking.md + - docs/issues/open/2824-1347-add-tests-primitives/ISSUE.md + - docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/ISSUE.md + - docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/manual-verification-evidence.md + - docs/issues/open/2842-inbound-tolerance-adr/ISSUE.md + - docs/adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md + - docs/issues/open/1347-overhaul-packages-testing/EPIC.md + - docs/issues/open/2583-1669-first-publish-of-workspace-crates/ISSUE.md + - docs/issues/closed/1835-1669-14-decouple-http-protocol-from-tracker-primitives/ISSUE.md + - docs/issues/closed/2417-2411-verify-http-scrape-info-hash-limit/ISSUE.md + - docs/issues/closed/2454-1669-mark-public-error-enums-non-exhaustive/ISSUE.md + - docs/issues/closed/2245-2243-review-numeric-protocol-wire-conversions/ISSUE.md + - docs/issues/drafts/generalize-error-events/EPIC.md + - docs/issues/drafts/remove-source-locations-from-errors/EPIC.md +--- + + + +# Issue #2850 - Make the number of bytes non-negative by construction + +## Goal + +A negative number of bytes cannot exist inside the tracker. The domain type +`torrust_tracker_primitives::NumberOfBytes` and the HTTP protocol type cannot hold one, each +delivery protocol refuses one as early as its public specification allows, and no standalone +validation function is needed to keep the rule. + +This issue is the fix for the bug of issue #2838, at its root. The general rules behind it are +recorded in the [ADR of issue #2842](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md) (see D5), so the next field with the same problem is +solved the same way. + +## Background + +Issue #2838 found that a UDP announce with a negative `left` is accepted and counted as a seeder, +while the HTTP tracker refuses the same value +([specification of #2838](../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md)). PR #2839 proposed a tactical patch: a +`validate_number_of_bytes` function in `packages/udp-core/src/services/announce.rs` that returns +`UdpAnnounceError::NegativeNumberOfBytes`. The maintainer decided to fix the root cause instead, so +that patch was not merged and the bug is still on `develop`. The root cause: + +- **The domain type allows the invalid value.** `NumberOfBytes` is `pub struct NumberOfBytes(pub i64)` + with an infallible `new` (`packages/primitives/src/number_of_bytes.rs`). Any code can build a + negative count. +- **Domain logic compensates for it.** `Peer::is_seeder` is `left.0 <= 0 && event != Stopped`, in + three places in `packages/primitives/src/peer.rs` (lines 217, 243 and 270). The `<= 0` is how a + negative `left` became a seeder. +- **A validation function does not remove the cause.** With the patch, nothing in the types would + force a new caller of `peer_builder::from_request` to call `validate_number_of_bytes` first, and + the value would be refused beside the wire-to-domain conversion, not by it. +- **HTTP has the same weakness in its type.** `packages/http-protocol` parses a `u64`, but stores it + in its own `NumberOfBytes(pub i64)`. The parser protects the rule; the type does not. + +The maintainer's rule: fail as soon as possible, in layers. The delivery layer validates syntax, +the service validates application invariants, and the domain validates domain invariants. +Invariants are protected by constructors or newtypes, not by standalone validation functions. + +One rule has priority over failing fast (maintainer, 2026-11-12): **a public protocol specification +is implemented strictly.** A type that mirrors a BEP keeps the shape the BEP gives it, also when it +can then carry a value the domain considers invalid. The specification is not the project's +decision, and the reasons behind it may be unknown. In that case the value is refused at the first +conversion into a type the project owns, which is the earliest point the project controls. This +extends a principle that [docs/packages.md](../../../packages.md) already states: "`*-protocol` +packages strictly implement BEP specifications." + +### Current state (audit on `develop`, 2026-11-12) + +`grep -rn NumberOfBytes packages` finds 34 Rust files. They fall into these groups: + +| Group | Files | What they do | +| --- | --- | --- | +| Domain type | `primitives/src/number_of_bytes.rs`, `primitives/src/lib.rs` | Definition and re-export | +| Domain logic | `primitives/src/peer.rs` | Three `is_seeder` copies read `left.0 <= 0`; `ser_number_of_bytes` serializes with `serialize_i64`; a test builder takes `left: i64` | +| UDP wire type | `udp-protocol/src/common.rs`, `announce.rs`, `request.rs` | `NumberOfBytes(pub I64)`, a zero-copy map of the BEP 15 packet. Must stay `I64` | +| UDP wire to domain | `udp-core/src/peer_builder.rs` | `from_request` copies the three counters with `.0.get()`; infallible | +| UDP service | `udp-core/src/services/announce.rs` | No check on `develop`. PR #2839 (not merged) proposed: `fn validate_number_of_bytes`, called before `from_request`; `UdpAnnounceError::NegativeNumberOfBytes { field: ByteCountField, value: i64 }` with the message ``Invalid announce request: `{field}` must not be negative, got {value}``; `pub enum ByteCountField { Left, Uploaded, Downloaded }` | +| HTTP protocol type | `http-protocol/src/v1/requests/announce.rs` | Its own `NumberOfBytes(pub i64)` (lines 34 to 47); `extract_number_of_bytes_from_param` parses `u64`, then refuses values above `i64::MAX` with `NumberOfBytesOverflow` (lines 598 to 620); the builder methods `with_downloaded`, `with_uploaded` and `with_left` take a `u64` and panic above `i64::MAX` (lines 478 to 507); the query building reads `.0` (lines 366 to 374) | +| HTTP protocol to domain | `http-core/src/services/announce.rs` | `peer_from_request` copies with `.0` (lines 252 to 254) | +| REST API | `rest-api-runtime-adapter/src/v1/conversion.rs` | Reads `.0` into the resource fields `uploaded`, `downloaded`, `left`, which are `i64` (`rest-api-protocol/.../resources/peer.rs`) | +| Benchmarks | `http-core/benches/helpers/util.rs` | Reads `.0` to build a protocol request from a peer | +| Tests, fixtures, docs | The other files, in `tracker-core`, `swarm-coordination-registry`, `torrent-repository-benchmarking`, `udp-core`, `udp-server`, `axum-http-server`, `http-core` | About 130 calls of `NumberOfBytes::new()` with `0`, `1`, `10`, `1000` and similar | + +Public `.0` access to the domain type, outside tests: `primitives/src/peer.rs` (4 places), +`rest-api-runtime-adapter/src/v1/conversion.rs` (3) and `http-core/benches/helpers/util.rs` (3). + +Values accepted from clients today: UDP accepts any `i64`, and a negative `left` becomes a seeder +(the bug). HTTP accepts `0` to `i64::MAX` and refuses a larger value with `NumberOfBytesOverflow`. + +Tests that exist today for the HTTP params (`http-protocol/src/v1/requests/announce.rs`, lines 889 +to 925) cover only a non-numeric value. No test covers a negative value, zero, the largest value or +the overflow. The crate documentation of `axum-http-server` (`src/lib.rs`, lines 48 to 52) calls +the three params "positive integer", although zero is valid. + +## Sources for the Decisions + +Several questions in the review of this specification already had an answer in an ADR or another +document that nobody remembered. This table maps each question to its source, so the implementer and +later readers start from the recorded decisions. + +| Question | Answer | Source | +| --- | --- | --- | +| Why are there three `NumberOfBytes` types? Is that duplication? | One type per layer, mapped at the boundaries; a single shared type was rejected | [Keep protocol and domain types decoupled](../../../adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md) (2026-05-27, commit `f7f29500d`); [issue #1835 specification](../../closed/1835-1669-14-decouple-http-protocol-from-tracker-primitives/ISSUE.md) | +| May a protocol type differ from what its BEP defines? | No. "`*-protocol` packages strictly implement BEP specifications" | [docs/packages.md](../../../packages.md), Package Conventions, principle 2 | +| Which way do dependencies point? | Servers, then core, then protocol, then domain; forbidden edges are checked by `cargo deny` | [docs/packages.md](../../../packages.md), Layer Boundary Enforcement; [deny.toml](../../../../deny.toml) | +| Must UDP and HTTP accept the same range for a value a client sends? | No. Each protocol has its own limit for its own reason, and the domain has none | [Cap scrape info hashes per protocol](../../../adrs/20261005124222_cap_scrape_info_hashes_per_protocol.md) (2026-10-05); [issue #2417 specification](../../closed/2417-2411-verify-http-scrape-info-hash-limit/ISSUE.md) | +| When is a value bounded by the tightest protocol? | Only a value the operator configures and every protocol sends, such as the announce interval | [Bound protocol-agnostic values by the tightest delivery protocol](../../../adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md) (2026-10-07) | +| How is a single-value invariant protected? | By a newtype that rejects the value at construction (decided for configuration values) | [Use newtypes for constrained configuration field types](../../../adrs/20260721100000_use_newtypes_for_constrained_configuration_field_types.md); [Separate configuration value invariants from consistency validation](../../../adrs/20260723184019_separate_configuration_value_invariants_from_consistency_validation.md) | +| Are wrapped inner errors public? When is an error enum `#[non_exhaustive]`? | Public and typed per package. `#[non_exhaustive]` when consumers only report or convert; exhaustive when variants select a recovery action. A generic `Box` is rejected | [Return `Result` only for concretely fallible public APIs](../../../adrs/20261005145329_return_result_only_for_concretely_fallible_public_apis.md) with its amendment of 2026-10-19; [issue #2454 specification](../../closed/2454-1669-mark-public-error-enums-non-exhaustive/ISSUE.md); the [`handle-errors-in-code` skill](../../../../.github/skills/dev/rust-code-quality/handle-errors-in-code/SKILL.md) | +| Why are packages treated as separate public APIs? | Each package is versioned and published on its own | [Adopt independent package versioning](../../../adrs/20260629000000_adopt_independent_package_versioning.md); [issue #2583 specification](../../open/2583-1669-first-publish-of-workspace-crates/ISSUE.md) | +| May an event carry an internal error type? | No. Events are objective facts with a stable payload | [Events are objective facts](../../../adrs/20260727000000_events_are_objective_facts.md); [general error-events EPIC draft](../../drafts/generalize-error-events/EPIC.md) | +| Is a questionable inbound value refused or tolerated? | Strict by default; a tolerance needs recorded evidence | [Reject malformed inbound protocol values unless real clients need the tolerance](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md), delivered by the spec-only pull request of this issue; [issue #2842 specification](../2842-inbound-tolerance-adr/ISSUE.md) | +| Which layer refuses a value the wire allows and the domain does not? What has priority over failing fast? | The first conversion into a type the project owns; a strict protocol specification has priority | The same ADR, points 6, 8 and 9 (decided in this review, D2) | +| Does any real client send a negative byte count? | None of the clients checked does: libtorrent sends `16384` and Transmission `i64::MAX` when the size is unknown | [Specification of #2838](../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md), "Evidence on real clients and other trackers" | +| What do the specifications say about the sign of the byte counts? | BEP 15 and BEP 3 do not say; the libtorrent document uses `int64_t` | [BEP 15](https://www.bittorrent.org/beps/bep_0015.html), [BEP 3](https://www.bittorrent.org/beps/bep_0003.html), [XBT Tracker](https://xbtt.sourceforge.net/udp_tracker_protocol.html), [libtorrent](https://www.libtorrent.org/udp_tracker_protocol.html); see "Research Findings" | +| Where were numeric wire conversions reviewed before? | The audit of every numeric conversion between wire and domain types | [issue #2245 specification](../../closed/2245-2243-review-numeric-protocol-wire-conversions/ISSUE.md) | + +Questions with no recorded answer, found in this review: + +| Question | State | +| --- | --- | +| When does an error stay typed and when is it replaced by a generic one for the user? How far do errors bubble up? | The maintainer's rules are not written in any ADR. Candidate for an ADR outside this issue | +| Why did the UDP protocol designers use a signed type for byte counts? | Unknown; not documented in the four sources | +| Does a client that was not checked send a negative byte count on purpose? | Unknown. The specification of #2838 lists the unchecked clients | + +## Research Findings + +### One type per layer is a recorded decision + +There are three types called `NumberOfBytes`, one per layer. This is intended and documented: + +| Layer | Type | Who defines its shape | +| --- | --- | --- | +| UDP delivery | `torrust_tracker_udp_protocol::NumberOfBytes(pub I64)` | The BEP 15 wire layout | +| HTTP delivery | `torrust_tracker_http_protocol` `NumberOfBytes(pub i64)` | The project; BEP 3 gives no width and no sign | +| Domain | `torrust_tracker_primitives::NumberOfBytes(pub i64)` | The project | + +The decision is +[Keep protocol and domain types decoupled](../../../adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md), +dated 2026-05-27. It was added in commit `f7f29500d` ("refactor(http-protocol): decouple protocol types +from domain primitives") for issue #1835, SI-14 of the packages overhaul EPIC #1669. It uses +`NumberOfBytes` as its example, says that the three types can look like accidental duplication but +have different reasons to change, and rejects a single shared type. The code cites the ADR in a +comment above the UDP and the HTTP type. + +That ADR says that adapters map between the types at the boundaries. It does not say which layer +refuses a value that the wire allows but the domain does not. The [ADR of issue #2842](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md) now does (D5). + +Maintainer constraint (2026-11-12): a type that represents a type defined by a BEP is not changed. +The delivery layer may therefore have to accept a value that makes no sense in the domain, and the +refusal happens when the value is converted into the next type the project owns. + +### What the specifications say about the sign + +Read on 2026-11-12: [BEP 15](https://www.bittorrent.org/beps/bep_0015.html), the original +[XBT Tracker document](https://xbtt.sourceforge.net/udp_tracker_protocol.html), the +[libtorrent document](https://www.libtorrent.org/udp_tracker_protocol.html) and +[BEP 3](https://www.bittorrent.org/beps/bep_0003.html). + +| Announce field | BEP 15 | XBT Tracker | libtorrent | +| --- | --- | --- | --- | +| `downloaded`, `left`, `uploaded` | 64-bit integer | 64-bit integer | `int64_t` | +| `num_want` | 32-bit integer | 32-bit integer | `int32_t` | +| `event`, `action`, `transaction_id` | 32-bit integer | 32-bit integer | `int32_t` | +| `ip`, `key` | 32-bit integer | 32-bit integer | `uint32_t` | +| `port` | 16-bit integer | 16-bit integer | `uint16_t` | + +- BEP 15 and the XBT Tracker document never say "signed" or "unsigned" for any field. +- The libtorrent document uses C types, so it is the source that makes the byte counts signed. + BEP 15 cites it in a footnote as an existing implementation. Its credits say the protocol was + designed by Olaf van der Spek (the author of BEP 15) and extended by Arvid Norberg. +- BEP 15 uses `-1` as the default of `num_want`, so "integer" in BEP 15 includes signed values at + least for that field. +- BEP 3 describes `uploaded`, `downloaded` and `left` only as "encoded in base ten ascii", with no + width and no sign. +- No document explains why a byte count is signed, and none says what a tracker must do with a + negative or out-of-range value. + +Conclusion: the UDP wire type `I64` follows the libtorrent reading, which is the de facto one, and +stays. Refusing a negative count is a decision of this project (#2838), not a rule of a BEP. Why the +protocol designers chose a signed type is not documented in these sources. + +### Why HTTP has an upper limit + +`NumberOfBytesOverflow` was added in commit `74ed59221` (2023-02-15, "feat(http): [#184] added +optional params to announce req in Axum implementation"). At that time the peer stored its counters +in `aquatic_udp_protocol::NumberOfBytes(pub i64)`, the UDP wire type, which the whole tracker used. +The new HTTP parser read a `u64` to refuse negative values and then had to fit the result into that +`i64`, so it needed an error for values that do not fit. The commit message and the code give no +other reason. + +The signed type itself came from the UDP side: commit `9d5833390` (2021-08-23) defined +`NumberOfBytes(pub i64)` and commit `fe5e8ea40` (2022-01-28) ported UDP to `aquatic_udp_protocol`. + +Conclusion: the limit is not a protocol rule or a policy. It is a consequence of the HTTP tracker +storing its values in a type borrowed from the UDP protocol. The types were decoupled in 2026 +(`f7f29500d`), but the `i64` and the limit were copied along. + +### Is a negative value ever meaningful? + +Question from the maintainer (2026-11-12): is it certain that no `NumberOfBytes` type ever needs a +negative value, for example as a sentinel? + +Inside the workspace (searched on `develop`, production code, tests, benches, examples and the +`tracker-client` console): + +- No code builds a domain or HTTP `NumberOfBytes` from a negative literal. Every literal is `0` or a + small positive number. +- No code uses a negative value as a sentinel ("unknown", "not set"). The HTTP protocol type + expresses "not sent" with `Option`. +- No arithmetic is done on a byte count. The domain type has no `Add`, `Sub` or ordering; it + derives only equality, hashing, `Clone`, `Copy` and `Debug`. So no subtraction can go below zero. +- The only code that depends on the sign is `Peer::is_seeder` (`left.0 <= 0`). +- The only sources of a negative value are the UDP wire (any `i64`) and two test helpers that take + an `i64`: the quickcheck generator of the UDP wire type (`udp-protocol/src/request.rs`), which + stays, and the `with_bytes_left_to_download(left: i64)` builder in `primitives/src/peer.rs`. +- The UDP checker of `tracker-client` takes `left: Option` + (`console/tracker-client/src/console/clients/udp/checker.rs`); the other client commands take a + `u64`. + +The type change itself is the test: with a `u64` inside, a negative literal or an `i64` passed to +the domain type does not compile, so any use that this search missed is found by the compiler +during the implementation, before any test runs. + +Outside the workspace, for clients in the wild, the evidence is in the +[specification of #2838](../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md), section "Evidence on real clients and other trackers". It was +collected from the client and tracker sources: + +- The case where a client does not know the size is a magnet link before the metadata arrives. + libtorrent then sends `left = 16384` and Transmission sends `left = i64::MAX`. Neither sends a + negative value. The tests written for PR #2839 cover each value; this issue takes them over. +- No client that was checked sends a negative `left`. That specification lists the clients that + were not checked. +- No tracker that was checked refuses a negative value: opentracker and aquatic treat it as a + leecher. Refusing is stricter than the ecosystem; the maintainer decided it in #2838. +- The specifications define no meaning for a negative count (table above). +- The HTTP tracker has refused negative values since it parses a `u64`. No report of a client + broken by that is known. + +The residual risk, an unchecked client that sends a negative count on purpose, is for UDP only. It +is the subject of the ADR of issue #2842 (reject malformed inbound values unless real clients need +the tolerance). + +## Design Decisions + +Each decision lists its options. D1 to D6 were decided by the maintainer on 2026-11-12, in the +review of this specification, which started as an EPIC with sub-issues (D6). The [ADR of issue #2842](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md) records the general rules (D5). The documents behind each decision are in +"Sources for the Decisions". + +### D1: the domain type + +| Option | Shape | For | Against | +| --- | --- | --- | --- | +| **A (decided)** | Private `u64` inside; `const fn new(u64)` stays infallible; `get() -> u64` | The type system gives the invariant; no error type in `primitives`. The about 130 `NumberOfBytes::new(0)` call sites compile unchanged. The only fallible conversion left in the workspace is the UDP wire edge (`i64` to `u64`), which is where the syntax check belongs. HTTP to domain is infallible | The domain can hold values above `i64::MAX`. The REST resource fields must become `u64` (D4) | +| B | Private field, range `0..=i64::MAX`; `TryFrom` and `TryFrom`; a `ZERO` constant | Same accepted range as today on every protocol. The REST resource keeps `i64` | A new error type in `primitives`. Every literal call site changes. The HTTP to domain conversion becomes fallible in the types although it can never fail, so `http-core` needs an error path that is dead code. The upper bound is a wire-width limit of BEP 15 leaking into the domain | +| C | Keep `i64` and the public field; only document the rule | No change | Does not solve the problem | + +**Decided by the maintainer (2026-11-12): A, with no upper bound.** Non-negative is the only +invariant the domain has for a byte count, and `u64` states exactly that. The field becomes private +with a `get()` accessor, so a later invariant can be added without touching every reader again. + +The maintainer's priority is the cleanest long-term design, not the cost of the refactor. Under +that priority A still wins: B's upper bound is the width of a UDP wire field, not a domain rule, +and B forces `http-core` to handle a conversion error that can never happen. No new type is +introduced: the existing newtype of each layer stays and only the domain one changes what it holds. +The newtype pattern is what makes the new constraint a local change. + +With the new type, `Peer::is_seeder` becomes `left == 0 && event != Stopped` in its three copies. +Removing the duplication of the three copies is not part of this issue. + +### D2: where UDP fails + +| Option | Where | For | Against | +| --- | --- | --- | --- | +| U1 | Only in `Request::parse_bytes`, beside the port `0` and event checks | Earliest point; the error is sendable and carries the transaction id | Puts a project decision into the layer that mirrors BEP 15, which is silent on negative values. `AnnounceRequest` has public fields, so the conversion to the domain is fallible anyway | +| **U2 (decided)** | Only in `peer_builder::from_request`, as a fallible wire-to-domain conversion | The parser stays a pure decoder of the BEP 15 packet. The rule is in one place and the types enforce it | Fails after the connection cookie check, inside the service, not at the edge | +| U3 | Both | Fails at the earliest point and the types still protect the domain | The rule is written twice, and the parser no longer only mirrors the specification | + +**Decided by the maintainer (2026-11-12): U2.** Failing fast is the preference, but implementing the +public specification strictly has priority (see "Background"). BEP 15 and the documents it +cites allow a signed 64-bit value here (see "Research Findings"), so the delivery layer accepts it. +The value is refused when it is converted into the domain type, the first type the project owns. + +The wire type stays `NumberOfBytes(I64)`: it is a zero-copy map of the packet +(`packages/udp-protocol/src/common.rs`) and +`docs/adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md` keeps it protocol-local. +`Request::parse_bytes` is not changed. + +Observation, not part of this issue: `Request::parse_bytes` already refuses a port `0` and an event +outside `0..=3`. Under the rule above those checks deserve a review: BEP 15 lists the four event +values, so that check mirrors the specification, but it does not forbid port `0`. The ADR of issue #2842 +states the rule (D5); a follow-up issue can apply it to the port check. + +Rejected: a second, validated request type returned by `parse_bytes` ("parse, don't validate" in +full). It would duplicate the announce request struct and is out of proportion for three fields. + +### D3: the error of the conversion, and the patch of PR #2839 + +After D1 and D2, the conversion in `peer_builder::from_request` refuses a negative counter. +`validate_number_of_bytes`, the function of PR #2839, is never added: that pull request is closed +without merging. The open point was the error the conversion returns. + +| Option | Shape | For | Against | +| --- | --- | --- | --- | +| 1 | `from_request` returns `UdpAnnounceError::NegativeNumberOfBytes` directly | Uses the variant proposed by PR #2839 | The conversion module depends on the error enum of the announce service that calls it: an inner module depends on an outer one | +| **2 (decided)** | `peer_builder` defines its own error for the wire-to-domain conversion (field name and value). `UdpAnnounceError` wraps it as the `source` of one new variant | The dependency points inwards. It is what `UdpAnnounceError` already does for `ConnectionCookieError`, `AnnounceError` and `WhitelistError`. A new failure cause in the conversion does not change the service enum | One more error type in `udp-core` | + +**Decided by the maintainer (2026-11-12): option 2.** Dependencies follow the documented +architecture: delivery layer, then application services, then domain +([docs/packages.md](../../../packages.md), Layer Boundary Enforcement). An inner module never +depends on an outer one, and an outer error wraps the inner error. The reason is to protect the +domain from the outer layers, which change more often. + +Both modules are in `udp-core` (application layer), so no domain code is involved: with D1 the +domain type needs no error at all, and the conversion uses `u64::try_from` on the wire value. + +Whether the wrapped error is public is already answered by the repository's rules, so this issue follows +the existing shape, a public error type in a public `source` field: + +- [Return `Result` only for concretely fallible public APIs](../../../adrs/20261005145329_return_result_only_for_concretely_fallible_public_apis.md) + and its amendment of 2026-10-19: every package is published and consumed on its own, so its error enums + are public and typed. An enum that consumers only report or convert is `#[non_exhaustive]`; an + enum whose variants select a recovery action stays exhaustive. The same ADR rejects a generic + error such as `Box` because it hides which failures are possible. The new conversion + error is only reported (it becomes a BEP 15 error response), so it is `#[non_exhaustive]`. +- The place where an inner error stops being exposed is the user-facing boundary, not the package + boundary: the delivery layer turns the error into a protocol error response, and events must not + carry internal error types (doc comments on `HttpAnnounceError` in + `packages/http-core/src/services/announce.rs` and in `packages/udp-server/src/event.rs`; + [Events are objective facts](../../../adrs/20260727000000_events_are_objective_facts.md); the + [general error-events EPIC draft](../../drafts/generalize-error-events/EPIC.md)). + +No ADR was found that records the maintainer's two general rules on errors: expose variants a +consumer can act on and return something generic when it cannot, and bubble errors up to the user +unless the number of abstraction levels makes that too costly. They are a candidate for an ADR of +their own, outside this issue. + +The message sent to the client is the one PR #2839 proposed (``Invalid announce request: `left` +must not be negative, got -5``), or a reviewed variation of it. The tests written for PR #2839 are +taken over and adapted (see "Regression Test Strategy"). + +### D4: HTTP and the REST API + +HTTP already refuses a negative value, because it parses a `u64`. +**Decided by the maintainer (2026-11-12), all three points:** + +- **The HTTP protocol type holds a private `u64`.** BEP 3 gives no width and no sign, so the + `i64` is the project's choice, not a BEP type. The conversion to the domain in `http-core` is + then infallible. Rejected: leave `NumberOfBytes(pub i64)`, which forces `http-core` to handle a + conversion error that can never happen. +- **The upper limit is removed.** The check that refuses values above `i64::MAX` and its + `NumberOfBytesOverflow` variant go away, and HTTP accepts up to `u64::MAX`. The limit has no + reason of its own (see "Why HTTP has an upper limit"). This is the only client-visible change of + this issue on HTTP: an announce with a counter above `i64::MAX`, refused today, is accepted. On + UDP, T2 makes the other one: an announce with a negative counter, accepted today, gets a BEP 15 + error response (AC12). +- **The REST API resource fields `uploaded`, `downloaded` and `left` become `u64`.** The JSON + output does not change for any value that can exist today; the Rust type and the generated API + description do. Rejected: keep `i64` and saturate in the adapter, which hides a value. + +After this change UDP and HTTP accept different ranges (`0..=i64::MAX` and `0..=u64::MAX`). That +is each protocol following its own specification, not an inconsistency to remove. + +### D5: the ADR + +The repository had ADRs for configuration values (newtypes for constrained fields, value +invariants separate from consistency validation) but none for values that arrive from clients. +Issue #2842 drafted one in PR #2843: "Reject malformed inbound protocol values unless real clients +need the tolerance". It decides whether a questionable value is refused. + +**Decided by the maintainer (2026-11-12): no separate ADR for the rules of this issue. They are +part of [the ADR of issue #2842](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md), and that ADR is delivered by the spec-only pull request of +this issue**, so the rule and its first application are reviewed together. PR #2843 is closed +without merging; its four commits are carried over with their authorship. The spec-only pull +request closes issue #2842. + +The ADR now answers both questions about an inbound value, whether it is refused and where: + +| Rule of this issue | Point of the ADR | +| --- | --- | +| A public protocol specification is implemented strictly; that has priority over failing fast. A type that mirrors a BEP is not narrowed. The value is refused at the first conversion into a type the project owns | 6 | +| Wire ranges may differ per protocol; the domain is the same for all | 7 | +| Each kind of rule is validated in the layer that owns it, as early as possible: syntax in the delivery layer, application invariants in the service, domain invariants in the domain | 8 | +| Invariants are protected by constructors or newtypes, not by standalone validation functions | 9 | +| Byte counts as the first application, with the research on the sign of the UDP fields and the client evidence | "First application: byte counts" | + +History of the alignment: the first text of PR #2843 differed from the decisions of this issue in +three places. Point 2 said the byte counts are signed "only because the format has no unsigned +type", which the sources do not support. Point 6 allowed the refusal in the protocol parser. Point +7 said "the stricter reading wins" between UDP and HTTP, which would have put the UDP wire limit +back on HTTP. The session of #2842 corrected the three points and added points 8 and 9 on +2026-11-12, after this review. + +The question behind point 7, whether UDP and HTTP must accept the same ranges, already had two +recorded decisions, and both support D4: + +- **Values clients send: each protocol has its own limit, for its own reason, and the domain has + none.** [Cap scrape info hashes per protocol](../../../adrs/20261005124222_cap_scrape_info_hashes_per_protocol.md) + (2026-10-05, issue #2417): UDP keeps 74 scrape info hashes because of the packet size, HTTP keeps + 100 as a policy value, and "limits belong to the protocol that has the reason for them"; + `tracker-core` has no cap. +- **Values the operator configures and every protocol sends: one value, bounded by the tightest + protocol.** [Bound protocol-agnostic values by the tightest delivery protocol](../../../adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md) + (2026-10-07). It says that it does not cover limits on what clients send and points to the + scrape ADR. + +A byte count is a value a client sends, so the first decision applies: UDP accepts `0..=i64::MAX` +because of its wire field, HTTP accepts `0..=u64::MAX`, and the domain has no upper bound. The +maintainer confirmed it (2026-11-12): the protocols may differ at the wire level and are equal in +the domain. + +The ADR also sets a general policy that this issue does not implement: a register of tolerances +and a metric that counts rejected requests per protocol and field (points 4 and 5). + +### D6: one standalone issue for three threads + +The bug was found by the `primitives` tests work of EPIC #1347 (Overhaul: Packages Testing). + +**Decided by the maintainer (2026-11-12): one standalone issue that references #1347, not an EPIC +and not a child of #1347. It replaces the patch of PR #2839 and carries the ADR of PR #2843.** + +- Standalone: this is a design change in several packages, not test work, so it does not belong + under a testing EPIC. The EPIC to remove source locations from errors, which has the same origin, + is also standalone. +- One issue, not an EPIC: the first draft was an EPIC with four sub-issues (an ADR, a check in the + UDP parser, the HTTP protocol type and the domain type). D2 removed the parser change. The two + code changes are not independent: between them the HTTP type would hold a `u64` and the domain + type an `i64`, which needs a temporary error for values that do not fit. In one issue that + interim state does not exist. The real code changes are in about ten files; the other call sites + compile unchanged. +- No patch first: the patch of PR #2839 adds a function, an error variant and an enum that this + issue would delete or replace right after. The bug only inflates a seeder count and has been + there since UDP was ported, so it can wait for the proper fix. The implementation of this issue + closes #2838. +- The ADR here: the patch, the ADR and this issue are three views of one decision, and were being + worked on in three sessions that had to be reconciled. The decision documents are now reviewed in + one docs-only pull request, and the code in a second one. + +What is taken over, so nothing is lost: + +| From | What | Where it is now | +| --- | --- | --- | +| PR #2843, branch `2842-inbound-tolerance-adr` | The ADR, its index entry and the specification of #2842 | Carried over as commits of the spec-only pull request | +| PR #2839, branch `2838-udp-reject-negative-announce-bytes` | The specification of #2838 with the field audit and the client and tracker evidence; the reproduction evidence; the UDP probe script | [`docs/issues/open/2838-1347-udp-reject-negative-announce-bytes/`](../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md), carried over by the spec-only pull request | +| PR #2839, the same branch | The tests, in the commits "test(udp-server): reject a negative left in an announce (red)", "test(udp-core): [#2838] cover rejected and accepted byte counts in announce" and "fix(udp-server): [#2838] classify a negative byte count as a bad request" | Not carried over yet. The implementation takes them from that branch and adapts them to the new error | + +The frontmatter keeps `epic: null`. + +## Scope + +### In Scope + +- `primitives`: `NumberOfBytes` holds a private `u64`, with `const fn new(u64)` and + `const fn get(&self) -> u64`; the three `is_seeder` copies compare `left` with zero; the + serializer writes a `u64`; the test builder takes a `u64`; doc examples adapted. +- `udp-core`: `peer_builder::from_request` returns a `Result` with its own error type and converts + each counter with `u64::try_from`; the announce service propagates it with `?`; + `UdpAnnounceError` gets one variant that wraps the conversion error. The field is named by a + typed value, as `ByteCountField` of PR #2839 does, or by the error's own variants; the + implementation decides and records why. No `validate_number_of_bytes` function is added. +- `udp-server`: the new error is classified as `ErrorKind::BadRequest` in `src/event.rs`, as + the commit "fix(udp-server): [#2838] classify a negative byte count as a bad request" of PR #2839 + does for its variant; the handler test; the message sent to the + client is listed in the pull request for approval. +- `http-protocol`: `NumberOfBytes` holds a private `u64` with `new(u64)` and `get()`; the parser + stores the `u64` it parses; `ParseAnnounceQueryError::NumberOfBytesOverflow` is removed; the + builder methods no longer convert or panic and lose their `# Panics` sections; the query building + uses `get()`. +- `http-core`: the protocol to domain conversion is `NumberOfBytes::new(uploaded.get())`, + infallible; tests and the benches helper adapted. +- `axum-http-server`: tests adapted; a contract test for an announce with `left` above `i64::MAX`; + the crate documentation of the three params says "non-negative integer". +- `rest-api-protocol` and `rest-api-runtime-adapter`: the resource fields `uploaded`, `downloaded` + and `left` are `u64`; the adapter uses `get()`. The generated API description is checked for the + changed fields. +- Every other caller in the workspace that does not compile. +- Tests (see "Regression Test Strategy"). +- The characterization test of the primitives tests work (#2824) that pins "a negative `left` + counts as a seeder": it cannot be written any more and is replaced. +- The documents of the spec-only pull request: this specification, the ADR of issue #2842 and the + specification and evidence of #2838. + +### Out of Scope + +- The UDP wire type `torrust_tracker_udp_protocol::NumberOfBytes(I64)` and the UDP request parser + `Request::parse_bytes` (D2). +- A review of the port `0` check in the UDP parser against the priority rule (D2, follow-up). +- Other announce fields. `num_want` is legitimately negative (`-1` means default); the field audit + is in the specification of #2838. +- An upper bound for byte counts (D1, D4). +- Removing the three copies of `is_seeder`. +- A general review of the other newtypes in `primitives`. +- Implementing the register of tolerances and the rejection metric of the ADR (its points 4 and + 5). +- Hiding the wrapped errors of `UdpAnnounceError` behind an opaque source (D3). +- An ADR for the maintainer's general rules on error exposure and propagation (D3, follow-up). +- The `location` field of the error variants touched here; that is the EPIC drafted in + `docs/issues/drafts/remove-source-locations-from-errors/EPIC.md`. +- The console `tracker-client`. Its UDP commands build wire requests, whose type does not change, + and its HTTP commands already pass a `u64` to the builder. + +## Architectural Decisions + +The decisions are D1 to D6 above, with their sources in "Sources for the Decisions". + +- Related ADRs: + [Keep protocol and domain types decoupled](../../../adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md), + [Cap scrape info hashes per protocol](../../../adrs/20261005124222_cap_scrape_info_hashes_per_protocol.md), + [Bound protocol-agnostic values by the tightest delivery protocol](../../../adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md), + [Return `Result` only for concretely fallible public APIs](../../../adrs/20261005145329_return_result_only_for_concretely_fallible_public_apis.md), + and [Reject malformed inbound protocol values unless real clients need the tolerance](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md). +- ADRs to create: None. The ADR of issue #2842 is delivered by the spec-only pull request of this + issue (D5) and must be merged before the implementation starts. + +Design constraints for the implementation: + +- The domain type has no error type and no fallible constructor. The check is `u64::try_from` on + the UDP wire value, in `udp-core`. +- The conversion error names the field and carries the refused value, as the variant proposed by PR #2839 + does. It is a public `#[non_exhaustive]` type in a public `source` field (D3). +- `peer_builder` does not import the error of the announce service. +- No `expect` or `unwrap` on a conversion in production code, and no `Result` for a conversion that + cannot fail. + +During implementation, stop and create an ADR when a decision affects project +architecture or design patterns, selects an approach among meaningful +alternatives, or has consequences future contributors need to understand. Do not +create ADRs for routine implementation details or style choices already governed +by project conventions. + +## Design and Ownership Review + +Not applicable. The change is two value types, a pure parser, a pure conversion and their callers; +there is no child process, asynchronous I/O, network readiness, resource cleanup or reusable test +fixture. + +## Bug-Fix Process + +This is the fix for the bug of #2838, following `.github/skills/dev/debugging/fix-bug/SKILL.md`. +The first steps were done for PR #2839 and are recorded in the folder of #2838: + +- Analysis and hypothesis: done. [Specification of #2838](../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md), "Background" and "Field audit". +- Real-artifact reproduction: done, with the UDP probe against a running tracker. + [Evidence of #2838](../2838-1347-udp-reject-negative-announce-bytes/manual-verification-evidence.md), + `evidence/probe-before-fix.txt`. +- Regression-test boundary: the wire-to-domain conversion `peer_builder::from_request` (unit), the + announce service (order of checks) and the UDP handler (response and no stored peer). +- Red evidence: recorded for the handler test (`evidence/red-test-output.txt`, commit "test(udp-server): reject a negative left in an announce + (red)" of PR #2839). + The implementation repeats it on its own branch before the production change. +- Production fix: this issue (T2 and T3 of the plan). +- Green evidence and like-for-like recheck: the same probe and values, recorded in this issue's + `manual-verification-evidence.md` (M1 to M3). + +## Regression Test Strategy + +Each rule is protected at the boundary that owns it. The UDP tests exist on the branch of PR #2839 +(`2838-udp-reject-negative-announce-bytes`) and are taken over, adapted to the new error: + +- `udp-core`, unit tests of `peer_builder::from_request` (the causal seam for UDP): each of the + three counters with `-1`; `left` with `i64::MIN`; `left` with `0`, `16384` (what libtorrent + sends before it has the metadata) and `i64::MAX` (what Transmission sends). The tests of PR #2839 + for these values (commit "test(udp-core): [#2838] cover rejected and accepted byte counts in + announce") move here from the service tests. +- `udp-core`, service tests of PR #2839 for the order of checks: the connection cookie is validated + before the conversion, and a negative counter is refused before the whitelist is consulted. They + stay. +- `udp-server`, the handler test of PR #2839 + (`it_should_reject_an_announce_with_a_negative_number_of_bytes_left`), adapted to the new + variant. +- `http-protocol`, unit tests for each of `uploaded`, `downloaded` and `left`: a negative value is + refused with `InvalidParam`; `0` is accepted; `u64::MAX` is accepted; a value above `u64::MAX` is + refused with `InvalidParam`. The tests for negative and zero are written first and pass before + any production change. +- `axum-http-server`, a contract test: an announce with `left` above `i64::MAX` is accepted. +- `primitives`: tests for `left == 0` (seeder) and `left > 0` (leecher), each with `Stopped` and + with another event, replace the characterization test for a negative `left`. + +## Implementation Plan + +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 | + +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 +compile between the type change and its callers. + +## Commit Points + +| Task | Coherent change set | Commit policy | +| --- | --- | --- | +| T0 | `test(udp-core)`: the UDP announce benchmark; then `docs(issues)`: the baseline recorded in `performance-evidence.md` | Commit the benchmark after it runs and its group name is confirmed; commit the baseline after all runs are recorded. | +| T1 | `test(http-protocol)`: tests that pin the current accepted range | Commit after focused validation and required review. | +| T2 | `test(udp-server)`: the red handler test; then `fix(udp-core)!`: the wire-to-domain conversion refuses a negative counter | Commit after focused validation and required review. | +| T3 | `refactor(primitives)!`: the number of bytes holds a `u64` in the domain and in the HTTP protocol, with every caller | One commit, because the workspace must compile. Commit after focused validation and required review. | +| T4 | `test(...)`: the new range and the seeder rule | Commit after focused validation and required review. | +| T5 | `docs(axum-http-server)`: param documentation; other commits only if a text changes | Commit after focused validation and required review. | +| T6 | `docs(issues)`: evidence and progress | Commit after the evidence is recorded. | + +Record a justified no-change decision in the task's evidence without creating an empty commit. For +test-producing work, use the `write-unit-test` skill and complete an explicit design review after +each passing test increment, before maintainer review and commit. Confirm that the test exposes the +one causal initial-state difference; its fixture owns only incidental mechanics; and the production +Act plus independently specified expected result remain visible. The review must use the mandatory +prose-first Arrange-Act-Assert comparison: write temporary prose for each section, refactor until +the code expresses it, remove redundant prose, and retain only irreducible context. Record this +review in task evidence or a file-local test plan. Assess helper boundaries by meaningful named +actions and abstraction-level alignment, not caller count: a single-use helper is valid when it +keeps the test readable and hides only incidental mechanics. Commit each reviewed test-design +increment before starting the next planned file or behavior area. Keep final verification and +completion evidence separate when it improves reviewability. Use a Conventional Commit message +with the narrow affected scope, and sign every commit with GPG. + +## Coordination + +- **PR #2839 (issue #2838).** Closed without merging, by its own session. Its branch + `2838-udp-reject-negative-announce-bytes` is kept until the implementation has taken the tests + from it. Issue #2838 stays open; the implementation pull request of this issue closes it. +- **Primitives tests (issue #2824, EPIC #1347).** That work is merged (PR #2841). Its tests in + `packages/primitives/src/peer.rs` pin today's behaviour for a negative `left`: + `it_should_treat_a_negative_number_of_bytes_left_as_a_seeder`, whose comment already points to + this issue, and the `-1` cases of the trait-qualified role table. After this issue those cases do + not compile. This issue deletes them and keeps the `left == 0` and `left > 0` cases. +- **EPIC to remove source locations from errors (draft).** Its SI-3 edits + `ParseAnnounceQueryError` in `packages/http-protocol/src/v1/requests/announce.rs`, a file this + issue edits. The two must not run at the same time; whichever starts second rebases. +- **PR #2843 (issue #2842).** Closed without merging, by its own session. The ADR is part of the + spec-only pull request of this issue, which closes issue #2842. +- **EPIC #1347.** Its sub-issue table lists #2838; the row now points to this issue for the fix. + +## Progress Tracking + +### Workflow Checkpoints + +- [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 +- [ ] 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 +- [ ] Issue closed and spec moved from `docs/issues/open/` to `docs/issues/closed/` + +### Progress Log + +Append one line per meaningful update. When an AI agent did the work, name its model after the +agent, for example `GitHub Copilot (Claude Opus 5.5)`, so later reviews can relate outcomes to +the model that produced them. + +- 2026-11-12 13:15 UTC - Claude Code (Fable 5.2) - Drafted the EPIC from the audit of `NumberOfBytes` on `develop` and the maintainer's review of PR #2839. Decisions D1 to D6 are proposals. Not approved; no GitHub issue created. +- 2026-11-12 16:40 UTC - Claude Code (Fable 5.2) - Added the research findings (decoupling ADR history; sign of the UDP fields in BEP 15, XBT Tracker and libtorrent). Recorded the maintainer's decisions D1 (private `u64`, no upper bound) and D2 (refuse at the wire-to-domain conversion only) and the priority rule: a strict protocol specification before failing fast. Removed the parser sub-issue. D4 to D6 are open. +- 2026-11-12 16:52 UTC - Claude Code (Fable 5.2) - Recorded the audit of negative values (none used in the workspace; no proof for clients in the wild) and the maintainer's decision D3: the conversion owns its error and `UdpAnnounceError` wraps it, so dependencies point inwards. +- 2026-11-12 17:07 UTC - Claude Code (Fable 5.2) - Recorded the history of the HTTP upper limit (commit `74ed59221`, 2023), the documented rule for exposing wrapped errors, and the maintainer's decision D4: HTTP type as `u64`, limit removed, REST fields as `u64`. D5 and D6 are open. +- 2026-11-12 17:17 UTC - Claude Code (Fable 5.2) - Recorded the two existing ADRs on value ranges and the three corrections for the ADR of PR #2843 (sent to its session). Added "Sources for the Decisions", which maps each question of the review to its ADR or document, lists the questions with no recorded answer, and linked the sources in the frontmatter and the text. +- 2026-11-12 17:19 UTC - Claude Code (Fable 5.2) - Recorded the maintainer's decision D5: no separate ADR; the rules are folded into the ADR of issue #2842 (PR #2843). Removed the ADR sub-issue; the EPIC has two code sub-issues that wait for that PR. D6 is open. +- 2026-11-12 17:22 UTC - Claude Code (Fable 5.2) - Recorded the maintainer's decision D6: standalone EPIC. All six decisions are made. Waiting for the approval of the specification as a whole; no GitHub issue created. +- 2026-11-12 17:27 UTC - Claude Code (Fable 5.2) - Drafted the specifications of SI-1 and SI-2 and linked them. Replaced the "client sources were not read" statement with the client evidence already recorded in the specification of #2838. Recorded the interim state between SI-1 and SI-2. Not approved; no GitHub issue created. +- 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. + +## Acceptance Criteria + +- [ ] AC1: `torrust_tracker_primitives::NumberOfBytes` and the HTTP protocol `NumberOfBytes` have no public field and no constructor that takes a signed integer. +- [ ] AC2: the three `is_seeder` implementations compare `left` with zero, and tests cover `left == 0` and `left > 0`, each with `Stopped` and with another event. +- [ ] AC3: `peer_builder::from_request` returns an error that names the field and the value when `bytes_left`, `bytes_uploaded` or `bytes_downloaded` is negative; unit tests cover the three fields and `i64::MIN`. +- [ ] AC4: `peer_builder::from_request` accepts `left` of `0`, `16384` and `i64::MAX`. +- [ ] AC5: `validate_number_of_bytes` does not exist, and no other standalone function validates a byte count. +- [ ] AC6: `peer_builder` does not import the error of the announce service; `UdpAnnounceError` wraps the conversion error as a `source`. +- [ ] AC7: `torrust_tracker_udp_protocol::NumberOfBytes` and `Request::parse_bytes` are unchanged (no diff in `packages/udp-protocol`). +- [ ] AC8: `ParseAnnounceQueryError::NumberOfBytesOverflow` does not exist; for each of `uploaded`, `downloaded` and `left` the HTTP parser refuses a negative value and a value above `u64::MAX` with `InvalidParam`, and accepts `0` and `u64::MAX`. +- [ ] AC9: `AnnounceBuilder::with_downloaded`, `with_uploaded` and `with_left` cannot panic and have no `# Panics` section. +- [ ] AC10: the conversion from the HTTP protocol type to the domain type is infallible, and an HTTP announce with a counter above `i64::MAX` is accepted. +- [ ] AC11: the REST resource fields `uploaded`, `downloaded` and `left` are `u64`, and the JSON of a peer is the same as before for the same peer. +- [ ] AC12: a UDP announce with a negative counter gets a BEP 15 error response with the request's transaction id, the peer is not stored, and the swarm statistics do not change. +- [ ] AC13: an announce with a negative, zero or positive `left` gets the same verdict over UDP and HTTP on a running tracker. +- [ ] AC14: the ADR of issue #2842 is merged, holds the rules listed in D5, and is listed in `docs/adrs/index.md`. +- [ ] AC15: the new UDP error is classified as `ErrorKind::BadRequest`, and the implementation pull request closes issue #2838. +- [ ] `linter all` exits with code `0` +- [ ] Relevant tests pass +- [ ] Manual verification scenarios are executed and documented in issue-local `manual-verification-evidence.md` +- [ ] Acceptance criteria are re-reviewed after implementation and reflect actual behavior +- [ ] Documentation is updated when behavior/workflow changes + +## Verification Plan + +Define verification before implementation starts and execute it before closing the issue. + +### Automatic Checks + +- `linter all` +- `cargo test --workspace`, because a `primitives` type changes +- `cargo test --doc --workspace`, because doc examples build the type +- `cargo bench --workspace --no-run`, so the benches compile +- Performance, because T2 adds a check to every UDP announce and T3 changes the type that every announce carries; see Performance Evidence below +- `cargo deny check bans`, the layer boundary check +- Pre-push checks + +### Performance Evidence + +Planned here, before any production change, as [`docs/benchmarking.md`](../../../benchmarking.md) +requires. The instruments are the UDP announce Criterion benchmark added by T0, `bench_announce_once` +of `http-core`, and the end-to-end UDP load test. + +- Baseline: T0, before T2. After: repeated after T3 with the same machine, build profile, + configuration and settings. Both are recorded in issue-local `performance-evidence.md`. +- Pass rule, one-sided: the after mean of the load test is not below the lowest baseline run, and + each after Criterion median is not above the highest baseline median. +- Expected cost: T2 deliberately adds one sign check per counter — three checks on every UDP + announce (`bytes_left`, `bytes_uploaded`, `bytes_downloaded`), today copied unchecked in + `peer_builder.rs` — so the one-sided rule for the UDP announce benchmark is stated with a + 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. + +### Manual Verification Scenarios + +Status values: `TODO`, `IN_PROGRESS`, `DONE`, `FAILED`, `BLOCKED`. + +Run a tracker with a UDP tracker, an HTTP tracker and the REST API on local ports. UDP announces +are sent with the probe of #2838; HTTP announces with `curl`. + +The probe uses one info hash and one peer endpoint, so each accepted announce replaces the peer of +the previous one. Read the REST output of M7 right after each accepted announce, before the next +announce is sent, and use the single-torrent detail: the torrent list does not include peers. + +| 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 | + +Notes: + +- Manual verification is mandatory even when automated tests pass. It is a + real human-oriented use of the feature or reproduction of the bug fix, not a + simulated result and not merely running automated tests. +- Every recorded validation command result must identify the toolchain or + runtime that produced it when one can affect behavior. For example, record + `cargo +nightly fmt --all -- --check` as `nightly Rust toolchain`, rather than + the ambiguous `cargo fmt --all -- --check`. +- Create `manual-verification-evidence.md` from + `docs/templates/MANUAL-VERIFICATION-EVIDENCE.md` when executing these + scenarios. Record actual prerequisites, actions, commands, program output, + relevant tracker logs, and outcomes there. +- If a scenario fails, record the failure and diagnosis in the progress log before proceeding. + +### Disposable Verification Scripts + +This issue reuses the probe in the specification folder of #2838, +[`evidence/udp_announce_probe.py`](../2838-1347-udp-reject-negative-announce-bytes/evidence/udp_announce_probe.py). +The reasons for a script and for Python are recorded there: a raw UDP packet with a negative +counter cannot be sent with the project's client, whose command line takes an unsigned value. No +new script is planned. The probe is not copied; the evidence file records the commit it was run +from. + +### Acceptance Verification + +| 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} | + +## Risks and Trade-offs + +- **A wide change in one commit.** The type change must compile in every package. Mitigation: T2 + is split off; most call sites compile unchanged; the compiler lists the rest. +- **One pull request across nine packages.** Mitigation: the commits of the plan can be reviewed + one by one, and most touched files are test code that only needs to compile. +- **UDP does not fail at the earliest point.** A negative counter is decoded and passes the cookie + check before it is refused. Mitigation: this is the accepted cost of mirroring BEP 15 strictly; + the ADR records the priority rule. +- **HTTP accepts values it refused before.** Counters above `i64::MAX` are not realistic sizes, and + the tracker does no arithmetic on them. Mitigation: the tests and M5 cover the largest value end + to end, including the REST output. No test covered the old overflow path. +- **The UDP error message is new.** The text is built by `error.to_string()` through the wrapping + variant. Mitigation: T5 lists the exact text in the pull request for approval. +- **A value above `i64::MAX` in the REST API.** JSON numbers above 2^53 lose precision in some + clients. That already holds for `i64` values today. Mitigation: M7 records the output. +- **Breaking public types** in `primitives`, `http-protocol`, `udp-core` and `rest-api-protocol`. + Mitigation: `primitives` owes a major release (4.0.0) and the others are before their first + publish (`docs/issues/open/2583-1669-first-publish-of-workspace-crates/ISSUE.md`). +- **Conflict with parallel work** on the same files (#2824, the source-locations EPIC). + Mitigation: the order in the Coordination section. +- **A real client sends a negative count on purpose.** libtorrent and Transmission do not; other + clients are unchecked (see "Is a negative value ever meaningful?"). Mitigation: the refusal is an + error response the client can show, the existing UDP error event counts it, and the ADR of issue + #2842 defines when a tolerance is added. +- **The fix lands later than the patch would.** The bug stays on `develop` until the + implementation merges. Mitigation: it only inflates a seeder count; T2 fixes it as the first code + commit. +- **Tests live on a branch of a closed pull request.** Mitigation: the branch is kept until the + implementation has taken them; the commits are named by their subject in D6. +- **Scope growth into a review of every primitive.** Mitigation: the Out of Scope list; other types + get their own issues, using the ADR. + +## Implementation Completion Review + +After implementation, compare the result with this specification. Record +invalidated assumptions, material design changes, unexpected validation +findings, and reusable lessons. + +- Retrospective: `Not yet assessed` +- If needed, create `implementation-retrospective.md` from the repository + template at `docs/templates/IMPLEMENTATION-RETROSPECTIVE.md` in this issue + specification's directory. +- If no retrospective is needed, add a concise progress-log entry explaining + why the work had no material discovery. +- When an independent reviewer receives this folder-style specification, it + records its result in `agent-review-reports.md` using + `docs/templates/AGENT-REVIEW-REPORTS.md`. Do not create that artifact for a + legacy standalone specification or when no folder-style specification was + supplied. + +## References + +The documents behind each decision, with links, are in "Sources for the Decisions". + +- Related issues: #2838 (the bug, closed by the implementation of this issue; + [specification](../2838-1347-udp-reject-negative-announce-bytes/ISSUE.md)), #2824 (primitives tests, where it was found as finding F6), + #1347 (Overhaul: Packages Testing), #2842 (ADR on inbound tolerance), #1835 (decoupling of the + protocol and domain types), #2417 (per-protocol scrape limits), #2454 (`#[non_exhaustive]` error + enums), #2245 (numeric wire conversions), #184 (origin of the HTTP upper limit), #2583 (first + publish of the workspace crates), #1669 (Overhaul: Packages) +- Related PRs: #2839 (the tactical patch, closed without merging), #2843 (the ADR, closed without + merging and carried over here) +- Related commits: `f7f29500d` (types decoupled, 2026), `74ed59221` (HTTP upper limit, 2023), + `fe5e8ea40` (UDP ported to `aquatic_udp_protocol`, 2022), `9d5833390` (first + `NumberOfBytes(pub i64)`, 2021) +- Related ADRs: + [Keep protocol and domain types decoupled](../../../adrs/20260527175600_keep_protocol_and_domain_types_decoupled.md), + [Cap scrape info hashes per protocol](../../../adrs/20261005124222_cap_scrape_info_hashes_per_protocol.md), + [Bound protocol-agnostic values by the tightest delivery protocol](../../../adrs/20261007082938_bound_protocol_agnostic_values_by_the_tightest_delivery_protocol.md), + [Return `Result` only for concretely fallible public APIs](../../../adrs/20261005145329_return_result_only_for_concretely_fallible_public_apis.md), + [Use newtypes for constrained configuration field types](../../../adrs/20260721100000_use_newtypes_for_constrained_configuration_field_types.md), + [Separate configuration value invariants from consistency validation](../../../adrs/20260723184019_separate_configuration_value_invariants_from_consistency_validation.md), + [Adopt independent package versioning](../../../adrs/20260629000000_adopt_independent_package_versioning.md), + [Events are objective facts](../../../adrs/20260727000000_events_are_objective_facts.md), + and [Reject malformed inbound protocol values unless real clients need the tolerance](../../../adrs/20261111170611_reject_malformed_inbound_protocol_values_unless_clients_need_tolerance.md), + which carries the rules of this issue +- Architecture: [docs/packages.md](../../../packages.md) (package conventions and layer boundary + enforcement) +- Specifications: [BEP 3](https://www.bittorrent.org/beps/bep_0003.html), + [BEP 15](https://www.bittorrent.org/beps/bep_0015.html), + [XBT Tracker UDP tracker protocol](https://xbtt.sourceforge.net/udp_tracker_protocol.html), + [libtorrent UDP tracker protocol](https://www.libtorrent.org/udp_tracker_protocol.html) diff --git a/docs/pr-reviews/pr-2851-review/PR-REVIEW.md b/docs/pr-reviews/pr-2851-review/PR-REVIEW.md new file mode 100644 index 0000000000..a6852ab00c --- /dev/null +++ b/docs/pr-reviews/pr-2851-review/PR-REVIEW.md @@ -0,0 +1,1024 @@ +--- +semantic-links: + skill-links: + - process-pr-review + related-artifacts: + - .github/skills/dev/pr-reviews/process-pr-review/SKILL.md +--- + + + +# PR #2851 Review Audit + +Source: pull-request reviews and inline review threads for https://github.com/torrust/torrust-tracker/pull/2851. + +## 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 the review `5879517733` of `da2ce7` (F1 to F7, reviewer-provided IDs) and Copilot's +review `5879649645` (F8 to F12, audit-local IDs). Both reviewed the first head of the pull request. +Copilot labels its five findings "Low severity"; the severity `Minor` is inferred from that label. +Round 2 is the approving review `5881088057` of `da2ce7` (F13 to F16, reviewer-provided IDs), on +the head that carried the round 1 audit. +Round 3 is Copilot's review `5881522270` (F17 to F19, audit-local IDs), on the head that carried +the round 2 audit. It labels its three findings "Low severity"; the severity `Minor` is inferred from that label. +Round 4 is the approving review `5887584344` of `da2ce7` (F20 to F22, reviewer-provided IDs), on the head that carried +the round 3 audit. +Round 5 is the approving review `5887875398` of `da2ce7` (F23 and F24, reviewer-provided IDs) and Copilot's review +`5888919892` (F25 and F26, audit-local IDs; Copilot labels them F24 and F25), both on the head that carried the round 4 audit. +Round 6 is the review `5889368194` of `da2ce7` (COMMENTED, F27 to F31, audit-local IDs; the reviewer's own numbering, +which collides with F25 and F26 above, is recorded as the original), on the head that carried the round 5 spec changes +before the round 5 audit record; and the review `5889728498` of `da2ce7` (COMMENTED, F32 to F34, audit-local IDs; same +collision, with the reviewer's own F30 to F32 recorded as the original), on the head that carried the round 5 audit. +Round 7 is Copilot's review `5890015379` (COMMENTED, F35 to F37, audit-local IDs), on the head that carried the round 6 +audit, submitted after a timed-out agentic pass with three mechanical comments. Copilot labels all three "Medium +severity"; the severity `Minor` is inferred from that label. +Round 8 is the review `5890044214` of `da2ce7` (DISMISSED, F38 to F41, audit-local IDs; reviewer's own numbering F33 to +F36 collides with the audit's own F33 to F36, recorded as the original) at the head that carried the round 6 audit, +before round 7 landed, and the review `5890183339` of `da2ce7` (COMMENTED, F42 and F43, audit-local IDs; reviewer's own +F37 and F38, which collide with the audit's own F37 and F38) at the head that carried the probe fix of round 7's F35, before round 7's audit commit +landed. Both sets of threads were resolved earlier by a blanket GraphQL call with no reply, repeating the mistake +corrected in round 6; they were reopened before replying. +Round 9 is the review `5890340167` of `da2ce7` (COMMENTED, F44 to F47, audit-local IDs; reviewer's own F39 to F42, +recorded as the original), on the head that carried the round-7 probe-documentation commit, before round 8 landed. +Round 10 is the approving review `5890585973` of `da2ce7` (F48 to F52, audit-local IDs; reviewer's own F43 to F46, which collide with the +audit's own, and F48, recorded as the original) and Copilot's review `5891790581` (F53 to F57, +audit-local IDs), both on the head that carried the round 9 audit. Copilot labels F53 to F56 "Medium severity" and F57 +"Low severity"; the severity `Minor` is inferred from those labels. +Round 11 is the approving review `5903179555` of `da2ce7` (F58, audit-local ID; reviewer's own F50, which collides, +recorded as the original), on the head that carried the round 10 audit. +Round 12 is Copilot's review `5903247803` (F59 and AUDIT-001, reviewer-provided IDs, which do not collide), on the head that carried the round-11 fix before the round 11 audit. Both are labelled "Low severity" in +the body; the comments carry `[Minor]` and `[Nit]` brackets, which are used. +Round 13 is the approving review `5903321950` of `da2ce7` (F61, audit-local ID; reviewer's own F59, which collides, +recorded as the original), on the head that carried the round 12 audit. F60 is not used. +Round 14 is the approving review `5904321921` of `da2ce7` (F62 and F63, reviewer-provided IDs, which do not collide), on +the head of the second rebase, which carried the round 13 audit. + +| Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state | +| ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ | +| F1 | review-finding:pr-2851-f1 | Human | Major | metadata | ORIGINAL | FIXED | RESOLVED | +| F2 | review-finding:pr-2851-f2 | Human | Major | correctness | ORIGINAL | FIXED | RESOLVED | +| F3 | review-finding:pr-2851-f3 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F4 | review-finding:pr-2851-f4 | Human | Minor | correctness | ORIGINAL | FIXED | RESOLVED | +| F5 | review-finding:pr-2851-f5 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F6 | review-finding:pr-2851-f6 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F7 | review-finding:pr-2851-f7 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F8 | review-finding:pr-2851-f8 | Copilot | Minor (inferred) | correctness | ORIGINAL | FIXED | RESOLVED | +| F9 | review-finding:pr-2851-f9 | Copilot | Minor (inferred) | correctness | ORIGINAL | FIXED | RESOLVED | +| F10 | review-finding:pr-2851-f10 | Copilot | Minor (inferred) | correctness | RE_RAISE_OF:F2 | NO_ACTION | SUPERSEDED | +| F11 | review-finding:pr-2851-f11 | Copilot | Minor (inferred) | correctness | ORIGINAL | FIXED | RESOLVED | +| F12 | review-finding:pr-2851-f12 | Copilot | Minor (inferred) | correctness | ORIGINAL | FIXED | RESOLVED | +| F13 | review-finding:pr-2851-f13 | Human | Minor | metadata | ORIGINAL | FIXED | RESOLVED | +| F14 | review-finding:pr-2851-f14 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F15 | review-finding:pr-2851-f15 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F16 | review-finding:pr-2851-f16 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F17 | review-finding:pr-2851-f17 | Copilot | Minor (inferred) | testing | ORIGINAL | FIXED | RESOLVED | +| F18 | review-finding:pr-2851-f18 | Copilot | Minor (inferred) | documentation | ORIGINAL | FIXED | RESOLVED | +| F19 | review-finding:pr-2851-f19 | Copilot | Minor (inferred) | testing | ORIGINAL | FIXED | RESOLVED | +| F20 | review-finding:pr-2851-f20 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F21 | review-finding:pr-2851-f21 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F22 | review-finding:pr-2851-f22 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F23 | review-finding:pr-2851-f23 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F24 | review-finding:pr-2851-f24 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F25 | review-finding:pr-2851-f25 | Copilot | Minor | security | ORIGINAL | FIXED | RESOLVED | +| F26 | review-finding:pr-2851-f26 | Copilot | Minor | testing | ORIGINAL | FIXED | RESOLVED | +| F27 | review-finding:pr-2851-f27 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F28 | review-finding:pr-2851-f28 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F29 | review-finding:pr-2851-f29 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F30 | review-finding:pr-2851-f30 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F31 | review-finding:pr-2851-f31 | Human | Suggestion | documentation | ORIGINAL | FIXED | RESOLVED | +| F32 | review-finding:pr-2851-f32 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F33 | review-finding:pr-2851-f33 | Human | Minor | other | ORIGINAL | FIXED | RESOLVED | +| F34 | review-finding:pr-2851-f34 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F35 | review-finding:pr-2851-f35 | Copilot | Minor (inferred) | correctness | ORIGINAL | FIXED | RESOLVED | +| F36 | review-finding:pr-2851-f36 | Copilot | Minor (inferred) | metadata | ORIGINAL | FIXED | RESOLVED | +| F37 | review-finding:pr-2851-f37 | Copilot | Minor (inferred) | metadata | RE_RAISE_OF:F36 | NO_ACTION | SUPERSEDED | +| F38 | review-finding:pr-2851-f38 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F39 | review-finding:pr-2851-f39 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F40 | review-finding:pr-2851-f40 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F41 | review-finding:pr-2851-f41 | Human | Minor | metadata | ORIGINAL | FIXED | RESOLVED | +| F42 | review-finding:pr-2851-f42 | Human | Minor | other | ORIGINAL | FIXED | RESOLVED | +| F43 | review-finding:pr-2851-f43 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F44 | review-finding:pr-2851-f44 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F45 | review-finding:pr-2851-f45 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F46 | review-finding:pr-2851-f46 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F47 | review-finding:pr-2851-f47 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F48 | review-finding:pr-2851-f48 | Human | Minor | metadata | ORIGINAL | FIXED | RESOLVED | +| F49 | review-finding:pr-2851-f49 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F50 | review-finding:pr-2851-f50 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F51 | review-finding:pr-2851-f51 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F52 | review-finding:pr-2851-f52 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F53 | review-finding:pr-2851-f53 | Copilot | Minor (inferred) | documentation | ORIGINAL | FIXED | RESOLVED | +| F54 | review-finding:pr-2851-f54 | Copilot | Minor (inferred) | correctness | ORIGINAL | FIXED | RESOLVED | +| F55 | review-finding:pr-2851-f55 | Copilot | Minor (inferred) | correctness | RE_RAISE_OF:F54 | NO_ACTION | SUPERSEDED | +| F56 | review-finding:pr-2851-f56 | Copilot | Minor (inferred) | metadata | RE_RAISE_OF:F49 | NO_ACTION | SUPERSEDED | +| F57 | review-finding:pr-2851-f57 | Copilot | Minor (inferred) | formatting | ORIGINAL | FIXED | RESOLVED | +| F58 | review-finding:pr-2851-f58 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F59 | review-finding:pr-2851-f59 | Copilot | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| AUDIT-001 | review-finding:pr-2851-audit-001 | Copilot | Nit | documentation | ORIGINAL | FIXED | RESOLVED | +| F61 | review-finding:pr-2851-f61 | Human | Nit | metadata | ORIGINAL | FIXED | RESOLVED | +| F62 | review-finding:pr-2851-f62 | Human | Minor | documentation | ORIGINAL | FIXED | RESOLVED | +| F63 | review-finding:pr-2851-f63 | Human | Nit | documentation | ORIGINAL | FIXED | RESOLVED | + +## Finding Details + +### F1 - Closing keywords for #2838 and #2850 in two commit messages and in the description + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334119 +- Concern: Two commit messages and two sentences of the description paired a closing keyword with #2838 or #2850, so the merge would have closed both issues before the implementation. +- Solution: Reworded the two commit messages (a history rewrite that kept every commit and the tree) and edited the description, which now also states the rewrite. The fix is outside the tree, so the resolution reference is the reply that states it. +- Current-tree verification: The closing-keyword scan of the `open-pull-request` skill printed nothing for the commit messages of `torrust/develop..HEAD`, only `Closes #2842` for the description, and nothing for the title. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555413190 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555413190 + +### F2 - The inventory says the UDP byte-count bug is fixed and UDP now rejects it + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334138 +- Concern: The inventory row of the ADR said the bug was fixed in PR #2839, which was not merged, and called the current HTTP `i64` type old. +- Solution: The Note column says UDP still accepts the value and that the planned change is issue #2850; the HTTP column names both limits of the current parser. +- Current-tree verification: Read `packages/udp-core/src/peer_builder.rs`: `from_request` returns `peer::Peer` and copies the three counters with `.0.get()`. +- Resolution reference: docs(adrs): [#2842] state in the inventory that UDP still accepts a negative byte count +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555413695 + +### F3 - Point 6 describes the `udp-core` conversion as if it existed + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334155 +- Concern: Point 6 of the ADR used the present tense for a fallible conversion that is not in the tree. +- Solution: Point 6 says that issue #2850 plans it. +- Current-tree verification: Read point 6 of the ADR in the tree; it reads "as issue #2850 plans for a negative `left` with a fallible conversion in `udp-core`". +- Resolution reference: docs(adrs): [#2842] describe the udp-core conversion as planned, not as existing +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555414073 + +### F4 - The Description attributes a sign to BEP 15 that the ADR later says BEP 15 does not state + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334169 +- Concern: The Description said BEP 15 encodes `left` as a signed 64-bit integer, against the research paragraph of the same ADR. +- Solution: The Description says BEP 15 encodes a 64-bit integer, which the implementation document it cites types as `int64_t`. +- Current-tree verification: `grep -n -i signed` over the ADR and the specifications of #2842 and #2838 showed no other sentence that attributes the sign to BEP 15. +- Resolution reference: docs(adrs): [#2842] stop attributing the sign of left to BEP 15 in the description +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555414457 + +### F5 - Checkpoints and acceptance criteria report the unmerged patch as done + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334182 +- Concern: The carried-over specification of #2838 reported implementation, tests and verification as done and cited tests that are not in the tree; the evidence file recorded an after-fix run without a note. +- Solution: The checkpoints and criteria are unchecked and marked superseded, the verification rows are TODO with the same mark, and V2 of the evidence file says the run used the branch of PR #2839. +- Current-tree verification: Read the three places in the tree after the commit; `grep -c '\[x\]'` in the Acceptance Criteria section of the #2838 specification is 0. +- Resolution reference: docs(issues): [#2838] mark the checkpoints, criteria and recheck of the unmerged patch as superseded +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555414853 + +### F6 - Section reference with no matching heading + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334200 +- Concern: The #2850 specification referred to a section "Why This Is Needed", which is not a heading, and one row still said "outside this EPIC". +- Solution: The reference names "Background" and the row says "outside this issue". +- Current-tree verification: Compared every quoted section name after "see" in the #2850 specification with its headings; the only one without a heading there is a heading of the #2838 specification, cited as such. +- Resolution reference: docs(issues): [#2850] correct a section reference and a leftover mention of the EPIC +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555415274 + +### F7 - Section reference with no matching heading + +- PR number: 2851 +- Source review ID: 5879517733 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554334213 +- Concern: The #2838 specification referred to a section "Decision to approve", which does not exist. +- Solution: The sentence points to the Progress Log, where the decision is recorded. +- Current-tree verification: Read the sentence and the progress-log entry of 2026-11-12 09:15 UTC in the tree. +- Resolution reference: docs(issues): [#2838] point the field decision at the progress log +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555415700 + +### F8 - A negative `left` inflates the seeder count, not completed downloads + +- PR number: 2851 +- Source review ID: 5879649645 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554433111 +- Concern: The Description said a negative value counts as a completed download. +- Solution: The Description says it counts the peer as a seeder (the `complete` count). +- Current-tree verification: Read `Peer::is_seeder` in `packages/primitives/src/peer.rs` and the completed counter in `packages/swarm-coordination-registry/src/swarm/coordinator.rs`, which is incremented on a transition to `Completed`. +- Resolution reference: docs(adrs): [#2842] name the seeder count as the statistic a negative left inflates +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555416071 + +### F9 - Require parity at the final inbound acceptance boundary, not at the parser + +- PR number: 2851 +- Source review ID: 5879649645 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554433196 +- Concern: Point 7 asked for a parity test of both parsers, while point 6 lets the UDP parser accept a value that the conversion refuses. +- Solution: Point 7 asks for a parity test up to the point where the request is accepted or refused, including the wire-to-domain conversion. +- Current-tree verification: Read points 6 and 7 of the ADR in the tree after the commit. +- Resolution reference: docs(adrs): [#2842] require verdict parity at the acceptance boundary, not at the parser +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555416464 + +### F10 - Reference pending #2850; #2839 was closed without merging + +- PR number: 2851 +- Source review ID: 5879649645 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554433267 +- Concern: The inventory row said "UDP now rejects it" although PR #2839 was not merged. This is the concern of F2 on the same row. +- Solution: No further change: the fix of F2 already corrected the row. +- Current-tree verification: Read the inventory row in the tree; it says "UDP still accepts it; the planned change is issue #2850". +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555416881 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555416881 + +### F11 - UDP treats a non-positive `num_want` as the maximum; HTTP zero requests none + +- PR number: 2851 +- Source review ID: 5879649645 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554433336 +- Concern: The inventory said the tracker ignores the UDP value and did not record the leniency below `-1` or the different meaning of zero. +- Solution: The row describes both protocols as the code behaves. +- Current-tree verification: Read `PeersWanted::from_client_request` and `PeersWanted::only` in `packages/tracker-core/src/announce_handler.rs`, the UDP call in `packages/udp-core/src/services/announce.rs` and `peers_wanted` in `packages/http-core/src/services/announce.rs`. +- Resolution reference: docs(adrs): [#2842] describe how num_want is handled on each protocol in the inventory +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555417314 + +### F12 - HTTP rejects a non-IP announce `ip`; distinguish this from the ADR fallback + +- PR number: 2851 +- Source review ID: 5879649645 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4554433400 +- Concern: The inventory listed a non-IP `ip` as ignored on HTTP, while the code rejects it. +- Solution: The row says HTTP rejects it, that it is not a leniency today, and that the linked `ip` ADR records an older silent fallback whose difference from the code needs its own follow-up. +- Current-tree verification: Read the `PeerIp` match in `packages/http-core/src/services/announce.rs`: `DnsName` and `Invalid` return errors; `Absent` and `Empty` use the connection IP. +- Resolution reference: docs(adrs): [#2842] record that HTTP rejects an announce ip that is not an IP address +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555417701 + +### F13 - The audit cites three commit ids that will never be on `develop` + +- PR number: 2851 +- Source review ID: 5881088057 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555575897 +- Concern: The processing log cited the ids of three commits of the branch as it was before the history rewrite. A review audit may not cite a PR-branch commit by id. +- Solution: The entry cites the commits by subject only, and a correction entry records that it was rewritten in place. +- Current-tree verification: Ran the commit-id check of the `open-pull-request` skill in a clone that still holds the first head; it printed nothing. +- Resolution reference: docs(pr-reviews): drop the commit ids of the rewritten branch from the audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555647329 + +### F14 - The force push is stamped 19:30; the forge records 19:34:12Z + +- PR number: 2851 +- Source review ID: 5881088057 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555575908 +- Concern: The log stamped the force push before it happened and named the maintainer as the actor; the forge timeline records 19:34:12Z and the PR author's account. +- Solution: A correction entry gives the forge time and actor and also corrects the "and pushed" of the next entry. The original entries are not rewritten. +- Current-tree verification: Read `head_ref_force_pushed` in the forge timeline of the pull request: 2026-11-12T19:34:12Z, actor `josecelano-bot`. +- Resolution reference: docs(pr-reviews): correct the time and actor of the force push in the audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555647720 + +### F15 - Scenario M2 still reads DONE for the fixed build + +- PR number: 2851 +- Source review ID: 5881088057 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555575927 +- Concern: The manual scenario M2 of the #2838 specification still read DONE for a build that is not on `develop`. +- Solution: M2 is TODO and its evidence cell carries the superseded mark. +- Current-tree verification: Read the Manual Verification Scenarios table of the #2838 specification in the tree. +- Resolution reference: docs(issues): [#2838] mark scenario M2 of the unmerged patch as superseded +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555648132 + +### F16 - `last-updated-utc` is unchanged by the edits + +- PR number: 2851 +- Source review ID: 5881088057 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555575950 +- Concern: The evidence file of #2838 and the specifications of #2838 and #2850 were edited in round 1 and kept their earlier `last-updated-utc`. +- Solution: The evidence file and the #2850 specification carry the time of their last content commits; the #2838 specification was stamped with its M2 edit in the commit for F15. +- Current-tree verification: Compared the three `last-updated-utc` values with `git log --format=%cI` of each file. +- Resolution reference: docs(issues): [#2850] set last-updated-utc to the time of the last content edits +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555648558 + +### F17 - The probe neither checks nor shows the transaction id of the response + +- PR number: 2851 +- Source review ID: 5881522270 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555935594 +- Concern: The UDP probe decoded the transaction id of each response and ignored it, so the planned recheck could not detect a response with a wrong id. +- Solution: The probe compares the id of the connect and the announce response with the id it sent and exits with status 1 on a mismatch. Its output for a correct response is unchanged. +- Current-tree verification: Ran the probe against a local fake UDP server: with the right id it printed the error response and exited 0; with a wrong id it printed a mismatch message on stderr and exited 1. +- Resolution reference: test(udp-probe): [#2838] reject a response with the wrong transaction id in the UDP probe +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4556040577 + +### F18 - Replaying the evidence fails because the database directory is not created + +- PR number: 2851 +- Source review ID: 5881522270 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555935674 +- Concern: The recorded configuration stores the database under a directory that no step creates, and the tracker creates only the file. +- Solution: The prerequisites have a bullet, marked as added after the recorded runs, that creates the directory. The record of the runs is unchanged. +- Current-tree verification: Read the Environment and Prerequisites section of the evidence file and `path` in `evidence/tracker.toml` in the tree. +- Resolution reference: docs(issues): [#2838] add the database directory as a replay prerequisite of the evidence +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4556040964 + +### F19 - A REST check after all announces cannot show the earlier byte counts + +- PR number: 2851 +- Source review ID: 5881522270 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4555935730 +- Concern: The probe fixes the info hash and the peer endpoint, so each announce replaces the previous peer; scenario M7 read the REST output only at the end. +- Solution: M7 reads the single-torrent detail right after each accepted announce, and the scenarios say why and that the torrent list has no peers. +- Current-tree verification: Read the Manual Verification Scenarios of the #2850 specification in the tree, and the fixed info hash and port in the probe. +- Resolution reference: docs(issues): [#2850] read the REST output after each accepted announce in scenario M7 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4556041507 + +### F20 - The round-3 review does carry a severity label + +- PR number: 2851 +- Source review ID: 5887584344 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560762446 +- Concern: This audit said Copilot's round-3 review gives no severity label; its body marks each of the three findings "Low severity". +- Solution: The round overview now says the review labels its three findings "Low severity" and that `Minor` is inferred from that label. +- Current-tree verification: Read the round overview of this record in the tree. +- Resolution reference: docs(pr-reviews): record round 4 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560877430 + +### F21 - `last-updated-utc` again trails the edits of two files + +- PR number: 2851 +- Source review ID: 5887584344 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560762450 +- Concern: The evidence file and the #2850 specification carried times earlier than their last content edits (the same defect as F16). +- Solution: Both files now read 2026-11-12 20:32, the time of their last content edits in `git log`. +- Current-tree verification: Read the frontmatter of both files in the tree and `git log -1 --format=%aI` of each before this fix. +- Resolution reference: docs(issues): [#2850] carry the time of the last content edit in last-updated-utc of two files +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560877678 + +### F22 - After the rebase, committer times no longer match the times this log attributes + +- PR number: 2851 +- Source review ID: 5887584344 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560762460 +- Concern: The rebase reset the committer time of the 24 commits up to the round-2 audit to 20:28:16Z to 20:28:32Z, so `git log --format=%cI` no longer gives the times that earlier entries cite; `%aI` keeps the original times, except for the last fix of the 19:36 range (19:35:03Z there). +- Solution: An appended entry in the processing log says so; no earlier entry was rewritten. +- Current-tree verification: Read the processing log in the tree. +- Resolution reference: docs(pr-reviews): record round 4 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560877891 + +### F23 - `Reviewer finding ID` repeats IDs that were not reassigned + +- PR number: 2851 +- Source review ID: 5887875398 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560991862 +- Concern: The entries of F20, F21 and F22 set `Reviewer finding ID` to the reviewer's own IDs, which are not reassigned. +- Solution: The three entries read `N/A`, as those of F1 to F7 and F13 to F16. +- Current-tree verification: Read the three entries in the tree. +- Resolution reference: docs(pr-reviews): record round 5 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4561860121 + +### F24 - The correction for F22 does not name the entry stamped 20:01 + +- PR number: 2851 +- Source review ID: 5887875398 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4560991869 +- Concern: The correction for F22 names the entries stamped 18:11 and 19:36 and the F16 verification, not the one stamped 20:01, which also cites `%cI` for commits the rebase re-stamped. +- Solution: An appended log entry names the entry stamped 20:01; the entry of the correction for F22 stays as it is. +- Current-tree verification: Read the processing log in the tree and `git log --format=%cI` and `%aI` of the four round 2 fixes. +- Resolution reference: docs(pr-reviews): record round 5 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4561860498 + +### F25 - The replay configuration binds an unused listener on every interface + +- PR number: 2851 +- Source review ID: 5888919892 +- Reviewer finding ID: F24 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4561799031 +- Concern: `evidence/tracker.toml` bound a UDP listener on `0.0.0.0:6969` that no probe used, exposing the replay tracker beyond localhost. +- Solution: The listener is removed, and the evidence file records the removal as a replay-only adjustment. +- Current-tree verification: Read `evidence/tracker.toml` and the Environment section of the evidence file in the tree; every probe targets `127.0.0.1:6868`. +- Resolution reference: docs(issues): [#2838] remove the unused second UDP listener from the replay configuration +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4561860930 + +### F26 - The plan has no baseline and no UDP announce benchmark + +- PR number: 2851 +- Source review ID: 5888919892 +- Reviewer finding ID: F25 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4561799123 +- Concern: T2 changes every UDP announce but the plan only compiled the benches; `docs/benchmarking.md` requires a relevant microbenchmark, the load test, a baseline before production changes and a one-sided pass rule agreed before implementation. +- Solution: New task T0 adds the missing UDP announce benchmark in its own commit and records the baseline before T2; T6 repeats the measurement after T3; a Performance Evidence section states the instruments, the one-sided rule and the tolerance to agree for the UDP announce; evidence goes to `performance-evidence.md`. +- Current-tree verification: Read the Implementation Plan and the Performance Evidence section of the #2850 specification; checked that no `udp-core` or `udp-server` benchmark times an announce (`udp-core` times the connect, the connection cookie and the ban service; `udp-server` a scrape). +- Resolution reference: docs(issues): [#2850] plan the performance baseline and the missing UDP announce benchmark +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4561861311 + +### F27 - The audit record stops at round 4, and two replies cite a commit that is not on the branch + +- PR number: 2851 +- Source review ID: 5889368194 +- Reviewer finding ID: F25 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562135511 +- Concern: The record had no row or log entry for the two reviews after round 4; two replies said a fix was "pushed right after this reply" in a commit subject that was not yet on the branch. +- Solution: The round-5 audit commit landed (rows F23 to F26, log entry at 09:50); this round adds rows for this review's own five findings, which the round-5 commit had not covered. +- Current-tree verification: Read the round 5 and round 6 sections of this record and `git log` of the branch. +- Resolution reference: docs(pr-reviews): record round 6 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562440525 + +### F28 - `udp-core` has three benchmarks, not only `connect_once` + +- PR number: 2851 +- Source review ID: 5889368194 +- Reviewer finding ID: F26 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562135512 +- Concern: The T0 row said "`udp-core` has only `connect_once`", omitting `ban_service_benchmark` and `connection_cookie_benchmark`; the conclusion (no announce benchmark) held regardless. +- Solution: The T0 row now reads "the `udp-core` benchmarks time only the connect, the connection cookie and the ban service"; the audit's own verification text for F26 above is corrected the same way (sweep). +- Current-tree verification: Read the T0 row of the #2850 specification and `packages/udp-core/Cargo.toml` lines 50 to 60 in the tree. +- Resolution reference: docs(issues): [#2850] correct benchmark wording, add a Commit Points row, and record the tolerance write-back +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562440881 + +### F29 - T2 adds one check per counter, not one comparison per announce + +- PR number: 2851 +- Source review ID: 5889368194 +- Reviewer finding ID: F27 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562135522 +- Concern: The Performance Evidence section said T2 "deliberately adds one comparison on every UDP announce"; the design converts each of `bytes_left`, `bytes_uploaded` and `bytes_downloaded` with `u64::try_from`, so it adds three checks. +- Solution: The section now reads "one sign check per counter — three checks on every UDP announce", naming the three counters and that `peer_builder.rs` copies them unchecked today. +- Current-tree verification: Read the Performance Evidence section and `packages/udp-core/src/peer_builder.rs` lines 23 to 25 in the tree. +- Resolution reference: docs(issues): [#2850] correct benchmark wording, add a Commit Points row, and record the tolerance write-back +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562441227 + +### F30 - Commit Points has no row for T0 + +- PR number: 2851 +- Source review ID: 5889368194 +- Reviewer finding ID: F28 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562135516 +- Concern: The Commit Points table started at T1, with no row for the new T0 task, and `bench` is not a Conventional Commit type the repository recognizes. +- Solution: A T0 row was added: `test(udp-core)` for the benchmark, `docs(issues)` for the baseline in `performance-evidence.md`. +- Current-tree verification: Read the Commit Points table of the #2850 specification in the tree. +- Resolution reference: docs(issues): [#2850] correct benchmark wording, add a Commit Points row, and record the tolerance write-back +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562441604 + +### F31 - Say where the agreed tolerance is written + +- PR number: 2851 +- Source review ID: 5889368194 +- Reviewer finding ID: F29 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562135525 +- Concern: The Expected cost bullet asked the maintainer to agree a tolerance after the baseline but did not say where that figure would be recorded, so the after measurement could be judged against a figure the plan never states. +- Solution: The bullet now ends "...and before the after measurement, and is then added to this section". +- Current-tree verification: Read the Performance Evidence section of the #2850 specification in the tree. +- Resolution reference: docs(issues): [#2850] correct benchmark wording, add a Commit Points row, and record the tolerance write-back +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562442024 + +### F32 - The round-5 log entry places the F23 and F24 fix before its replies + +- PR number: 2851 +- Source review ID: 5889728498 +- Reviewer finding ID: F30 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562413702 +- Concern: The round-5 entry said the F23/F24 fix was committed and pushed before the 09:46 replies, and gave a placeholder time "09:5x"; in fact that fix is `docs(pr-reviews): record round 5 in the review audit of PR #2851`, committed at 10:38:07Z, 52 minutes after those replies. +- Solution: An appended correction entry gives the forge time of the replies and the actual commit time of the fix; the original entry stays as it is, per the Completion Rules' correction convention. +- Current-tree verification: Read the round-5 log entry and the appended correction, and `git log --format=%cI` of that commit. +- Resolution reference: docs(pr-reviews): record round 6 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562443275 + +### F33 - The five threads of review `5889368194` were resolved with no reply and no row + +- PR number: 2851 +- Source review ID: 5889728498 +- Reviewer finding ID: F31 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562413688 +- Concern: A blanket GraphQL resolve call closed those five threads before they were read or replied to, against the skill's rule that a reply precedes resolution; the record had no row for them. +- Solution: All five threads were reopened, replied to with their disposition and verification (this round's F27 to F31), and resolved again after the replies. +- Current-tree verification: Read the five threads on the forge: each now has a reply before its resolution, and rows F27 to F31 above. +- Resolution reference: docs(pr-reviews): record round 6 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562442447 + +### F34 - This verification repeats the `udp-core` benchmark claim of F26 + +- PR number: 2851 +- Source review ID: 5889728498 +- Reviewer finding ID: F32 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562413698 +- Concern: The audit's own current-tree verification for F26 (round 5) repeated the inaccurate "only `connect_once`" claim that F28 (this round) corrects in the specification. +- Solution: The verification text for F26 above now reads "no `udp-core` or `udp-server` benchmark times an announce", matching the corrected specification wording. +- Current-tree verification: Read the F26 section of this record in the tree. +- Resolution reference: docs(pr-reviews): record round 6 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562442841 + +### F35 - The probe assumes the connect response is always 16 bytes and action 0 + +- PR number: 2851 +- Source review ID: 5890015379 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562634358 +- Concern: `struct.unpack(">iiq", ...[:16])` on the connect response raises `struct.error` with no useful message if the tracker returns a BEP15 error (action 3) or a packet shorter than 16 bytes. +- Solution: unpack only the first 8 bytes first (action, tid); check `action == 0` and exit with the decoded error message otherwise; only then unpack `connection_id` from the next 8 bytes. +- Current-tree verification: Read `evidence/udp_announce_probe.py` in the tree and `python3 -I -c "import ast; ast.parse(...)"` on it. +- Resolution reference: docs(issues): [#2838] parse the connect response defensively in the UDP probe +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562694766 + +### F36 - The document uses a `Category` value, `process`, that is not in its own allowed list + +- PR number: 2851 +- Source review ID: 5890015379 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562634429 +- Concern: Row F33 used `process` as its Category, which the Conventions section's enum does not list, so the taxonomy was not self-consistent. +- Solution: F33's Category is now `other`, a listed value. +- Current-tree verification: Read the Conventions section and row F33 in the tree. +- Resolution reference: docs(pr-reviews): record round 7 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562695099 + +### F37 - Duplicate of F36 + +- PR number: 2851 +- Source review ID: 5890015379 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562634476 +- Concern: Identical body to F36's comment, on a second thread. +- Solution: Superseded by F36; no separate change. +- Current-tree verification: Read F36 above. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562695454 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562695454 + +### F38 - `process` is not one of the record's categories + +- PR number: 2851 +- Source review ID: 5890044214 +- Reviewer finding ID: F35 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562653447 +- Concern: Row F33 used the category `process`, which the Conventions section's enum does not list. +- Solution: Already fixed (same defect as this round's F36) when F33's category was changed to `other`. +- Current-tree verification: Read row F33 in the tree. +- Resolution reference: docs(pr-reviews): record round 7 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562796674 + +### F39 - The resolution reference for F34 names a commit that does not contain its fix + +- PR number: 2851 +- Source review ID: 5890044214 +- Reviewer finding ID: F36 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562653454 +- Concern: F34's fix (the verification text in this file) is in the round-6 audit commit, but the row cited the spec-wording commit instead. +- Solution: F34's Resolution reference now cites `docs(pr-reviews): record round 6 in the review audit of PR #2851`. +- Current-tree verification: Read the F34 section in the tree. +- Resolution reference: docs(pr-reviews): record round 8 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562796991 + +### F40 - The round-6 entry gives reply times the forge does not have, and is stamped after its own commit + +- PR number: 2851 +- Source review ID: 5890044214 +- Reviewer finding ID: F34 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562653465 +- Concern: The round-6 entry said the eight replies were between 11:04:40Z and 11:07:55Z; the forge has them at 10:56:47Z to 10:57:03Z, before the two commits (10:58:56Z, 11:01:45Z) the entry is itself part of. +- Solution: An appended correction entry gives the forge reply times and the two commits' actual times; the original entry stays as it is. +- Current-tree verification: Read the round-6 log entry and the appended correction, and the forge `created_at` of the eight replies. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562797287 + +### F41 - The record cites two PR-branch commit ids + +- PR number: 2851 +- Source review ID: 5890044214 +- Reviewer finding ID: F33 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562653472 +- Concern: F32's section and its correction entry cited two PR-branch commit ids directly; `open-pull-request` allows no PR-branch commit id in a review audit. +- Solution: Both are now cited by Conventional Commit subject (`docs(pr-reviews): record round 5 in the review audit of PR #2851` and `docs(issues): [#2850] plan the performance baseline and the missing UDP announce benchmark`), as F13 was. +- Current-tree verification: Read the F32 section and the round-5 correction entry in the tree; the commit-id check. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562797657 + +### F42 - Round 7 was not in the record, four threads had no reply, and one reply claimed a fix not yet on the branch + +- PR number: 2851 +- Source review ID: 5890183339 +- Reviewer finding ID: F37 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562741696 +- Concern: At review time (11:30:41Z), the round-7 audit had not landed, four threads of review `5890044214` had no reply, and the category reply had been posted before its commit was pushed. +- Solution: Fixed by round 8, which added rows F38 to F41 for the four threads of `5890044214` and replied on each before resolving it. This review was made at the head of the round-7 probe fix (its forge `commit_id`), before the round-7 audit commit (`docs(pr-reviews): record round 7 in the review audit of PR #2851`, committed at 11:27:27Z); when that commit's push landed, relative to the review (11:30:41Z), is not known. +- Current-tree verification: Read rounds 7 and 8 of this record, and row F33, whose category reads `other`. +- Resolution reference: docs(pr-reviews): record round 8 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562798076 + +### F43 - The probe's new exit path is not described where its other changes are + +- PR number: 2851 +- Source review ID: 5890183339 +- Reviewer finding ID: F38 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562741687 +- Concern: The docstring and the evidence file's probe note described only the transaction-id exit, not the new one for a non-zero connect action. +- Solution: One sentence was added to each. +- Current-tree verification: Read the probe's docstring and the evidence file's probe note in the tree. +- Resolution reference: docs(issues): [#2838] document the probe's new error-response exit path +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562798378 + +### F44 - `last-updated-utc` is later than the commit that sets it + +- PR number: 2851 +- Source review ID: 5890340167 +- Reviewer finding ID: F41 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562840955 +- Concern: The stamp read 2026-11-13 11:35, but the commit that sets it was authored and committed at 11:33:25Z. +- Solution: The stamp now reads 2026-11-13 11:33, matching `git log` of that commit. +- Current-tree verification: Read the frontmatter of the evidence file and `git log -1 --format=%aI` of the probe-documentation commit. +- Resolution reference: docs(issues): [#2838] correct the probe evidence timestamp to its commit time +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562908350 + +### F45 - Rows F35 to F37 do not mark their severity as inferred + +- PR number: 2851 +- Source review ID: 5890340167 +- Reviewer finding ID: F40 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562840969 +- Concern: The three source comments carry no `[Severity]` bracket; the review body labels all three "Medium severity", so the severity needs the `(inferred)` marker, as F8 to F12 and F17 to F19 have it. +- Solution: Rows F35 to F37 now read `Minor (inferred)`, and the round-7 overview line names the label. +- Current-tree verification: Read rows F35 to F37 and the round-7 overview line in the tree. +- Resolution reference: docs(pr-reviews): record round 9 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562908674 + +### F46 - Four replies described audit changes not yet on the branch, and six threads had no row + +- PR number: 2851 +- Source review ID: 5890340167 +- Reviewer finding ID: F42 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562840977 +- Concern: At review time (11:42:28Z), round 8 had not yet landed; the four replies of 11:37:12Z to 11:37:19Z described fixes correctly, but those fixes were not pushed until round 8, after this review was posted. +- Solution: Fixed by round 8, which added rows F38 to F43 for exactly the six threads this finding names (`5890044214` and `5890183339`) and replied on each before resolving it. +- Current-tree verification: Read round 8 of this record, and that the six threads it names are replied to and resolved on the forge. +- Resolution reference: docs(pr-reviews): record round 8 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562909023 + +### F47 - The round-7 entry puts the audit commit and push before the replies + +- PR number: 2851 +- Source review ID: 5890340167 +- Reviewer finding ID: F39 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562840984 +- Concern: The round-7 entry says the audit commit and push happened before the three replies; the replies are at 11:24:58Z to 11:25:03Z (forge `created_at`), and the audit commit was authored at 11:25:12Z and committed at 11:27:27Z, after them. Same slip as this account's F34 on round 6. +- Solution: An appended correction entry gives the forge reply times and the commit's actual times; the original round-7 entry stays as it is. +- Current-tree verification: Read the round-7 log entry and the appended correction, and `git log --format=%aI`/`%cI` of the round-7 audit commit. +- Resolution reference: docs(pr-reviews): record round 9 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562909413 + +### F48 - Two rows were marked fixed by changes the head did not carry + +- PR number: 2851 +- Source review ID: 5890585973 +- Reviewer finding ID: F43 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562994961 +- Concern: Row F41's Concern still cited the two PR-branch commit ids it says were removed, and row F40 claimed an appended correction for the round-6 entry that the log did not have. +- Solution: Row F41's Concern describes the ids in words; a correction entry for the round-6 entry is appended; rows F40 and F41 cite the commit that carries their fixes. +- Current-tree verification: Scanned the audit for every PR-branch commit id (no match) and read the appended correction and rows F40 and F41 in the tree. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572494580 + +### F49 - Row F42 uses the category `process` + +- PR number: 2851 +- Source review ID: 5890585973 +- Reviewer finding ID: F44 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562994943 +- Concern: Row F42 used `process`, which is not one of the nine categories. +- Solution: Row F42's category is `other`. +- Current-tree verification: Read row F42 in the tree. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572494876 + +### F50 - Row F38 cites a commit that does not contain its fix + +- PR number: 2851 +- Source review ID: 5890585973 +- Reviewer finding ID: F45 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562994949 +- Concern: Row F38's fix is row F33's category change, made by the round-7 audit commit, but the row cited the round-8 audit commit. +- Solution: Row F38 cites `docs(pr-reviews): record round 7 in the review audit of PR #2851`. +- Current-tree verification: Read the F38 section in the tree. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572495191 + +### F51 - The round-8 text states things the record contradicts + +- PR number: 2851 +- Source review ID: 5890585973 +- Reviewer finding ID: F46 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562994965 +- Concern: Row F42 gave a placeholder time "11:25:xx" and a wrong line number; the overview and the round-8 entry said the reviewer's F37 and F38 do not collide; rows F42 and F46 were superseded without the skill's reply form. +- Solution: Row F42's Solution and verification are corrected, the overview states the collision, a correction for the round-8 entry is appended, and rows F42 and F46 are `FIXED`/`RESOLVED` with the round-8 audit commit, which fixed both concerns. +- Current-tree verification: Read the round-8 overview, rows and sections F42 and F46, and the appended correction in the tree. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572495561 + +### F52 - The round-9 entry is stamped before the replies it reports + +- PR number: 2851 +- Source review ID: 5890585973 +- Reviewer finding ID: F48 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4562994973 +- Concern: The round-9 entry, stamped 11:45, reports replies made at 11:49:59Z to 11:50:06Z and their resolution. +- Solution: An appended correction gives the reply and commit times; the original entry stays as it is. +- Current-tree verification: Read the appended correction and the forge `created_at` of the four replies. +- Resolution reference: docs(pr-reviews): correct rows and log entries of the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572495815 + +### F53 - The EPIC row says issue #2850 fixes the bug + +- PR number: 2851 +- Source review ID: 5891790581 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4563834211 +- Concern: The sub-issue row of #2838 in EPIC #1347 said the bug is "Fixed by" issue #2850, which is a planned specification. +- Solution: The row says #2850 is the planned fix and that the bug is present on `develop` until its implementation merges. +- Current-tree verification: Read the row and the frontmatter stamp of the EPIC in the tree. +- Resolution reference: docs(issues): [#1347] describe issue #2850 as the planned fix in the sub-issue table +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572496107 + +### F54 - The probe unpacks responses without checking their length + +- PR number: 2851 +- Source review ID: 5891790581 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4563834296 +- Concern: A response shorter than 8 bytes (or 16 for the connection id, 20 for the announce fields) made `struct.unpack` raise `struct.error`. +- Solution: The probe checks each length before unpacking and exits with status 1 printing the length. +- Current-tree verification: Ran the probe against a local fake UDP server: a correct exchange printed as before; 2-byte and 8-byte connect responses and a 9-byte announce response each exited 1 with the message. +- Resolution reference: docs(issues): [#2838] check the length of each UDP response in the probe +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572496414 + +### F55 - Duplicate of F54 + +- PR number: 2851 +- Source review ID: 5891790581 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4563834340 +- Concern: Identical body to F54's comment, on a second thread. +- Solution: Superseded by F54; no separate change. +- Current-tree verification: Read F54 above. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572496646 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572496646 + +### F56 - Row F42 uses the category `process` + +- PR number: 2851 +- Source review ID: 5891790581 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4563834396 +- Concern: The same change as F49. +- Solution: Superseded by F49; no separate change. +- Current-tree verification: Read row F42 in the tree. +- Resolution reference: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572496876 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572496876 + +### F57 - The evidence stamp is not quoted like the others in the pull request + +- PR number: 2851 +- Source review ID: 5891790581 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4563834460 +- Concern: The evidence file's `last-updated-utc` was unquoted while the other files of the pull request quote it. +- Solution: The stamp is quoted and carries the time of its last content commit. +- Current-tree verification: Read the frontmatter of the evidence file and `git log -1 --format=%aI` of the probe commit. +- Resolution reference: docs(issues): [#2838] check the length of each UDP response in the probe +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572497171 + +### F58 - The record gives two accounts of when the round-7 audit commit reached the branch + +- PR number: 2851 +- Source review ID: 5903179555 +- Reviewer finding ID: F50 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572599166 +- Concern: The F42 Solution said the round-7 audit commit was on the branch when review `5890183339` was posted, while the overview and the round-8 entry say that review came before it; the forge records no push time that orders them. +- Solution: The F42 Solution gives the same account as the other two places: the review was made at the head of the round-7 probe fix, and when the audit commit's push landed relative to the review is not known. An appended correction records the change. +- Current-tree verification: Read the F42 section, the round-8 overview and entry, and the appended correction in the tree; the forge `commit_id` of review `5890183339` is the round-7 probe-fix commit. +- Resolution reference: docs(pr-reviews): give one account of the round-7 audit commit in the audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572623767 + +### F59 - D4 calls the HTTP range expansion the only client-visible change + +- PR number: 2851 +- Source review ID: 5903247803 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572652820 +- Concern: D4 said the HTTP range expansion is the only client-visible change of the issue, but T2 also turns a UDP announce with a negative counter into a BEP 15 error response (AC12). +- Solution: The D4 bullet scopes that statement to HTTP and names the UDP change with AC12. +- Current-tree verification: Read D4 and AC12 of the #2850 specification in the tree. +- Resolution reference: docs(issues): [#2850] name the UDP rejection as a client-visible change +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572678561 + +### AUDIT-001 - Round 11 has no row or detail entry for F58 + +- PR number: 2851 +- Source review ID: 5903247803 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572652840 +- Concern: At the reviewed head the only mention of F58 was a correction entry; the table and the detail sections ended at F57 and review `5903179555` was not recorded. +- Solution: The round 11 audit commit, pushed after the reviewed head, added row F58 and its section with the source review, the original ID F50, the reply URL and the fixing commit. +- Current-tree verification: Read row F58 and its section in the tree. +- Resolution reference: docs(pr-reviews): record round 11 in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572678771 + +### F61 - The reviewer's AUDIT-001 is filed as F60, and row F59 records an ID that was not reassigned + +- PR number: 2851 +- Source review ID: 5903321950 +- Reviewer finding ID: F59 +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572709497 +- Concern: Copilot's IDs F59 and AUDIT-001 did not collide, so step 3 of `process-pr-review` keeps them; the record filed AUDIT-001 as F60 and gave F59 a `Reviewer finding ID` although it was not reassigned. +- Solution: The row and section are AUDIT-001, both entries read `Reviewer finding ID: N/A`, and an appended correction records the change. +- Current-tree verification: Read the round-12 overview, rows F59 and AUDIT-001 and their sections, and the appended correction in the tree; the validator accepts the ID. +- Resolution reference: docs(pr-reviews): keep the reviewer-provided IDs of round 12 in the audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4572725832 + +### F62 - The second rebase is recorded nowhere + +- PR number: 2851 +- Source review ID: 5904321921 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4573491069 +- Concern: The force push at 12:19:04Z rebased all commits onto `develop`, but the description still said the branch was rebased once, no log entry recorded the rewrite, and the commit ids that review comments cite were mapped to subjects nowhere. +- Solution: The History section of the description states the second rebase and its reason; a pull request comment maps each cited id to its commit subject, so this record cites no branch commit id; an appended log entry records the force push and points to that comment. +- Current-tree verification: Read the log entry stamped 12:28 and the description; each subject in the mapping comment names exactly one commit on the branch. +- Resolution reference: docs(pr-reviews): record the second rebase in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4573508877 + +### F63 - After the second rebase, the log's `%cI` times no longer hold + +- PR number: 2851 +- Source review ID: 5904321921 +- Reviewer finding ID: N/A +- Source URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4573491066 +- Concern: The second rebase set every committer time to 12:12:28Z to 12:12:58Z, so the entries that cite `git log --format=%cI` or give "committed at" times no longer match the branch; `%aI` keeps the original times, as F22 recorded for the first rebase. +- Solution: An appended correction in the processing log says so; no earlier entry was rewritten. +- Current-tree verification: Read the correction stamped 12:28 in the processing log. +- Resolution reference: docs(pr-reviews): record the second rebase in the review audit of PR #2851 +- Follow-up PR URL: N/A +- Reply URL: https://github.com/torrust/torrust-tracker/pull/2851#discussion_r4573508998 + +## Processing Log + +- 2026-11-12 18:05 UTC - Started round 1 for review `5879517733` (submitted 18:02:39Z, forge `submitted_at`). Checked F1 to F7 against the tree. +- 2026-11-12 18:07 UTC - F1: rewrote the branch history to reword two commit messages. The four commits after "docs(adrs): [#2842] cite the client evidence for the byte counts" were replayed in the same order; `git diff` between the old head and the rewritten head was empty. The first review cites two of them and its reviewed head by their earlier ids: "docs(issues): [#2838] carry over the spec and evidence from PR #2839", "docs(adrs): [#2842] point the inbound tolerance ADR at issue #2850" and, as the reviewed head, "docs(issues): [#2850] cite the commits of PR #2839 by subject". +- 2026-11-12 18:11 UTC - Fixes of F2 to F7 committed between 18:08:03Z and 18:11:27Z (`git log --format=%cI`), one commit each. +- 2026-11-12 19:30 UTC - The maintainer pushed the rewritten branch with `--force-with-lease`. Fetched the threads again and found Copilot's review `5879649645` (submitted 18:11:09Z) with five threads. Checked F8 to F12 against the tree; F10 is a re-raise of F2. +- 2026-11-12 19:36 UTC - Fixes of F8, F9, F11 and F12 committed between 19:33:34Z and 19:36:24Z (`git log --format=%cI`), one commit each, and pushed. +- 2026-11-12 19:37 UTC - Edited the pull request description for F1 and stated the history rewrite in it. +- 2026-11-12 19:38 UTC - Replied on the twelve threads between 19:38:23Z and 19:38:49Z (forge `created_at`). +- 2026-11-12 19:40 UTC - Started this audit record, after the replies, because it holds their URLs. +- 2026-11-12 19:41 UTC - `validate-audit-record.py --pr-number 2851` exited 0 (12 rows, 0 failures). Resolved the twelve threads; a GraphQL refresh showed 0 unresolved threads. +- 2026-11-12 19:57 UTC - Round 2: review `5881088057` of `da2ce7` (APPROVED, submitted 19:53:43Z, forge `submitted_at`) with four findings, F13 to F16, on the audit and the #2838 records. +- 2026-11-12 19:57 UTC - Correction for F13: the entry stamped 18:07 was rewritten in place to remove three commit ids of the branch as it was before the history rewrite; it now cites those commits by subject only. No other entry was rewritten. +- 2026-11-12 19:57 UTC - Correction for F14: the entry stamped 19:30 has the wrong time and actor. The forge timeline records the force push (`head_ref_force_pushed`) at 19:34:12Z with `josecelano-bot` as the actor; the maintainer ran `git-bot-push --force-with-lease`, which pushes as that account. The entry stamped 19:36 says "and pushed": the commits are stamped up to 19:36:24Z and their push landed later, before the first reply at 19:38:23Z, whose forge record names that head. +- 2026-11-12 20:01 UTC - Round 2: the four fixes were committed between 19:55:16Z and 19:57:12Z (`git log --format=%cI`) and their push had landed by 20:00:04Z (`git ls-remote` of the fork matched the local head). Replied on the four threads between 20:00:05Z and 20:00:12Z (forge `created_at`). `validate-audit-record.py --pr-number 2851` exited 0 (16 rows, 0 failures). Resolved the four threads; a GraphQL refresh showed 0 unresolved threads. +- 2026-11-12 20:38 UTC - Round 3: Copilot's review `5881522270` (submitted 20:28:18Z, forge `submitted_at`) with three findings, F17 to F19. Before it was read, the branch had been rebased onto `develop`, because the pull request conflicted in the sub-issue table of EPIC #1347 after PR #2841 merged; every commit was replayed in the same order. The three fixes were committed between 20:31:34Z and 20:32:42Z (`git log --format=%cI`). The forge timeline records the force push of the rebased branch at 20:37:18Z (`head_ref_force_pushed`, actor `josecelano-bot`; the maintainer ran `git-bot-push --force-with-lease`). Edited the pull request description to state the rebase. Replied on the three threads between 20:37:44Z and 20:37:50Z (forge `created_at`). `validate-audit-record.py --pr-number 2851` exited 0 (19 rows, 0 failures). Resolved the three threads; a GraphQL refresh showed 0 unresolved threads. +- 2026-11-13 07:44 UTC - Round 4: the approving review `5887584344` of `da2ce7` (submitted 2026-11-13 07:28:03Z, forge `submitted_at`) at the head that carried the round 3 audit, with three nits, F20 to F22. The F21 fix was committed and pushed first; the replies on the three threads follow it (forge `created_at`). Correction for F22: the rebase set the committer time of the 24 commits up to the round 2 audit to 20:28:16Z to 20:28:32Z, so `git log --format=%cI` does not give the times that the entries stamped 18:11, 19:36 and the F16 verification cite. `git log --format=%aI` keeps the original times (18:08:03Z, 18:11:27Z, 19:33:34Z, 19:55:16Z, 19:57:12Z), except that the last fix of the 19:36 range shows 19:35:03Z there, not 19:36:24Z. No earlier entry was rewritten. +- 2026-11-13 09:50 UTC - Round 5: the approving review `5887875398` of `da2ce7` (forge `submitted_at` 2026-11-13 08:00:46Z) with two nits, F23 and F24, and Copilot's review `5888919892` (submitted 09:39:31Z, forge `submitted_at`) with two findings, F25 and F26, on the head that carried the round 4 audit. Their fixes were committed and pushed before the replies on the four threads (forge `created_at` 09:5x). Correction for F24: the entry stamped 20:01 cites `git log --format=%cI` for the four round 2 fixes (19:55:16Z to 19:57:12Z); after the rebase `%cI` shows 20:28:31Z for them, and `%aI` keeps 19:55:16Z to 19:57:12Z. No earlier entry was rewritten. +- 2026-11-13 11:10 UTC - Round 6: two reviews of `da2ce7` that had not yet been processed. `5889368194` (submitted 10:21:06Z, forge `submitted_at`) with five findings in the reviewer's own numbering F25 to F29, on the head that carried the round-5 spec commits before the round-5 audit landed; its five threads had been resolved earlier by a blanket GraphQL call with no reply, against the skill's rule. `5889728498` (submitted 10:54:09Z, forge `submitted_at`) with three findings, reviewer's own F30 to F32, on the head that carried the round-5 audit. Both sets of reviewer IDs collide with existing audit IDs (F25, F26, F30, F31), so new audit-local IDs F27 to F34 were assigned, recording the originals. The five wrongly-resolved threads were reopened (`unresolveReviewThread`), then all eight threads were replied to between 11:04:40Z and 11:07:55Z (forge `created_at`), apologizing on the five for the process error. The spec fix (F28, F29, F30, F31, F34 wording) was committed as `docs(issues): [#2850] correct benchmark wording, add a Commit Points row, and record the tolerance write-back` and the audit rows and sections as `docs(pr-reviews): record round 6 in the review audit of PR #2851`, then pushed. `validate-audit-record.py --pr-number 2851` exited 0 (34 rows, 0 failures). Resolved all eight threads, in order, after their replies; a GraphQL refresh showed 0 unresolved threads. +- 2026-11-13 11:10 UTC - Correction for F32: the round-5 log entry (stamped 09:50) says the F23/F24 fix was committed and pushed before the four replies, with a placeholder time "09:5x". The fix is commit `docs(pr-reviews): record round 5 in the review audit of PR #2851`, authored and committed at 10:38:07Z (`git log --format=%aI`/`%cI`), 52 minutes after the four replies (forge `created_at` 09:46:22Z to 09:46:28Z). The listener and benchmark-plan fixes (`docs(issues): [#2850] plan the performance baseline and the missing UDP announce benchmark`, pushed by 09:46:13Z) are unaffected by this correction. No earlier entry is rewritten. +- 2026-11-13 11:25 UTC - Round 7: Copilot's review `5890015379` (submitted 11:17:55Z, forge `submitted_at`; a timed-out agentic pass with three mechanical comments) at the head that carried the round-6 audit, with F35 to F37 (audit-local IDs; no reviewer-provided IDs). F35 fixed in the probe script. F36 fixed in the audit's own Category value for F33. F37 replied `Superseded by F36: duplicate comment with identical body.` and recorded `NO_ACTION`/`SUPERSEDED`. The probe fix was committed as `docs(issues): [#2838] parse the connect response defensively in the UDP probe` and the audit rows and sections as `docs(pr-reviews): record round 7 in the review audit of PR #2851`, then pushed. Replied on the three threads, then resolved them. +- 2026-11-13 11:40 UTC - Round 8: two reviews that had been missed, because a blanket GraphQL resolve call closed their threads again before they were read, repeating the round-5/6 mistake. `5890044214` (submitted 11:20:08Z, forge `submitted_at`, DISMISSED) with four findings at the head that carried the round-6 audit, reviewer's own F33 to F36 (collides with existing audit IDs, reassigned F38 to F41, originals recorded). `5890183339` (submitted 11:30:41Z, COMMENTED) with two findings at the head that carried the probe fix of round 7's F35, before round 7's audit commit had landed; reviewer's own F37 and F38, reassigned F42 and F43 (no collision, reassigned anyway for this record's own sequencing). All six threads were reopened (`unresolveReviewThread`) before any reply. The probe-documentation fix (F43) was committed as `docs(issues): [#2838] document the probe's new error-response exit path` and pushed first; the audit corrections (F38 to F42) as `docs(pr-reviews): record round 8 in the review audit of PR #2851`. Replied on all six threads between 11:37:09Z and 11:37:21Z (forge `created_at`), then resolved each of the six threads individually by its own thread id — never by a scan-all-unresolved call. `validate-audit-record.py --pr-number 2851` exited 0 (43 rows, 0 failures). A GraphQL refresh showed 0 unresolved threads. +- 2026-11-13 11:45 UTC - Round 9: the review `5890340167` of `da2ce7` (submitted 11:42:28Z, forge `submitted_at`) at the head that carried the round-7 probe-documentation commit, before round 8 had landed, with four findings, reviewer's own F39 to F42, reassigned F44 to F47 (originals recorded). F44 fixed the evidence timestamp. F45 fixed the missing `(inferred)` marker on F35 to F37. F46 was already superseded by round 8, which this review predates; replied noting that. F47 fixed by an appended correction below. The timestamp fix was committed as `docs(issues): [#2838] correct the probe evidence timestamp to its commit time` and the audit changes as `docs(pr-reviews): record round 9 in the review audit of PR #2851`. Replied on all four threads, then resolved each individually by its own thread id. +- 2026-11-13 11:45 UTC - Correction for F47: the round-7 entry says the probe fix was committed, the audit commit followed, and both were pushed, before the three replies. The replies are at 11:24:58Z, 11:25:00Z and 11:25:03Z (forge `created_at`). The round-7 audit commit was authored at 11:25:12Z and committed at 11:27:27Z, after all three. The probe-script commit (`docs(issues): [#2838] parse the connect response defensively in the UDP probe`) was authored and committed at 11:21:30Z, before the replies, so that half of the entry holds. No earlier entry is rewritten. +- 2026-11-14 08:08 UTC - Correction for F40: the round-6 entry (stamped 11:10) gives the eight replies as 11:04:40Z to 11:07:55Z and places them after both commits. The forge has the replies at 10:56:47Z to 10:57:03Z (`created_at`). Both commits came after them: `docs(issues): [#2850] correct benchmark wording, add a Commit Points row, and record the tolerance write-back` was authored and committed at 10:58:56Z, and `docs(pr-reviews): record round 6 in the review audit of PR #2851` was authored at 10:59:31Z and committed at 11:01:45Z (`git log --format=%aI`/`%cI`). No earlier entry is rewritten. +- 2026-11-14 08:08 UTC - Correction for the round-8 entry (stamped 11:40): it says the reviewer's own F37 and F38 of review `5890183339` do not collide. They collide with the audit's own F37 (since round 7) and F38 (assigned in the same round); they were reassigned F42 and F43 because of that. Row F42 also said the round-7 audit commit landed at "11:25:xx"; it was authored at 11:25:12Z and committed at 11:27:27Z. Rows F42 and F46 were `NO_ACTION`/`SUPERSEDED` with replies not in the `Superseded by : .` form; both concerns were fixed by the round-8 audit commit, so both rows are now `FIXED`/`RESOLVED` with that commit as their reference. No earlier entry is rewritten. +- 2026-11-14 08:08 UTC - Correction for the round-9 entry (stamped 11:45): it reports the four replies and their resolution, which happened later. The replies are at 11:49:59Z to 11:50:06Z (forge `created_at`); the round-9 audit commit was authored at 11:49:22Z and committed at 11:50:46Z. No earlier entry is rewritten. +- 2026-11-14 08:14 UTC - Round 10: the approving review `5890585973` of `da2ce7` (submitted 2026-11-13 12:00:03Z, forge `submitted_at`) with five findings, reviewer's own F43 to F46 and F48, reassigned F48 to F52; and Copilot's review `5891790581` (submitted 13:27:29Z) with five, F53 to F57; both on the head that carried the round 9 audit. The fixes were committed between 08:06:35Z and 08:09:24Z (`git log --format=%aI`) as `docs(issues): [#1347] describe issue #2850 as the planned fix in the sub-issue table`, `docs(issues): [#2838] check the length of each UDP response in the probe` and `docs(pr-reviews): correct rows and log entries of the review audit of PR #2851`, and their push had landed by 08:13 (`git ls-remote` of the fork matched the local head). Replied on the ten threads between 08:13:39Z and 08:14:01Z (forge `created_at`). The threads are resolved one by one, by their own thread id, after this entry's commit is pushed. +- 2026-11-14 08:33 UTC - Correction for F58: the corrected F42 Solution (from the round-10 corrections) said the round-7 audit commit was already on the branch when review `5890183339` was posted. The forge records that review at the head of the round-7 probe fix, as the overview and the round-8 entry say, and no push time that orders the round-7 audit commit (committed 11:27:27Z) against the review (11:30:41Z). The F42 Solution now says so. No earlier entry is rewritten. +- 2026-11-14 08:38 UTC - Round 11: the approving review `5903179555` of `da2ce7` (submitted 08:32:57Z, forge `submitted_at`) at the head that carried the round 10 audit, with one Nit, reviewer's own F50, reassigned F58. The fix was committed as `docs(pr-reviews): give one account of the round-7 audit commit in the audit of PR #2851` (authored and committed 08:33:41Z) and its push had landed before the reply (`git ls-remote` of the fork matched the local head). Replied on the thread at 08:38:09Z (forge `created_at`). The thread is resolved by its own thread id after this entry's commit is pushed. +- 2026-11-14 08:51 UTC - Round 12: Copilot's review `5903247803` (submitted 08:45:50Z, forge `submitted_at`) at the head that carried the round-11 fix, before the round 11 audit was pushed, with two findings, F59 and AUDIT-001. F59 was fixed as `docs(issues): [#2850] name the UDP rejection as a client-visible change` (authored and committed 08:47:17Z) and its push had landed before the replies (`git ls-remote` of the fork matched the local head). AUDIT-001 was already fixed by `docs(pr-reviews): record round 11 in the review audit of PR #2851`. Replied on both threads at 08:50:50Z and 08:50:52Z (forge `created_at`). The threads are resolved one by one, by their own thread id, after this entry's commit is pushed. +- 2026-11-14 09:02 UTC - Correction for round 12: Copilot's IDs F59 and AUDIT-001 do not collide with this record, so both are kept, as step 3 of `process-pr-review` asks. The row and section first filed as F60 are now AUDIT-001, and both entries read `Reviewer finding ID: N/A`; the overview and the round-12 entry are updated to match, because they named the IDs only. The two round-12 replies still say "audit F59" and "audit F60"; F60 is not used for any other finding. No other entry is rewritten. +- 2026-11-14 09:07 UTC - Round 13: the approving review `5903321950` of `da2ce7` (submitted 09:00:28Z, forge `submitted_at`) at the head that carried the round 12 audit, with one Nit, reviewer's own F59, reassigned F61. The fix was committed as `docs(pr-reviews): keep the reviewer-provided IDs of round 12 in the audit of PR #2851` (authored and committed 09:03:22Z) and its push had landed before the reply (`git ls-remote` of the fork matched the local head). Replied on the thread at 09:06:51Z (forge `created_at`). The thread is resolved by its own thread id after this entry's commit is pushed. +- 2026-11-14 12:28 UTC - Second rebase: after the approval of round 13, the pull request conflicted with `develop` in the sub-issue table of EPIC #1347, because #2852 changed its row 11. The branch was rebased onto `develop`; the conflict was resolved by keeping the row of `develop` and the branch's #2838 row after it, and every commit was replayed in the same order with the same changes. The forge timeline records the force push at 12:19:04Z (`head_ref_force_pushed`, actor `josecelano-bot`; pushed with `git-bot-push --force-with-lease`). The commit ids that review comments cite no longer name commits on the branch. The pull request comment https://github.com/torrust/torrust-tracker/pull/2851#issuecomment-6877254223 (forge `created_at` 12:27:16Z) maps each of them to its commit subject, so that this record cites no branch commit id. The History section of the pull request description now states the second rebase. +- 2026-11-14 12:28 UTC - Correction for F63: the second rebase set the committer time of all 52 commits to 12:12:28Z to 12:12:58Z, so `git log --format=%cI` no longer gives the times that the entries citing it give, and a "committed at" time that differs from the author time can no longer be read from the branch. `git log --format=%aI` keeps the original author times. This is the effect that the correction for F22 recorded for the first rebase. No earlier entry is rewritten. +- 2026-11-14 12:32 UTC - Round 14: the approving review `5904321921` of `da2ce7` (submitted 12:25:15Z, forge `submitted_at`) at the head of the second rebase, with F62 (Minor) and F63 (Nit). The mapping comment was posted at 12:27:16Z and the description edited before the fix commit `docs(pr-reviews): record the second rebase in the review audit of PR #2851` (authored and committed 12:28:05Z), whose push had landed before the replies (`git ls-remote` of the fork matched the local head). Replied on both threads at 12:32:15Z and 12:32:17Z (forge `created_at`). The threads are resolved one by one, by their own thread id, after this entry's commit is pushed. + +## 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. diff --git a/project-words.txt b/project-words.txt index 535e30bb9e..2541c5a5ff 100644 --- a/project-words.txt +++ b/project-words.txt @@ -106,6 +106,7 @@ SUBSESSIONS Seedable Shareaza Signedness +Spek Subissues Swatinem Swiftbit @@ -351,6 +352,7 @@ libraw libsqlite libstdc libtorrent +libtransmission libz llist loadavg @@ -494,6 +496,7 @@ rqbit rsplit rstest rstrip +rtorrent rusqlite rustc rustdoc @@ -600,6 +603,7 @@ unpushed unrecognised unrepresentable unreproduced +unresolve unreviewed unseparated unspawned