Skip to content

docs(issues): [#2681] specify gating the tracker-core test modules and mocks - #2682

Merged
josecelano merged 8 commits into
torrust:developfrom
josecelano:2681-2482-gate-tracker-core-test-modules-and-mocks-spec
Oct 28, 2026
Merged

josecelano merged 8 commits into
torrust:developfrom
josecelano:2681-2482-gate-tracker-core-test-modules-and-mocks-spec

Conversation

@josecelano

Copy link
Copy Markdown
Member

Related to #2681

Spec-only PR for subissue 3 of sub-EPIC #2482 (row 3: gate tracker-core's test modules and mocks). It contains no code change.

What it adds

  • The refreshed specification at docs/issues/open/2681-2482-gate-tracker-core-test-modules-and-mocks/ISSUE.md (moved from the draft under docs/issues/drafts/), re-verified against develop: module declarations and line numbers, the consumers of each Mock* type, the dependency kind of mockall, and a measured plain-test baseline (tracker-core 155 unit, 12 integration, 16 doc; http-core 191 unit, 1 doc; udp-core 99 unit, 3 doc and 3 ignored).
  • Row 3 of the Reorganize test support code shared between workspace packages (EPIC #1669) #2482 Subissues table (issue number, spec path, IN_PROGRESS), the intro sentence and a Progress Log entry, plus the inventory links.

Design decisions (settled with the maintainer on 2026-10-28)

  • Only MockTorrentMetricsStore, the one mock other packages use (http-core and udp-core unit tests), goes behind the non-default testing feature, with mockall becoming an optional dependency (testing = ["dep:mockall"]). The other three mocks are used by nobody outside tracker-core (and two by nobody at all), so they use cfg_attr(test, automock) (ADR rule D.2). This narrows the literal text of ADR rule D.1 ("all four"); the spec adds a dated amendment note to the ADR as task T7.
  • The helper modules peer_tests, test_helpers and whitelist::test_helpers become private #[cfg(test)] mod (rule C).
  • tracker-core's own targets use the path-only self dev-dependency (ADR option O1c); http-core and udp-core enable the feature from their [dev-dependencies].
  • A discarded prototype found two side effects that the earlier draft missed and the spec now covers: cargo deny check bans needs torrust-tracker-core in its own wrappers list once it has a self dev-dependency (same commit as the manifest change), and clippy's redundant_pub_crate requires pub mod tests inside the now-private helper modules.
  • Every option with strengths, weaknesses and the rejected alternatives is recorded in the spec (D1 to D6).

Review notes

The implementation PR follows after this one merges and will close #2681. The Shipped Features job gets its first real testing feature to check there.

@josecelano
josecelano requested review from da2ce7 and a balanced review from Copilot October 28, 2026 12:11
@josecelano josecelano self-assigned this Oct 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test plan has a premature feature checkpoint and lacks reliable checks for doc tests, dependency edge kinds, and mockall’s production dependency status.

4 open issues
What changed in this PR

This documentation-only PR prepares #2681, part of #2482’s effort to keep shared test support out of production builds. It specifies the tracker-core migration without changing runtime code.

Changes:

  • Promotes the draft to an open issue specification with refreshed baselines, decisions, implementation steps and verification criteria.
  • Limits feature-gated sharing to MockTorrentMetricsStore; keeps other mocks and helpers test-only.
  • Registers #2681 in the parent EPIC and updates inventory links.
File Description
docs/​issues/​open/​2681-2482-gate-tracker-core-test-modules-and-mocks/​ISSUE.md Adds the refreshed migration specification and verification plan.
docs/​issues/​open/​2482-1669-reorganize-shared-test-support/​test-support-inventory.md Points patterns C and D to the open specification.
docs/​issues/​open/​2482-1669-reorganize-shared-test-support/​EPIC.md Registers #2681, marks row 3 in progress and records the design decision.
docs/​issues/​drafts/​2482-gate-tracker-core-test-modules-and-mocks/​ISSUE.md Removes the draft replaced by the open specification.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
4 resolved since last review

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The issue document records the implementation branch instead of the required spec-only PR branch.

1 open issue
2 resolved since last review

Review effort: Balanced

@josecelano

Copy link
Copy Markdown
Member Author

ACK 98a6e13

@josecelano
josecelano merged commit 0edeb13 into torrust:develop Oct 28, 2026
1 check passed

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 98a6e13b3c03b4fa2ebf4aa17007b8ec7bf4f30c (post-merge). Recomputed from the bytes at the merged head, against the base 883cc834c94869e04dd1f8fadc6936fd884322d8; the PR merged on 2026-10-28 at 16:24:54Z as 0edeb136c.

Label: POST_MERGE_FINDINGS — Review was requested on 2026-10-28 at 12:11:56Z. The PR merged before this round ran. The findings below stand at the merged head for a follow-up; no ACK follows a merged PR.

Claims and change: eight commits change five documentation paths, with no implementation. Four database mocks exist; only MockTorrentMetricsStore has cross-package consumers, in the stated four unit-test modules. The planned optional dependency, feature gates, private helper modules, self dev-dependency, consumer dev edges and wrapper allowance fit the inspected manifests and ADR, with the D.1 amendment explicitly deferred to T7. Unit counts recompute to 155/191/99 and integration counts to 12/0/0; the published doc-test baseline omits compile-fail cases. Prototype execution and approval claims have no independent run artifacts in this capture.

Records: the draft move, EPIC row and inventory links agree. All 47 relative Markdown links resolve. The final spec timestamp matches its branch-metadata edit. F1-F7 have the correct source-review associations, same-thread replies and unique fixing subjects where applicable, and all seven threads are resolved. The severity labels and one Processing Log event need corrections below. The five-mock references also overstate the actual inventory.

Hygiene: all eight commit subjects are Conventional and carry the issue tag; author and committer identities match and all per-commit whitespace checks are clean. Attribution footer lines occur in all eight commits; no applicable prohibition was found. The description contains a closing-pattern match for issue 2681 inside its future-implementation sentence, and that sentence is copied into the merge message. The introductory related-issue reference does not neutralize it. New terminology was compared with the project dictionary; independent spelling verification remains outstanding.

The review bot: review 5682548756's four concerns were valid and addressed: checkpoint moved to T4, matching doc-test commands added, dependency-tree inspection added, and coupling expectations corrected. Review 5683278144's two double-pipe claims were false at its reviewed tree; both declines are supported by the bytes. Review 5683607616's branch-name concern was valid and fixed. None of those source concerns needs re-raising.

Findings: F8 (Minor), the issue-closing reference that closed the implementation issue on merge (reopened three minutes later); F9-F11 (Minor), incomplete doc-test baseline, unmarked inferred severities and a premature push entry; F12 (Nit), nonexistent fifth mock.

Checked, no finding: all implementation tasks remain TODO, feature sharing is limited to the one consumed mock, default builds remain a required check, and test counts must be compared using matching commands. PR 2680 changes interval types independently; its tests use the existing core test infrastructure. PRs 2684 and 2685 archive configuration records and do not implement this spec. The open implementation PR 2688 is outside this review.

Checks

On the loop's compute hub at the merged head, against the base 883cc834c (receipt server-gates-sojka-479; the PR merged as 0edeb136c): pre-commit profile gate exit 0 (109 s); linter markdown, linter cspell, linter lychee exit 0; frontmatter-validator --all: 16 errors / 4 warnings at the merged head and 16 / 4 at the base re-measured, the same 20 diagnostics by path and category; the audit validator over docs/pr-reviews/pr-2682-review/PR-REVIEW.md with the review comments and commit list captured at gate time: ok, 7 rows, 3 log entries, 0 failures. GitHub checks at this head at posting time: "Docs Lint: completed/success". At posting, develop is 968099d93.

- [x] Spec reviewed and approved by user/maintainer (the maintainer, 2026-10-28)
- [x] GitHub issue created, linked as a sub-issue of #2482 (`parent_issue_url` verified), and its number added to this spec
- [ ] Spec-only PR merged into `develop` before implementation
- [ ] Implementation completed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor][F8] Keep the specification PR from closing the implementation issue

This concerns the PR description, anchored to the changed checkpoint that correctly leaves implementation outstanding. Its Review notes sentence says the later implementation PR “will close #2681”. The repository's open-pull-request closing-keyword pattern matches that phrase, and the same sentence is present in merge 0edeb136c. Future tense does not protect an issue reference from the closing mechanism. This PR changes only documentation and leaves T1–T8 and implementation unchecked. The forge shows the effect: the merge closed issue 2681 at 16:24:55Z, and it was reopened at 16:27:15Z, so the damage was repaired the same afternoon, and the implementation PR records the lesson in its last commit. What remains is the description: use a related-issue reference without a closing verb. Editing it cannot remove the phrase already stored in the merge history.


| Package | Unit tests | Integration tests | Doc tests |
| --- | --- | --- | --- |
| `torrust-tracker-core` | 155 | 12 (`tests/integration.rs`) | 16 passed |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor][F9] Include compile-fail doctests in the baseline

The Doc tests column counts ordinary tests but omits the compile-fail examples already present at this head. tracker-core/src/statistics/repository.rs:22,30 contributes two; http-core/src/statistics/repository.rs:18,26 contributes two; udp-core/src/container.rs:145, crypto/cookie_cipher.rs:40, and statistics/repository.rs:18,26 contribute four. Thus the source inventory is 18 core doctests, 3 HTTP doctests, and 10 UDP doctests including three ignored, rather than 16, 1 and 6 total. These examples protect API restrictions and are part of the no-test-loss contract in AC3. Record compile-fail counts separately and compare them in T1/T5, preserving all result groups rather than only the ordinary-test summary. This is a source inventory, not a claim that these tests were executed in this lane.


| Finding ID | Review finding reference | Author class | Severity | Category | Relationship | Disposition | Thread state |
| ---------- | ------------------------ | ------------ | -------- | -------- | ------------ | ----------- | ------------ |
| F1 | review-finding:pr-2682-f1 | Copilot | Minor | documentation | ORIGINAL | FIXED | RESOLVED |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor][F10] Mark the normalized severities as inferred

None of the seven captured source comments contains a repository severity bracket, yet every row records bare Minor. The review overviews supply Low or Medium labels, which require interpretation to map into the repository scale. Both this record's Status Values and process-pr-review require (inferred) when severity comes from free prose. Add that marker to F1–F7 and state the mapping, so later audit consumers can distinguish reviewer-provided severity from local normalization. PR 2680's audit already follows this rule.


- 2026-10-28 12:33 UTC - The review of `copilot-pull-request-reviewer` (5682548756) arrived with four inline threads, F1 to F4. Each claim was checked against the spec and the tree and confirmed; each was fixed in its own signed commit, replied on, and resolved. This record is committed and pushed after the fixes; da2ce7 is re-requested after the push.
- 2026-10-28 13:45 UTC - Round 2: review 5683278144 arrived with a timeout warning and two inline threads, F5 and F6. The claim (rows starting with `||`) was checked against both files and found false; replied with the prescribed `Superseded by F5:` and `Superseded by F6:` forms and resolved both threads. Copilot was re-requested once because of the warning.
- 2026-10-28 13:45 UTC - Round 3: the re-requested review 5683607616 arrived with one inline thread, F7. The claim was confirmed against the `create-issue` skill, fixed in its own signed commit, replied on and resolved. This record is committed and pushed after the fix; da2ce7 is re-requested after the push.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor][F11] Correct the log entry that records a push before its commit existed

The 13:45 entry includes this audit being committed and pushed after the F7 fix. The commit that first carries this entry is 98a6e13b3, with author and committer time 2026-10-28T13:46:32Z; its push cannot have completed in the recorded 13:45 minute. The F7 fix at 13:45:03 and reply at 13:45:39 do fit that minute, but the later audit delivery does not. process-pr-review requires event timestamps after the event and append-only corrections. Append a correction separating the verified fix/reply times from the later delivery, and identify an actual push timestamp or explicitly leave it unverified.

## Acceptance Criteria

- [ ] AC1: `cargo tree -p torrust-tracker-core -e normal --depth 1` shows no direct dependency on
`mockall` in a default build, and a default build's public API contains none of the five

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Nit][F12] Name the four mocks rather than an unexplained fifth

The source and this spec's Pattern D table contain exactly MockAuthKeyStore, MockSchemaMigrator, MockTorrentMetricsStore and MockWhitelistStore. No fifth core mock is declared or re-exported. AC1, T1 and Risks nevertheless refer to five names, so an implementer cannot tell what extra API must be checked. Replace all three occurrences with the four explicit names, or identify and demonstrate a fifth target if one was intended.

josecelano added a commit that referenced this pull request Oct 29, 2026
… mock behind a testing feature

ec12c79 docs(pr-reviews): [#2681] record the second da2ce7 review of PR 2688 (Jose Celano)
5069d21 docs(issues): [#2681] embed the retained verification script and name its state-check commands (Jose Celano)
55696ce docs(pr-reviews): [#2681] record the da2ce7 review of PR 2688 (Jose Celano)
edbc22f docs(pr-reviews): [#2681] mark the normalized severities as inferred (Jose Celano)
9e81990 docs(issues): [#2681] record a stamped re-run of the verification sequence (Jose Celano)
00ed4e9 docs(pr-reviews): [#2681] append the chronology correction for the audit and the spec log (Jose Celano)
258e8f9 docs(pr-reviews): [#2681] correct the visibility rationale for declining F1 and F2 (Jose Celano)
4980517 docs(issues): [#2681] record the closing-keyword lesson of the spec PR (Jose Celano)
05bc0b2 docs(pr-reviews): [#2681] record the second Copilot review of PR 2688 (Jose Celano)
2a42023 docs(issues): [#2681] test the preserved shipped-profile binary in the evidence (Jose Celano)
6571e2c docs(pr-reviews): [#2681] record the review of PR 2688 (Jose Celano)
c01ddd5 docs(issues): [#2681] record the pre-PR review, the completion review and the retrospective (Jose Celano)
89dae2d docs(tracker-core): [#2681] explain the testing mock, the self wrapper and the pub test modules (Jose Celano)
7d84d6c docs(issues): [#2681] record the manual verification evidence (Jose Celano)
4637298 docs(adrs): [#2681] narrow rule D.1 to the mock other packages use (Jose Celano)
fff8dc0 docs(issues): [#2681] mark inventory patterns C and D resolved (Jose Celano)
d6f81f1 refactor(tracker-core): [#2681] put the torrent metrics mock behind a testing feature (Jose Celano)
51b7077 refactor(tracker-core): [#2681] generate the crate-private database mocks only for tests (Jose Celano)
b0e85c1 refactor(tracker-core): [#2681] make the crate-private test helper modules private (Jose Celano)

Pull request description:

  Closes #2681

  Subissue 3 of sub-EPIC #2482 (row 3: gate `tracker-core`'s test modules and mocks), the first row that adds a `testing` feature to a real crate. The spec merged in #2682; the design decisions are recorded there (D1 to D6).

  ## What changes

  - Rule C: `peer_tests`, `test_helpers` and `whitelist::test_helpers` are private `#[cfg(test)]` modules, no longer empty public modules in the API.
  - Rule D: `MockTorrentMetricsStore`, the one mock other packages use (`http-core` and `udp-core` unit tests), is generated behind the new non-default `testing` feature (`testing = ["dep:mockall"]`, `mockall` is now an optional dependency). The other three mocks are used by no other package, so they use `#[cfg_attr(test, automock)]` (ADR rule D.2); the ADR gets an amendment note narrowing rule D.1 ("all four"), as the maintainer decided on 2026-10-28.
  - `tracker-core`'s own targets use a path-only self dev-dependency (ADR option O1c) and `http-core` and `udp-core` enable the feature from their `[dev-dependencies]`. No `[dependencies]` entry or `default` chain enables `testing`.
  - `deny.toml`: `torrust-tracker-core` is listed as its own wrapper, which the self dev-dependency requires (`cargo deny check bans` fails without it). It is in the same commit as the manifest change.
  - The inventory marks patterns C and D resolved. The evidence is in `manual-verification-evidence.md` (V0 to V8), and there is an implementation retrospective for rows 4 to 7.

  ## Verification

  - A default `tracker-core` build has no direct `mockall` dependency (`cargo tree -p torrust-tracker-core -e normal --depth 1`) and `mockall` is absent from the normal graph of `http-core` and `udp-core` (`cargo tree -i mockall`), while their tests still compile (red before their dev-dependency entries, green after).
  - Test counts are equal before and after in 12 commands (the three packages, plain, `--all-features`, `--all-targets --all-features` and `--doc --all-features`); no `required-features` is used.
  - The `Shipped Features` job's check is green on the real tree, and red (exit 1) when the feature is put on a `[dependencies]` entry or in `default`. The shipped-profile binary has no `Mock*` or `mockall` strings, with a positive control.
  - `cargo machete --with-metadata`, `cargo deny check bans`, `cargo +stable package --workspace --no-verify` and the pre-push script pass. An independent pre-PR review returned PASS WITH FINDINGS; its findings are fixed or answered in the evidence (V8).

  ## Notes for reviewers

  - The pattern is breaking for a crate that is not yet published (`pub mod` to private, the mocks leaving the default API); #2583 decides versions and this PR does not touch its spec.
  - `MockWhitelistStore` and `MockSchemaMigrator` are used by no test; they stay under `cfg(test)` to keep this change behaviour-preserving. Deleting them is a separate cleanup.
  - Rows 4 to 7 reuse the pattern, including the `deny.toml` self-wrapper entry.

ACKs for top commit:
  da2ce7:
    ACK ec12c79 — verified the documentation delta, V9 command correspondence and clean integration with develop
  josecelano:
    ACK ec12c79

Tree-SHA512: 2faabec61a43508a83edcefeffb4889056d49c32c044d342cd30a0681e494c22454da4f6d41708cae2bd203a98ecaf7efb2f3148fb62f0fa5ce7a9b7c3eba5f1
josecelano added a commit that referenced this pull request Oct 30, 2026
…ssues/closed

7642cf1 docs(issues): [#2681] fix the chronological order of the row-3 completion log entry and keep the F10 chronology precise (Jose Celano)
1100613 docs(pr-reviews): [#2681] record the post-merge finding F10 of PR 2688 with maintainer approval (Jose Celano)
262b772 chore(issues): archive closed issue #2681 spec to docs/issues/closed (Jose Celano)

Pull request description:

  Archives the spec for issue #2681 (closed by the merge of PR #2688) from `docs/issues/open/` to `docs/issues/closed/`, and sets row 3 of the #2482 Subissues table to DONE.

  - Verified issue #2681 is `CLOSED` on GitHub (closed when PR #2688 merged, which carried the closing keyword for that issue)
  - Updated frontmatter (`status: done`, `spec-path`, `related-pr: 2688`, `last-updated-utc`) and the last workflow checkpoint
  - Repaired every live reference to the old `docs/issues/open/2681-...` path: the #2482 EPIC row and Progress Log, the inventory destination table, the ADR's dated amendment note, the evidence and retrospective frontmatter, and the `related-artifacts` of the two PR review audits (#2682, #2688)
  - Pre-commit hooks passed

  This PR also carries the approved post-merge correction for PR #2688's finding F10 (an audit chronology note), per the maintainer's durable approval at <#2688 (comment)>: an append-only fix to `docs/pr-reviews/pr-2688-review/PR-REVIEW.md` only, no code change. The row stays `FOLLOW_UP`/`OPEN` in that audit; the GitHub thread is replied to and resolved once this PR merges.

ACKs for top commit:
  da2ce7:
    ACK 7642cf1 — verified the docs-only delta, chronology fixes, audit source mappings, local links and clean merge at this head
  josecelano:
    ACK 7642cf1

Tree-SHA512: ab973f0af54244b49d721db5c73039ee6d85067e60db9cb75d623c52aac46ee768e79ccbfb666515bcf87a72612ba41ae1e10700b9660f69b6e22a580823c271
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gate tracker-core's test modules and mocks (#2482 subissue 3)

3 participants