You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs(issues): [#3051] spec for the random expiring key duration overflow panic - #3054
Adds the issue specification for #3051: a random expiring authentication key with a seconds_valid that overflows the clock panics at key::generate_key instead of returning DurationOverflow. The spec records the maintainer's design decision (fix at the seam, with a dedicated key::DurationOverflow type), the plain-language explanation, the regression test strategy and the implementation plan.
docs/issues/open/3051-random-expiring-key-duration-overflow-panic/manual-verification-evidence.md (reproduction on a real tracker and at the unit seam)
docs/issues/open/3051-random-expiring-key-duration-overflow-panic/evidence/ (tracker configuration and panic log)
docs/pr-reviews/pr-3054-review/PR-REVIEW.md (the audit record of this pull request's reviews)
Validation
linter markdown and linter cspell pass. The reproduction commands and outputs are in the evidence file. No production code or test is changed in this PR; it also carries the review audit record; the temporary reproduction test is not included.
Summary by CodeRabbit
Documentation
Added an issue plan outlining scope, acceptance criteria, regression tests, and verification steps for a reported duration-overflow problem.
Added reproduction configuration and records of pre-fix manual and unit-test results; post-fix verification remains pending.
Added a review audit documenting findings, dispositions, and review progress.
These documentation changes do not implement fixes or alter application behavior.
Spec for the panic when a random expiring authentication key duration
overflows the clock, with the real-tracker and unit-seam reproduction.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
No actionable comments were generated in the recent review.
Walkthrough
The PR adds an issue specification for random expiring-key duration overflow, reproduction configuration and manual verification evidence, and an audit of PR review findings and processing.
Changes: Issue 3051 specification and evidence
Layer / File(s)
Summary
Overflow scope and proposed behavior docs/issues/open/3051-random-expiring-key-duration-overflow-panic/ISSUE.md
The issue document describes the reported panic, affected paths, proposed API and REST handling, scope boundaries, and API changes.
Regression and reproduction evidence docs/issues/open/3051-random-expiring-key-duration-overflow-panic/ISSUE.md, docs/issues/open/3051-random-expiring-key-duration-overflow-panic/evidence/tracker.repro.toml, docs/issues/open/3051-random-expiring-key-duration-overflow-panic/manual-verification-evidence.md
The issue document lists implementation and regression-test checkpoints. The evidence records the reproduction setup and pre-fix results; the post-fix recheck remains marked TODO.
PR 3054 review audit
Layer / File(s)
Summary
Review findings and recorded resolutions docs/pr-reviews/pr-3054-review/PR-REVIEW.md
The audit records findings F1–F18, their dispositions, and resolution references.
Review processing and completion rules docs/pr-reviews/pr-3054-review/PR-REVIEW.md
The audit records the processing timeline and rules for checking findings, updating threads, and documenting outcomes.
Merge Risk: Minimal · up to 367df · assessed changes only
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title uses the conventional commit form docs(issues): [#3051] spec for ... and names the main change: adding the planned specification for issue #3051, the random expiring key duration overflow …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title uses the conventional commit form docs(issues): [#3051] spec for ... and names the main change: adding the planned specification for issue #3051, the random expiring key duration overflow panic. The PR adds only documentation (issue spec, repro config, verification evidence, and review audit), and the title matches that scope. The title does not mention the verification evidence or the review audit, but it does not need to cover every detail.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.
…cope
Review finding: durations above i64::MAX seconds that fit the clock are
rejected by the stores with a 500. Different root cause, tracked in torrust#3055.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at ca1884a3816301a8e28201923f1a2b248f99a6d9. Recomputed from the bytes at this head, against the merge base 11c54fb48; git merge-tree against develop11c54fb48 merges without conflict, and the merged tree equals the head tree.
Process: a spec-only bug specification, governed by the create-issue and fix-bug skills and the issue and manual-verification-evidence templates; answering review threads follows process-pr-review. The required sections, frontmatter, classified reproduction and red-first regression task are present.
The change against its claim: four files under the issue folder, nothing outside it. The background holds: key/mod.rs:111 unwraps CurrentClock::now_add (unwrap at column 79); the pre-generated branch returns DurationOverflow (handler.rs:102-103); the adapter maps the generate-key error to Database (auth_key.rs:49); the quoted doc phrases and the timestamps recompute. ca1884a38 does what its subject says: the three stores convert the expiry with i64::try_from (auth_key_store.rs:49 in each driver), the failure reaches the client as a 500 without a panic, and #3055 is open. One claim does not hold: the generate-key endpoint cannot reach the 400 through the adapter alone (inline).
Consistency: every relative link, spec-path, issue-spec and related artifact resolves; the tables keep their column counts; no word needs the project dictionary.
Hygiene: two commits, 126e6e033 (docs(issues): add issue specification for #3051, the subject create-issue prescribes) and ca1884a38, each with author equal to committer and one attribution footer line (no rule in the tree on it); git diff --check is clean; the PR-branch commit-id check prints nothing; no closing keyword in the title, the description, the messages or the thread reply, and the description uses Related to #3051.
Findings: one Major (the generate-key 400 lies outside the planned scope), three Minor (one is the missing audit record), six Nits; all inline.
Checked, no finding: the head branch matches branch:; the frontmatter matches the validator's issue profile, and last-updated-utc now equals the newest log entry; the release profile does not abort on panic; the existing pre-generated u64::MAX test shows the test clock overflows, as the temporary test relies on; thread PRRT_kwDOGp2yqc6782Sb has a reply that names the fixing commit by its subject, and is resolved.
Checks
On the loop's compute node at this head, against the merge base 11c54fb48: the repository's pre-commit gate and lint roster exit 0 (2026-11-25). The PR changes documentation only, so no package tests apply. Checked against the bytes at posting: generate_auth_key_handler answers every generate_key error with failed_to_generate_key_response (packages/axum-rest-api-server/src/v1/context/auth_key/handlers.rs:80), which builds an unhandled-rejection 500 (responses.rs:29-31), while lines 97 to 99 of the spec say both REST paths yield "the existing 400 response", as the Major says. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (${{ matrix.package }}): completed/skipped; Package Coverage Regression: completed/success; Docker E2E: completed/skipped; Layer Boundary Bans: completed/success; Unit (nightly): completed/success; Workspace Packaging: completed/success; Shipped Features: completed/success; Unit (stable): in_progress/pending; Source Locations: completed/success; Documented Clippy Allows: completed/success; Test (Docker) (release): queued/pending; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on windows-latest (stable): completed/success; Build on macos-latest (nightly): queued/pending; Build on macos-latest (stable): completed/success; Docs Lint: completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: in_progress/pending; CodeRabbit: completed/neutral". At posting, develop is 9188c6e64.
… scope
Review round on PR torrust#3054: the deprecated generate-key endpoint answers 500
for every error, so the 400 needs a handler arm; list it in the scope, the
plan and the tests. Also fix the caller list, the test-design review
location, the completion-review conditions and the evidence wording.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Audit record for the claude[bot] and da2ce7 reviews of PR torrust#3054: one row per
finding, with the reply URLs and the commit subjects that fixed them.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at 2f123f2298b7a90e8700a5ee3528f56490ac65e7. Recomputed from the bytes at this head, against the merge base 11c54fb48; git merge-tree against develop9188c6e64 merges without conflict, and develop changed none of the paths this pull request touches or its spec cites.
Process: the spec follows create-issue and fix-bug; the replies and the audit record follow process-pr-review.
The change against its claim, since review 6059932482: e8a294f92 gives generate_auth_key_handler a DurationOverflow arm answering the existing 400, lists the handler, its doc comment and tests in scope, and narrows Out of Scope to responses clients get today; that holds, since the overflow panics before an error can reach the handler. It also fixes the caller list, the review location, the completion-review conditions, M1 and M3, the expiry-based bound and the evidence wording; the quote now matches the log byte for byte. 2f123f229 adds docs/pr-reviews/pr-3054-review/PR-REVIEW.md: eleven rows, one per thread, each with a matching source review ID and severity, a reply on its own thread and a resolution; the late start is logged and the log is in order.
Consistency: links and paths resolve; tables keep their column counts; no word needs the project dictionary.
Hygiene: four commits, each with author equal to committer and one attribution footer line (no rule in the tree on it); git diff --check is clean; the PR-branch commit-id check prints nothing; no closing keyword in the title, the description, the messages, the replies or the audit record.
Threads: all eleven have a reply, a row and a resolution. Approval is withheld only because the audit validator fails on one row (inline).
Findings: one Minor (the validator), two Nits; all inline.
Checked, no finding: the trial merge; last-updated-utc in both spec files equals the newest log entry; the record names the stale maintainer ACK and the scope widening it follows from.
Checks
On the loop's compute node at this head, against the merge base 11c54fb48: the repository's pre-commit gate and lint roster exit 0, and the audit validator reports failed with 11 rows, 5 log entries and 2 failures (2026-11-25). The PR changes documentation only, so no package tests apply. Checked against the bytes at posting: lines 74 and 76 of docs/pr-reviews/pr-3054-review/PR-REVIEW.md read Resolution reference: 4696525898 and Reply URL: <4696525898>, a bare comment id where a discussion URL is expected, which is where both validator failures come from. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Docker E2E: completed/skipped; Workspace Packaging: completed/success; Unit (stable): in_progress/pending; Layer Boundary Bans: completed/success; Documented Clippy Allows: completed/success; Unit (nightly): in_progress/pending; Shipped Features: completed/success; Source Locations: completed/success; Docs Lint: completed/success; Build on windows-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on macos-latest (stable): in_progress/pending; Build on ubuntu-latest (stable): completed/success; Build on macos-latest (nightly): completed/success; Test (Docker) (release): queued/pending; CodeRabbit: completed/neutral". At posting, develop is 9188c6e64.
…apture
Review 6060302201 on PR torrust#3054: plan the generate_auth_key_handler test and
the rename of the test that pinned 500 for every error, and show the
redirect that captured the tracker log.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.
…3054 audit
CodeRabbit finding F15: the audit cited the spec by its open/ path, which
goes stale when the issue closes.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at 1b5bdc379bea16bd63c94ef8309d55b0e36f2e86. Recomputed from the bytes at this head, against the merge base 11c54fb48; git merge-tree against develop9188c6e64 merges without conflict, and develop touches none of the files this pull request changes.
Process: the spec follows create-issue and fix-bug; the replies and the audit record follow process-pr-review.
The change against its claim, since review 6060302201: cfd5325d4 plans the generate_auth_key_handler test in T1, T2 and the red-run paragraph, plans the rename of the test that pinned 500 for every error in T3, and shows the > .tmp/tracker.log 2>&1 redirect behind the log extract. 1b5bdc379 gives the persistence-range row full discussion URLs, drops the verification line's claim of a validator result, and adds the rows and log entries for review 6060302201.
Consistency: links and paths resolve; tables keep their column counts; no word needs the project dictionary.
Hygiene: six commits, each with author equal to committer and one attribution footer line (no rule in the tree on it); git diff --check is clean; the PR-branch commit-id check prints nothing; no closing keyword in the title, the description (the appended automated summary included), the messages, the replies or the audit record.
Threads and audit: all fourteen threads have a reply, a row and a resolution; each row's source review ID, severity and reply match the thread, and the validator's logic, run over the record, reports 14 rows, 7 log entries and no failure.
Findings: one Minor and two Nits, inline; none blocks.
Checked, no finding: the trial merge; last-updated-utc in both spec files equals the newest log entry; the record says the maintainer ACK of an earlier head is stale.
Checks
On the loop's compute node at this head, against the merge base 11c54fb48: the repository's pre-commit gate and lint roster exit 0, and the audit validator reports ok with 14 rows, 7 log entries and 0 failures (2026-11-25). The PR changes documentation only, so no package tests apply. Checked against the bytes at posting: cfd5325d4 changes only ISSUE.md and manual-verification-evidence.md, and 1b5bdc379 is the only commit since 2f123f229 that touches docs/pr-reviews/pr-3054-review/PR-REVIEW.md, so the resolution reference at its line 220 names a commit without the fix. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (${{ matrix.package }}): completed/skipped; Test (Docker) (release): queued/pending; Discover Package Coverage: completed/success; Generate Coverage Report: in_progress/pending; Docs Lint: completed/success; Docker E2E: completed/skipped; Documented Clippy Allows: completed/success; Source Locations: completed/success; Unit (nightly): in_progress/pending; Shipped Features: completed/success; Layer Boundary Bans: completed/success; Unit (stable): in_progress/pending; Workspace Packaging: completed/success; Build on macos-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on macos-latest (nightly): completed/success; Build on windows-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; CodeRabbit: completed/success". At posting, develop is 9188c6e64.
ACK 1b5bdc3 — the spec scopes the generate-key handler arm and its tests, and the audit record carries a reply, a row and a resolution for all fourteen threads, with the validator's logic passing over it
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at 63e9f5076ac2ef979095656c8f5d305e2f276190. Since review 6060544492 at 1b5bdc379, the only change is 63e9f5076, which touches only docs/pr-reviews/pr-3054-review/PR-REVIEW.md: it cites the issue by number in the record's frontmatter instead of by its open/ path, and adds the row and log entry for the CodeRabbit comment that asked for it. The record still carries a reply, a row and a resolution for every thread opened before its last audit commit. The three non-blocking comments in review 6060544492 still apply and do not block.
Checks
On the loop's compute node at this head, against the merge base 11c54fb48: the repository's pre-commit gate and lint roster exit 0, and the audit validator reports ok with 15 rows, 9 log entries and 0 failures (2026-11-25). Checked against the bytes at posting: git diff --stat 1b5bdc379 63e9f5076 lists only docs/pr-reviews/pr-3054-review/PR-REVIEW.md. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (${{ matrix.package }}): completed/skipped; Package Coverage Regression: completed/success; Generate Coverage Report: in_progress/pending; Discover Package Coverage: completed/success; Test (Docker) (release): queued/pending; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (stable): completed/success; Build on macos-latest (stable): queued/pending; Build on windows-latest (nightly): completed/success; Build on macos-latest (nightly): queued/pending; Build on ubuntu-latest (nightly): completed/success; CodeRabbit: completed/success". At posting, develop is 9188c6e64.
Review 6060544492 on PR torrust#3054: the evidence showed the command with the
open/ path, but it ran with the drafts/ path.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Reviewed at 367dfdc7971ea80f13db2c4cea4a957a1ac64681. Recomputed from the bytes at this head, against the merge base 11c54fb48; git merge-tree against develop8f8202582 merges without conflict. develop touches none of this pull request's files; its edit to handler.rs changes one import in the peer_key_errors test module (from line 701), below every module and helper the evidence names, and key/mod.rs is unchanged.
The change against its claim, since review 6060679568: 4baa99569 shows the tracker start command with the drafts/ path it ran with and says where the folder lives now. 367dfdc79 points the validator-finding row at 1b5bdc379's subject, the commit that changed it, and adds the rows and log entries for review 6060544492, including the two duplicate replies the forge's errors left behind. The description's Files list now names the audit record.
Consistency: links and paths resolve; tables keep their column counts; no word needs the project dictionary.
Hygiene: nine commits, each with author equal to committer and one attribution footer line (no rule in the tree on it); git diff --check is clean; the PR-branch commit-id check prints nothing; no closing keyword in the title, the description, the messages, the replies or the audit record.
Threads and audit: all seventeen threads have a reply, a row and a resolution, and the body finding of review 6060493901 has its row; the validator's logic, run over the record, reports 18 rows, 13 log entries and no failure.
Findings: two Nits, inline; neither blocks.
Checked, no finding: the trial merge; last-updated-utc of the evidence file; the frontmatter citing "issue #3051"; each new row's source review ID, severity and first reply.
Checks
On the loop's compute node at this head, against the merge base 11c54fb48: the repository's pre-commit gate and lint roster exit 0, and the audit validator reports ok with 18 rows, 13 log entries and 0 failures (2026-11-25). The PR changes documentation only, so no package tests apply. Checked against the bytes at posting: line 317 of docs/pr-reviews/pr-3054-review/PR-REVIEW.md attributes the ACK of 15:31:12Z to the maintainer, and comment 7166969112, created at 15:31:12Z, is the one posted with review 6060544492. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (${{ matrix.package }}): completed/skipped; Package Coverage Regression: completed/success; Docs Lint: completed/success; Discover Package Coverage: completed/success; Generate Coverage Report: in_progress/pending; Docker E2E: completed/skipped; Layer Boundary Bans: completed/success; Unit (stable): in_progress/pending; Shipped Features: completed/success; Documented Clippy Allows: completed/success; Workspace Packaging: completed/success; Unit (nightly): in_progress/pending; Source Locations: completed/success; Test (Docker) (release): queued/pending; Build on macos-latest (stable): in_progress/pending; Build on windows-latest (stable): in_progress/pending; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Build on macos-latest (nightly): in_progress/pending; Build on ubuntu-latest (nightly): completed/success; CodeRabbit: completed/success". At posting, develop is 8f8202582.
- 2026-11-25 15:18 UTC - Wrote the rows F12 to F14 and fixed the F1 row. `validate-audit-record.py` was not run by this session (it calls plain `gh`); the reviewer's run reported the two failures that F12 fixes.
- 2026-11-25 15:28 UTC - Review 6060493901 (`coderabbitai[bot]`, `COMMENTED`, `submitted_at` 15:28:00Z) arrived on the head `docs(pr-reviews): [#3051] record review 6060302201 in the PR 3054 audit`: one finding in its body, F15 (no thread, so no reply).
- 2026-11-25 15:29 UTC - Fixed F15 in the commit `docs(pr-reviews): [#3051] cite issue 3051 by number in the PR 3054 audit`.
- 2026-11-25 15:31 UTC - Review 6060544492 (`da2ce7`, `submitted_at` 15:31:08Z, later dismissed) posted F16 to F18; the maintainer's `ACK` of 15:31:12Z named the head before the audit-only commit `docs(pr-reviews): [#3051] cite issue 3051 by number in the PR 3054 audit`.
The reason will be displayed to describe this comment to others. Learn more.
[Nit] This entry credits the maintainer with the ACK of 15:31:12Z, but comment 7166969112 is the reviewer's ACK, posted with review 6060544492. The maintainer's own ACK is comment 7167451569, of 63e9f5076, at 15:56:39Z. Both ACKs of 63e9f5076 are stale after 4baa99569 and 367dfdc79, and the last entry does not say the head needs new ones (merge-pull-requestSKILL.md:80-83, process-pr-reviewSKILL.md:127-130).
- Concern: The description's Files list names only the issue folder, but the pull request also adds the audit record.
- Solution: The description's Files list and Summary now name the audit record. The fix is outside the repository tree (the pull request description), so the reply URL is the durable reference.
The reason will be displayed to describe this comment to others. Learn more.
[Nit] The description's Summary is unchanged; the audit record is named in its Files list and its Validation paragraph. Reply 4697438606 says Summary too.
ACK 367dfdc — the evidence shows the start command as it ran, and the audit record carries a reply, a row and a resolution for all seventeen threads, with the validator's logic passing over it
The reason will be displayed to describe this comment to others. Learn more.
🟣 pre-existing, not blocking: pre-existing: Admins can still crash the request task after this plan ships, using durations that fit the clock and i64. The spec's Out of Scope bullet claims that range gets a 500 "with no panic". When the expiry is past chrono's maximum (about 8.2e12 s, year 262143) but ≤ i64::MAX, the store persists the key. peer_key_to_auth_key (auth_key.rs:90) then calls PeerKey::expiry_time, which panics. Fix: the DurationOverflow check must reject every expiry that expiry_time cannot represent, on the random, pre-generated and generate-key paths, or expiry_time must become fallible. The spec's "no panic" claim should also be corrected. A small fix can ride a push you are already making; otherwise a short reply is enough.
Why this was flagged
An admin sends POST /api/v1/keys with seconds_valid 10000000000000 (1e13), with or without a key, or POST /api/v1/key/10000000000000. now + d fits the u64 clock, so the planned key::DurationOverflow check passes. add_key_to_keys accepts it because the value fits i64 (sqlite/auth_key_store.rs:49). The adapter's peer_key_to_auth_key (rest-api-runtime-adapter auth_key.rs:90) then calls PeerKey::expiry_time (peer_key.rs:101-106), which calls torrust_clock::conv::convert_from_timestamp_to_datetime_utc. That function unwraps chrono's DateTime::from_timestamp, which returns None above roughly 8_210_266_876_799 s. The client gets an empty reply, like the panic this issue fixes, and a key it never received is left stored. The base already behaves this way. The spec's Out of Scope bullet (ISSUE.md:130-133) says the remaining range ends in a 500 "with no panic". The tests use only u64::MAX, so they would pass with this range still panicking.
Verification: Severity: pre-existing. The base code already panics the same way on the pre-generated-key path, and this PR changes only docs. At sqlite/auth_key_store.rs:49, i64::try_from(value.as_secs()) succeeds for about 1e13, so the key is persisted. At peer_key.rs:101-105, expiry_time returns a non-optional DateTime<Utc>, which cannot hold a timestamp of about 1e13 s.
…hitelist behavior
773fbc5 docs(pr-reviews): [#2902] record the replies to the second review round of #3056 (josecelano-bot)
df51dcc docs(pr-reviews): [#2902] record the first two review rounds of #3056 (josecelano-bot)
cac28a2 docs(issues): [#2902] keep the S4 log entry to its stamp and add the lessons register (josecelano-bot)
d4ad792 docs(issues): [#2902] re-measure S4 and correct its records after review (josecelano-bot)
daae1ab test(tracker-core): [#2902] pin the clearing of a key reset where it is owned (josecelano-bot)
0a4a512 docs(issues): [#2902] record the S4 measurement on the rebased branch (josecelano-bot)
014e4cc test(tracker-core): [#2902] adapt the key tests to keys counted in characters (josecelano-bot)
7b11ffa docs(issues): [#2902] record the S4 pull request (josecelano-bot)
9467765 docs(issues): [#2902] close slice S4 with its coverage measurement (josecelano-bot)
8269c6f test(tracker-core): [#2902] pin what the in-memory whitelist reports on add and remove (josecelano-bot)
97d78b3 test(tracker-core): [#2902] pin the failure and order behavior of the persisted whitelist and its manager (josecelano-bot)
f1cbb48 docs(issues): [#2902] record no change for the authentication repositories, service and module files (josecelano-bot)
16887d2 test(tracker-core): [#2902] pin the expiry boundary and the generated expiry of authentication keys (josecelano-bot)
ad59cc3 test(tracker-core): [#2902] pin the validation and the equality of authentication keys (josecelano-bot)
42c8b2a docs(issues): [#2902] correct the S3 remark on the aggregate line count (josecelano-bot)
b519bf1 test(tracker-core): [#2902] pin the failure and replace behavior of the keys handler (josecelano-bot)
Pull request description:
Related to #2902
Slice S4 of #2902: tests for the authentication and whitelist code of `packages/tracker-core`. No production code changes. Almost every file of the slice was already covered by line, so the slice was driven by mutation checks, not by uncovered lines: each plan lists the mutants it must kill, and each no-change decision is backed by mutants that were killed.
| Ledger rows | File | Decision |
| --- | --- | --- |
| 28 | `authentication/handler.rs` | 3 tests: a failed removal and a failed load leave the in-memory keys untouched, and a load replaces them |
| 29 | `authentication/key/peer_key.rs` | 19 tests: a key accept/reject table (none existed), one `quickcheck` property, a random-key test, a peer-key equality table (covers the one uncovered line). F3 checked: nothing deserializes a `Key` or `PeerKey` from untrusted input, so the unvalidated `Deserialize` derive is a latent hazard, recorded without change |
| 30 | `authentication/key/mod.rs` | 10 tests: the expiry boundary (a key still verifies at its exact expiry time; the mutant `<=` was killed by this case only), a property, the generated expiry; a misplaced existing test fixed (the permanent module displayed an expiring key) |
| 31-34 | key repositories, authentication service and module files | no change for rows 31, 33 and 34 after 15 mutants, all killed (two only by the row 28 tests); row 32 gains one assertion: the in-memory repository's own reset test now checks that a key missing from the new list is dropped, so the rule is pinned where it lives |
| 35-36 | `whitelist/repository/persisted.rs`, `whitelist/manager.rs` | 9 tests with a mocked store: a store failure is returned and stops later writes, the database is written before memory, a failed load leaves memory untouched and a load replaces it |
| 37-39 | `whitelist/authorization.rs`, `repository/in_memory.rs`, module files | row 38 was "no change" in the ledger, but two mutants (`add` and `remove` always returning `true`) survived every test, so 4 cases now pin the return values; rows 37 and 39 no change after 4 mutants, all killed |
**Two bugs found, handed to their own issues** (the maintainer's rule: bugs go first, one session per issue; this PR adds no test that would pin either behavior, and a regression test follows each fix):
- A random expiring key whose duration overflows the clock **panics** (`generate_key` unwraps `now_add`), while the pre-generated path returns `DurationOverflow`; reachable from the REST add-key and generate-key endpoints. Found while planning row 30; tracked as #3051 (finding F7), spec in #3054.
- Two concurrent adds of the same info-hash: one fails with `UNIQUE constraint failed` in 199 of 200 rounds on SQLite, although `add` is idempotent sequentially (finding F4). Found while planning rows 35-36; tracked as #3052, spec in #3053.
Coverage of `tracker-core` (stable Rust 1.100.0, `cargo-llvm-cov 0.9.1`, against the `develop` base `8f8202582`): unit-only lines 87.45% to 88.20% (349 unit tests, 304 on the base), aggregate 87.45% to 88.20%, each measured from a clean coverage target at the head and at the base. Most of the gained lines are the new test modules; the slice adds protection more than line coverage (see the slice measurements in `coverage-evidence.md`). The coverage-evidence remark of S3 about a ten-line aggregate difference is corrected: it was a counting artifact between builds.
**Rebase.** The branch was rebased on `develop` after #3042 (the secrets-redaction fix) merged: it changed `key/mod.rs`, made a key's display redacted, counted the key length in characters with a length-carrying error, and changed the key error texts. The row 30 conflict was resolved in its own commit (the permanent-display test now expects the redacted text, and my error-text table was dropped as a duplicate of the one now on `develop`); the key tests were adapted in a separate commit (`test(tracker-core): [#2902] adapt the key tests to keys counted in characters`), and the commits from the row 29 test up to that adaptation do not compile their test target; the history was not rewritten to hide the step. Every mutation set was run again on the rebased code and every mutant is killed; the slice was measured again, and once more after the first review.
Also in this PR: `quickcheck` (a dev-dependency added in S2) is used in two more files; the property of `peer_key.rs` carries a `clippy::needless_pass_by_value` expectation with its reason, because `quickcheck` passes generated arguments by value. The plan table of `test-refactor-plans/README.md` gains the rows of S3 (it was missing) and S4.
Validation: `cargo test -p torrust-tracker-core --all-features` (349 unit, 15 integration and 18 other tests), `cargo clippy -p torrust-tracker-core --all-targets --all-features`, `cargo +nightly fmt --all -- --check`, `cargo machete --with-metadata`, the pre-commit gate on each commit when it was made (the rebase replays commits without the hook, so the seven that do not compile their test target were checked before the rebase, and the commits added after it ran the gate) and the repository's pre-push checks on push. All mutants of the new tests and of the no-change files were run and killed; the plans have the tables.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Tests**
* Expanded coverage for authentication key validation, expiration behavior, and key-repository updates.
* Added checks for whitelist operations, persistence failures, and database loads, including whether in-memory data remains consistent when operations fail.
* Updated coverage for resetting stored keys.
* **Documentation**
* Added completed test plans, coverage results, and review records for authentication and whitelist areas. Also clarified how to compare coverage measurements across test sessions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
ACKs for top commit:
josecelano:
ACK 773fbc5
da2ce7:
ACK 773fbc5 — the tracker-core authentication and whitelist tests with their re-measured coverage records, and an audit record that answers every review thread with the validator passing
Tree-SHA512: 55f091ad29f5a23be3aad598c338de6cab47642f95dfb57edf048b70a68fb39a6edfed6a9a823ddf3fdf4c6d5644b2aec48dbdb34881f6001c89b9a021ccf0fd
… key duration overflows the clock
ff5ae2c test(tracker-core): [#3051] adapt the new key tests to generate_key returning a Result (josecelano-bot)
5c2100e docs(issues): [#3051] cite the fix commit by subject in the evidence (josecelano-bot)
085687e docs(issues): [#3051] record the green run and the real-tracker recheck (josecelano-bot)
0e44bc9 fix(tracker-core): [#3051] return an error when a random key duration overflows the clock (josecelano-bot)
75cde87 test(tracker-core): [#3051] add failing regression tests for the random key duration overflow (josecelano-bot)
Pull request description:
Closes#3051
## Summary
Creating a random expiring authentication key with a `seconds_valid` that overflows the clock no longer panics. `key::generate_key` returned the key and unwrapped the clock addition, so `POST /api/v1/keys` (random key) and `POST /api/v1/key/{seconds}` with `18446744073709551615` dropped the connection and logged a panic at `key/mod.rs:111`. They now answer `400` "invalid auth key duration", as the pre-generated key path already did. The design is the one the maintainer decided on the spec PR (#3054): fix at the seam, with a dedicated `key::DurationOverflow` type converted into `PeerKeyError::DurationOverflow`.
## Breaking public API change (`torrust-tracker-core`, allowed before 4.0.0)
- `authentication::key::generate_key(lifetime) -> Result<PeerKey, key::DurationOverflow>` (was `PeerKey`).
- `KeysHandler::generate_expiring_peer_key(lifetime) -> Result<PeerKey, PeerKeyError>` (was `Result<PeerKey, databases::error::Error>`); the `pub(crate)` `generate_permanent_peer_key` changes the same way.
- New `key::DurationOverflow { seconds_valid: u64 }` and `impl From<DurationOverflow> for PeerKeyError`.
All callers in the workspace are updated: `tracker-core`, `http-core` tests, the REST adapter, the REST handler and the persistence benchmark binary.
## Files
- `packages/tracker-core/src/authentication/key/mod.rs`, `handler.rs` and `error.rs`: the fix and its unit tests.
- `packages/rest-api-runtime-adapter/src/v1/adapters/auth_key.rs`: the generate-key adapter reuses `map_peer_key_error`.
- `packages/axum-rest-api-server/src/v1/context/auth_key/handlers.rs` and its contract tests: a `DurationOverflow` arm in `generate_auth_key_handler`; the existing test of the other errors is renamed.
- `packages/http-core` (tests) and `packages/persistence-benchmark`: callers.
- `docs/issues/open/3051-random-expiring-key-duration-overflow-panic/`: spec progress, `manual-verification-evidence.md` (red before the fix, green after, real-tracker recheck) and `test-design-review.md`.
## Validation
- The regression tests were committed first and failed for the bug (evidence V2b); they pass with the fix (V2c). The new `generate_key` unit test fails when the old `unwrap()` is restored.
- `linter all` exits `0`; the tests of `tracker-core`, `axum-rest-api-server`, `http-core`, `axum-http-server`, `rest-api-runtime-adapter` and `persistence-benchmark` pass, and so do the workspace doc tests.
- Real tracker recheck (V3): requests 2 and 4 answer `400` instead of an empty reply, the control answers `200`, and the log holds no panic.
- Not changed: an expiry above `i64::MAX` seconds that still fits the clock returns a `500` from the stores, tracked in #3055; `PeerKeyError` is not split or renamed.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Expiring-key requests with durations beyond the supported range now return a clear invalid-duration error instead of triggering a panic.
* This validation applies to both current and deprecated key-generation endpoints, including requests to add randomly generated keys.
* Permanent key generation remains unaffected.
* **Tests**
* Added regression coverage for duration overflow handling and API responses, including verification that the tracker records no panic.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
ACKs for top commit:
josecelano:
ACK ff5ae2c
Tree-SHA512: cc2e737d6d5eb0fb9ed4e5ea6db954d9ff8a0f205c89d6fc362a92c7e9e3e592917bcbcb1ef1770c0bf8a836e86a60c84acd2660d7a84c892b273a3416c09428
…ssues/closed
0ac4829 docs(pr-reviews): [#3051] record the replies to review 6079505913 in the PR 3072 audit (josecelano-bot)
70a3f89 docs(pr-reviews): [#3051] record review 6079505913 in the PR 3072 audit (josecelano-bot)
0196ad3 docs(pr-reviews): [#3051] record the replies to review 6078748782 in the PR 3072 audit (josecelano-bot)
828414b docs(pr-reviews): [#3051] record review 6078748782 in the PR 3072 audit (josecelano-bot)
4a84d47 docs(issues): [#3051] leave the remaining criteria for a reviewer to tick (josecelano-bot)
9a1b9aa docs(pr-reviews): [#3051] record the replies to review 6077711472 in the PR 3072 audit (josecelano-bot)
ac62b23 docs(pr-reviews): [#3051] record review 6077711472 in the PR 3072 audit (josecelano-bot)
157aff7 docs(issues): [#3051] leave the acceptance criteria for a reviewer to tick (josecelano-bot)
119ee6b docs(pr-reviews): [#3051] record the replies to review 6075748165 in the PR 3072 audit (josecelano-bot)
65f43b0 docs(pr-reviews): [#3051] add the PR 3072 review audit (josecelano-bot)
eb5671e docs(issues): [#3051] make the archived spec agree with its record (josecelano-bot)
6a6fbb9 chore(issues): archive closed issue #3051 spec to docs/issues/closed (josecelano-bot)
Pull request description:
Related to #3051
## Summary
Archives the spec of issue #3051, which is closed: its spec PR (#3054) and fix PR (#3064) are merged. The folder moves from `docs/issues/open/` to `docs/issues/closed/` as the `cleanup-completed-issues` skill describes. The ISSUE.md frontmatter now has `status: done`, the new `spec-path` and `related-pr: 3064`; the checkpoints the merged work satisfies are ticked and the progress log records the archival. The branch also carries the audit record of the reviews of this pull request.
## Files
- `docs/issues/closed/3051-random-expiring-key-duration-overflow-panic/` (moved from `open/`: `ISSUE.md`, `manual-verification-evidence.md`, `test-design-review.md`, `evidence/`).
- `docs/pr-reviews/pr-3072-review/PR-REVIEW.md` (the audit record of the reviews of this pull request).
## Validation
`linter markdown` and `linter cspell` pass, `git diff --cached --check` is clean, and a search for the folder name finds no live reference to the old path (the PR 3054 audit record keeps the path that existed at the time). No code is changed. The checkpoint "Reviewer validated acceptance criteria" is left unticked on purpose.
ACKs for top commit:
da2ce7:
ACK 0ac4829 — the #3051 spec archived to docs/issues/closed with its references repaired, and an audit record that answers every review finding and passes its validator
josecelano:
ACK 0ac4829
Tree-SHA512: a8367619601e0db1162b6b85c85d92535fd90bd10b26623abee55aee6f7cd71c2abffa2a701846d7769e9d4d0f9a3b035b8bb71c9fa1766cf01a2b43b3f8ba2c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #3051
Summary
Adds the issue specification for #3051: a random expiring authentication key with a
seconds_validthat overflows the clock panics atkey::generate_keyinstead of returningDurationOverflow. The spec records the maintainer's design decision (fix at the seam, with a dedicatedkey::DurationOverflowtype), the plain-language explanation, the regression test strategy and the implementation plan.Files
docs/issues/open/3051-random-expiring-key-duration-overflow-panic/ISSUE.mddocs/issues/open/3051-random-expiring-key-duration-overflow-panic/manual-verification-evidence.md(reproduction on a real tracker and at the unit seam)docs/issues/open/3051-random-expiring-key-duration-overflow-panic/evidence/(tracker configuration and panic log)docs/pr-reviews/pr-3054-review/PR-REVIEW.md(the audit record of this pull request's reviews)Validation
linter markdownandlinter cspellpass. The reproduction commands and outputs are in the evidence file. No production code or test is changed in this PR; it also carries the review audit record; the temporary reproduction test is not included.Summary by CodeRabbit