Repository navigation
feat(axum-http-server): [#2412] migrate the standalone HTTP environment and example to the token lifecycle - #2439
Conversation
Both affected packages pass before changes. The example's SIGTERM baseline differs from the spec's expectation: the legacy Halted path subscribes to SIGTERM inside the library, so only the server stops and a later Ctrl-C makes Environment::stop() panic (exit 101).
…ith an injected health check Make start_with_cancellation_and_health_check public so the HTTP test environment can use the token-aware lifecycle while keeping its injected health-check seam (needed by the HTTPS health-check contract test). Additive: the legacy Halted API is unchanged.
…ure options Joining the drain controller in the HTTP test environment exposed up to 1 s per stop with idle keep-alive connections. Accepted for now; the comment records how to remove it if it becomes a bottleneck.
…o the token lifecycle Environment now starts the HTTP server through the token-aware path with a fresh cancellation token per start, and stop() cancels it once and joins the server task, drain controller, and statistics event listener, reporting every failure after all three are joined. The listener is no longer aborted. The health-check API contract tests use Environment::stop() instead of the server field and no longer sleep for port release.
…SIGINT or SIGTERM The example's main is now the OS-signal boundary: it installs SIGINT and Unix SIGTERM handlers before announcing readiness, then calls Environment::stop(). Manual runs (announce, then SIGTERM or SIGINT) stop in order and exit 0; before, SIGTERM was caught inside the library and a later Ctrl-C panicked.
…nsumer The task inventory now records that the HTTP test environment and example use the token-aware lifecycle; the feature README status no longer says implementation has not started.
…opping the environment Covers the AC3 case not yet tested: a drain timeout is reported by name even when every owned task joins. Proven by ignoring TimedOut, which makes the test fail.
REVIEW FAILED on two documentation gaps; no code defects.
… findings Rename the first environment test to what it asserts, explain the causal yield in the server-failure test, scope the example's readiness comment to Unix, move its Unix signal import to the top, and drop the Future import already in the 2024 prelude.
…ings Record the prose-first AAA comparison for the environment tests, replace the evidence file's template placeholders with the automated tests, scope AC7 to direct signal subscriptions, and set the spec status to in-progress.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Drain timeouts can hang indefinitely, and failed startup can detach the statistics listener.
Review effort: Balanced
Findings: 2
Open (3)
What changed in this PR
Migrates the standalone HTTP test environment and example to the production token-aware shutdown lifecycle.
Changes:
- Adds token-aware environment startup, restart, and task joining.
- Moves example signal handling to
main. - Updates tests and shutdown documentation.
| File | Description |
|---|---|
packages/axum-server/src/signals.rs |
Documents drain polling cost. |
packages/axum-http-server/src/testing/environment.rs |
Implements token-aware environment lifecycle and tests. |
packages/axum-http-server/src/server.rs |
Exposes the injected-health-check startup path. |
packages/axum-http-server/examples/http_only_public_tracker.rs |
Handles SIGINT and Unix SIGTERM. |
packages/axum-http-server/Cargo.toml |
Enables Tokio time support for tests. |
packages/axum-health-check-api-server/tests/server/contract.rs |
Uses the environment shutdown API. |
docs/issues/open/2412-1488-si-16-migrate-standalone-http-environment/manual-verification-evidence.md |
Records verification evidence. |
docs/issues/open/2412-1488-si-16-migrate-standalone-http-environment/ISSUE.md |
Records implementation status and acceptance evidence. |
docs/issues/open/2412-1488-si-16-migrate-standalone-http-environment/agent-review-reports.md |
Adds independent review reports. |
docs/features/shutdown-process/task-inventory.md |
Updates the shutdown inventory. |
docs/features/shutdown-process/README.md |
Updates feature status. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…only after the server starts A failed server start used to detach the statistics listener: it was spawned first, and the panic dropped its handle while the task kept the only token clone. Subscribe before starting, so no event is missed, but spawn the listener only after a successful start. Addresses Copilot review on PR torrust#2439.
…en-aware drain times out graceful_shutdown_on_cancellation starts an unbounded graceful phase (graceful_shutdown(None)), so on TimedOut a connection held past the deadline kept the server task, and any caller joining it, waiting forever. Call handle.shutdown() at the deadline, matching the legacy path's bounded grace period. Covered by a test that holds a real connection open. Affects the HTTP, REST API, and health-check servers. Addresses Copilot review on PR torrust#2439.
…e Copilot fixes macOS is cfg(unix), so only the Windows CI build compiles the example's non-Unix branch. Addresses Copilot review on PR torrust#2439.
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at bb54338cbd0a26cef9d4fe3ce6fc4adeacc8043b (round 1). Recomputed from the bytes at this head, against develop at 050726d46.
Two earlier passes at previous heads were superseded by pushes before they could be posted; their analysis is re-derived here at this head.
Copilot's inline findings already use F1–F3 on this PR, so this review numbers its own findings from F4 (loop F<k> / Copilot F<k>).
What it is. 16 commits over the develop tip (the merge base), 12 files, +869/−140. The HTTP test Environment and the http_only_public_tracker example move to the token-aware lifecycle: private Stopped/Running states, a fresh token per start, and a stop() that cancels once and joins the server task, drain controller and statistics listener through join_owned_tasks. The last commit adds only the audit record.
Token-aware path and the drain. The graceful phase starts with graceful_shutdown(None) (signals.rs:25); at the deadline the helper calls handle.shutdown() before returning TimedOut (signals.rs:47-55), the effect the legacy path gets from graceful_shutdown(Some(90 s)) (signals.rs:77), so join_owned_tasks (environment.rs:255) ends after a timed-out drain. The helper is shared: HTTP and REST API pass 90 s (axum-http-server/src/server.rs:29, axum-rest-api-server/src/server.rs:53), the health-check API 5 s (axum-health-check-api-server/src/server.rs:37). In the tracker binary the 10 s shared deadline (src/main.rs:37) still pre-empts the 90 s budgets, so only the health-check API changes observably: a connection held past 5 s is now force-closed and the component reports its drain timeout (src/bootstrap/jobs/health_check_api.rs:75-85) instead of being aborted at 10 s (loop F9).
Environment start/stop. The receiver is taken before the fallible start and the listener spawned after it (environment.rs:106-128); a broadcast receiver buffers from subscription (bus.rs:64-65). One cancel then the joins; Launcher holds no socket (server.rs:74-78); a restart binds :0 afresh; the removed pub fields had one caller, migrated; tokio's time feature is a dev-dependency.
Example. On Unix both handlers are installed before Listening on; the non-Unix comment matches src/main.rs:51; Future comes from the 2024 prelude; exit 0 after stop(); no direct signal use under packages/axum-http-server/src (AC7).
Tests. The force-close test (signals.rs:216-247) runs on a paused clock that auto-advances to the 500 ms deadline while the held request's handler is pending; the server task then completes without further I/O, and without the force-close the 1 s timeout elapses instead. The listener-leak test (environment.rs:333-354) fails at bind (server.rs:423-424); with the container kept alive the old order leaves a second Arc holder (listener.rs:23), so strong_count == 1 is deterministic. Names match assertions. Attribute counts: axum-http-server 43 + 61, health-check 3 + 8, axum-server 6, REST API 6 + 58. The PR body's Validation still says five environment tests and 42 + 61.
Documents. The T4 entry is corrected in place with a dated marker quoting the old wording and an appended 15:53 entry, which meets "Append one line per meaningful update" (docs/templates/ISSUE.md:152). Each claim of the 15:53 entry matches the diff; the stamp 15:53 equals it. AC3 holds and the Risks line "the same bound as the legacy path" (ISSUE.md:350-352) is true.
Hygiene. 16 Conventional subjects; the fifteen product and spec commits carry [#2412]; the audit commit docs(pr-reviews): audit Copilot feedback on #2439 does not, which AGENTS.md:382 (PR titles only) does not require and which matches the 2437 record commit on develop. Times ascending; no attribution trailers; no banned token; Cargo.lock untouched.
Copilot's threads. All three are fixed, recorded in the audit record and resolved (isResolved true for each):
- Copilot F1 (comment 4185609715):
handle.shutdown()at the deadline (signals.rs:54), held-connection test atsignals.rs:217. The first-pass Major no longer stands. - Copilot F2 (comment 4185609583): subscribe first, spawn after the start (
environment.rs:106-128), test at:334. - Copilot F3 (comment 4185609794):
ISSUE.md:262and the PR body corrected.
Audit record (docs/pr-reviews/pr-2439-review/PR-REVIEW.md). It follows docs/templates/PR-REVIEW-TEMPLATE.md and the shape of the 2436 and 2437 records on develop. Rows keep Copilot's ids in the review's comment order (F2 created 15:16:04Z, F1 15:16:05Z, F3 15:16:06Z), as process-pr-review step 3 allows ("Use a reviewer-provided finding ID when present and it does not collide"), with matching detail entries in the same order. References are review-finding:pr-2439-f<n>. Severities equal the brackets; author class Copilot; categories correctness, correctness, documentation are concern-based readings step 4 permits. FIXED/RESOLVED match isResolved. Source review 5416744478, the three discussion_r source URLs and the three reply URLs pair up thread by thread; each resolution subject exists once on the branch. Reproduced at this head: the Windows/macOS grep matches only the correction note at ISSUE.md:262, and the stated test counts match the attributes. The Processing Log is chronological and append-only: the review was submitted at 15:16:06Z, before the 15:32 fetch; the fix commits were authored at 15:45:47Z and 15:52:33Z; the replies were posted at 16:07:10–14Z. The github-review-threads tool it names exists (contrib/dev-tools/github/github-review-threads). The badge sentence matches the review body's Medium severity/Low severity alt text. One clause of F2's Concern is inaccurate (loop F10).
Findings. None blocks. Still standing, inline: loop F4 Minor (evidence cites a pre-rebase commit id), F5 Nit (doc lists impossible errors), F6 Nit (example doc overclaims), F7 Suggestion (binding test lacks a targeted mutation), F8 Nit (startup awaits unbounded), F9 Minor (the shared-helper change is outside the spec's scope and completion review). New: loop F10 Nit (the record's F2 Concern says a registration failure left the listener uncancelled).
Checked, no finding. Audit structure, ids, references, order, severities, states, URLs and resolution subjects; log order and stamps; the named tool; the badge sentence; the audit commit's subject; production callers and budgets; the paused-clock and strong_count tests; the progress-log correction; AC3; commit hygiene.
Checks
On the loop's compute hub at this head, base develop 050726d46 (receipts server-gates-krkavec-55 and -56): pre-commit profile gate exit 0 (77 s), clippy-allow-reasons --base-ref 050726d46 exit 0, tree clean after the gate; linter markdown, linter cspell, linter lychee exit 0; cargo +stable test --all-targets --all-features for torrust-tracker-axum-http-server, torrust-tracker-axum-health-check-api-server and torrust-tracker-axum-server: 121 passed, 0 failed (26 s); for the two other users of the changed drain helper, torrust-tracker-axum-rest-api-server: 64 passed, 0 failed (35 s), and the root crate torrust-tracker: 162 passed, 0 failed (61 s); cargo +nightly clippy over the three HTTP packages with -D warnings: 0 diagnostics (9 s); the skill's validate-audit-record.py --pr-number 2439 over the live review comments at this head: 3 rows, 3 log entries, 0 failures. GitHub checks at this head at posting time: 3 completed skipped; 19 completed success.
|
ACK bb54338 — Copilot F1–F3 recomputed as fixed and resolved at this head, and the audit record checked field by field against the skill, the template and the live threads; remaining loop findings are non-blocking. |
… findings List only the errors the token-aware start methods can return, scope the example's no-signals sentence to the token-aware path it uses, and bound every environment start in the tests with the same deadline as stop. Addresses da2ce7 review on PR torrust#2439 (F5, F6, F8).
Record the shared drain-helper change as design decision D7 with its production effect, record which mutation proves the binding test, and name the V2/V3 tree by commit subject. Addresses da2ce7 review on PR torrust#2439 (F4, F7, F9).
|
Response to the da2ce7 review 5417753246 (round 2 on this PR), covering every finding:
All findings are recorded in |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 17f17864d1adec60202386e9d9902a18b5ae81b2 (round 2). Recomputed from the bytes at this head, against develop at 050726d46.
What changed. Two commits over the round-1 tip (5 files, +40/−14; 18 commits, 12 files, +896/−141 overall): "refactor(axum-http-server): [#2412] address da2ce7 review code findings" (F5, F6, F8) and "docs(issues): [#2412] address da2ce7 review spec findings" (F4, F7, F9). Both subjects are Conventional with [#2412], types fit (doc comments, an example doc and a test helper; spec and evidence text), author and committer times ascend, no attribution trailers, no banned token, Cargo.lock untouched. Everything else round 1 established is unchanged.
Code findings (fixed). F5: both token-aware starts now document Error::Bind, Error::Listener and Error::Registration only (server.rs:298-299, :380-381), the errors start_token_aware_runtime and the registration path can return. F6: http_only_public_tracker.rs:40 now says "The token-aware path it uses never listens for signals". F8: start_within_deadline (environment.rs:312-316) bounds every start in the tests (:327, :367, :380, and the restart at :383); the listener-leak test wraps its spawned start in timeout(TEST_DEADLINE, …) (:348-350): a start that hangs leaves a detached task until the test runtime drops, after the expect has already failed the test, which is acceptable.
Spec and evidence findings (fixed). F4: V2 names its tree by commit subject (manual-verification-evidence.md:109-111). F9: an In Scope bullet (ISSUE.md:111-112) and D7 (:158-169) state the change and its effect exactly: the 10 s deadline in src/main.rs still pre-empts the 90 s HTTP and REST API budgets, and only the health-check API's 5 s budget changes; the completion review cites the 12:48 and 17:40 entries (:382), and the 17:40 entry says why no retrospective is needed, as docs/templates/ISSUE.md:144 asks. The template has no Design Decisions section, so "Added during PR #2439 review" is unconstrained. F7: the mutation I suggested (a stop() that skips the server task) was wrong. The 17:40 entry reports that it survives, because cancellation alone makes axum stop accepting and drop the listening socket. The T2 row (:214) instead names "a stop() that never stops the server", which fails at the test's own bind with AddrInUse. With no cancellation the server keeps its socket, so that mutation does target binding release; the entry records the outcome of the run.
F10 (not addressed). The diff does not touch the audit record: PR-REVIEW.md:64-66 still says a registration failure left the listener uncancelled. Yet the 17:40 entry says "F10: corrected in the PR #2439 audit record" (loop F11).
Record and threads. process-pr-review makes the record the author's ("The PR author owns one tracked audit record … Reviewers … deliver findings through GitHub only", :19-21) and lets fixes land before it ("Update the audit progressively and commit it separately from product fixes", :101-102). Before merge it requires every finding recorded (steps 3-5), a reply before resolution ("reply with the disposition, current-tree verification, and resolution reference, then use resolve-review-threads to resolve it", :85-89), the validator green and "no unresolved actionable thread" (:98-102, checklist :286-292). Still owed: rows F4–F11 citing review 5417753246, each discussion_r source URL (4186389282 … 4186389342) and its reply URL; F10's Concern narrowed; seven replies (eight with F11); resolution. The validator checks only the rows that exist (validate-audit-record.py:192-199), so a green run at this head does not show the record is complete. Ruling: by themselves the owed steps would not block, since they are the author's pre-merge workflow; this round requests changes for loop F11 alone, and one record commit that corrects F10 resolves both.
Findings. Loop F11 Minor, blocking (inline): a progress-log claim that is false at this head. Loop F10 Nit still open. F4–F9 fixed.
Checked, no finding. The two subjects and types; the # Errors text against the error paths; every test start and the timeout over the spawned start; D7's production effect against src/main.rs:37 and the 90 s/90 s/5 s budgets; the In Scope bullet; the completion review against the template; the 17:40 stamp (between the two commits' author times 17:39:48Z and 17:52:42Z); the evidence's named subject; the T2 row's mutation.
Checks
On the loop's compute hub at this head, base develop 050726d46 (receipt server-gates-krkavec-57): pre-commit profile gate exit 0 (80 s), clippy-allow-reasons --base-ref 050726d46 exit 0, tree clean after the gate; linter markdown, linter cspell, linter lychee exit 0; cargo +stable test --all-targets --all-features: the three HTTP packages 121 passed (28 s), torrust-tracker-axum-rest-api-server 64 passed (21 s), the root crate 162 passed (44 s), 0 failed; cargo +nightly clippy over the three HTTP packages with -D warnings: 0 diagnostics (12 s); validate-audit-record.py --pr-number 2439 over the live comments: 3 rows, 3 log entries, 0 failures (it validates only the rows the record has). GitHub checks at this head at posting time: 1 completed skipped; 14 completed success; 3 in_progress null. At posting time the author had replied on all seven round-1 threads (18:02 UTC), each citing its fix commit and audit id; the F10 reply names a record commit that is not at this head, which is the F11 case above. The replies do not change the ruling; the record commit will.
Add findings F4-F11 from review 5417753246 and narrow F2's concern to bind and listener-setup failures (F10).
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at e27c0f29c5b2a9091812272ec42029c230cdc977 (round 3). Recomputed from the bytes at this head, against develop at 050726d46.
Loop findings continue from F13: F12 is left for the record's entry of round-2 F11, which process-pr-review step 3 moves to the next audit id because the record's own F11 now holds that id.
What changed. One commit over the round-2 tip, "docs(pr-reviews): record da2ce7 review on #2439" (docs/pr-reviews/pr-2439-review/PR-REVIEW.md only, +155/−2; 19 commits, 12 files, +1049/−141 overall). As in round 1, the record subject carries no [#2412], which AGENTS.md:382 (PR titles) does not require. Author and committer times are equal and ascending, there are no attribution trailers or banned token, and Cargo.lock is untouched. The PR body's new Validation counts (1 + 6 + 1 new tests; 43 + 61, 3 + 8, 6, 6 + 58) match the test attributes; "pre-push passed on every push" cannot be checked from the bytes.
The record's round-2 section.
- Rows F4–F10 keep the review's own tags (step 3, no collision, so
Reviewer finding ID: N/A). - Author class
Human; severities equal the posted brackets; categoriesdocumentation/testingare concern-based (step 4). - Source review 5417753246 with its seven
discussion_rURLs; the seven 18:02Z replies pair thread by thread (4187152197 … 4187153859); each resolution subject exists once on the branch. - Reproduced: F4's grep for the pre-rebase id over the evidence finds 0 hits; F8's
grep '\.start()'finds exactly three (productionEnvironment::newatenvironment.rs:146and the bounded calls at:313and:348); F7 matches the spec's 17:40 entry and T2 row; F9's three paths carry the 5 s budget, the component error and the 10 s deadline; F2's Concern is narrowed (:76-80). - Rounds are numbered by review order (Copilot first); no rule numbers rounds.
RESOLVED×7 while the threads are unresolved is the sanctioned forward state, not a false one. The template gives an in-PR fixed finding no other value (OPEN"applies prospectively to audits created or updated for approved follow-up work"), and the skill runs the validator "before every audit commit and before replying to or resolving any thread" (SKILL.md:206-207), so the record precedes resolution. Step 9's final fetch makes it true.
F11 collision. The record's F11 (the review body's stale-count remark) may be a row: step 2 excludes only "a summary or verdict that contains no request", and this asserted a defect the author then fixed. NON_RESOLVABLE with the review URL as source is the template's form for a body finding (PR-REVIEW-TEMPLATE.md:55-56). Round-2 review 5418725511 reuses F11 for a different finding, and references never change once assigned (SKILL.md:190-191). Step 3 therefore applies: "When a later review reuses an existing ID for a different finding, assign the next audit-local F<ordinal> and record the reviewer's original ID in the detail entry." Record it as F12, with Reviewer finding ID: F11.
Round-2 findings. Loop F11 is fixed: the 17:40 spec entry's "F10: corrected in the PR #2439 audit record" is now true. Loop F10 is fixed by the narrowed Concern.
Owed before merge.
- An F12 row for round-2 F11 (source review 5418725511,
#discussion_r4187209512,Reviewer finding ID: F11). - A reply on thread 4187209512.
- Resolution of all eight loop threads.
- A Processing Log entry for review 5418725511 (submitted 18:08:46Z, after the last entry: unlogged, not false).
- A green validator and a final fetch. The validator checks only the rows that exist, so it cannot show the F12 row is missing.
Findings. Loop F13 Minor, blocking (inline): the record's 17:40 Processing Log entry is stamped before two of the events it records.
Checked, no finding. Rows F4–F11 field by field; the reproducible verifications; the round-numbering label; the F11 row's form and its comment-URL resolution (no commit exists for a PR-description edit; the validator skips URLs); the 18:03 entry (replies 18:02:17–28Z; consolidated response 18:03:56Z); the narrowed F2 Concern; the record subject; commit hygiene.
Checks
On the loop's compute hub at this head, base develop 050726d46 (receipt server-gates-krkavec-59): pre-commit profile gate exit 0 (82 s), clippy-allow-reasons --base-ref 050726d46 exit 0, tree clean after the gate; linter markdown, linter cspell, linter lychee exit 0; cargo +stable test --all-targets --all-features: the three HTTP packages 121 passed (29 s), torrust-tracker-axum-rest-api-server 64 passed (20 s), the root crate 162 passed (44 s), 0 failed; cargo +nightly clippy over the three HTTP packages with -D warnings: 0 diagnostics (11 s); validate-audit-record.py --pr-number 2439 over the live comments: 11 rows, 5 log entries, 0 failures. GitHub checks at this head at posting time: 1 completed skipped; 13 completed success; 3 in_progress null; 1 queued null.
Append a correction with the actual commit and push times, and record da2ce7 round-4 finding F13.
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 02d8040fc8bd6aee240727f298dbfe82b9781caf (round 4). Recomputed from the bytes at this head, against develop at 050726d46.
A pass at the previous tip was superseded by the push before it could be posted.
What changed. One commit, "docs(pr-reviews): correct the 17:40 audit log entry on #2439" (docs/pr-reviews/pr-2439-review/PR-REVIEW.md only, +24; 21 commits, 12 files, +1098/−141 overall), authored at 18:45:21Z. Code, spec, evidence and PR body are unchanged since the round-2 tip.
Loop F13: fixed. The 17:40 entry is untouched, and the appended 18:42 entry names it as a correction with the actual times. That is the template's append-only form (docs/templates/PR-REVIEW-TEMPLATE.md:110-111: "Append entries only. If an entry was rewritten in place, restore the prior entries, then append a correction that names the rewritten content"). Its times match the bytes:
- code-fix commit authored 17:39:48Z;
- spec-fix commit authored 17:52:42Z;
- push at 17:58:46Z, from
review_dismissedwith the round-2 tip asdismissal_commit_id.
The 18:42 stamp falls in the reply's minute (18:42:45Z) and before the carrying commit (18:45:21Z).
The F13 row and entry.
Human/Minor match the posted bracket.metadatais a step-4 category that fits a log-stamp defect.Reviewer finding ID: N/Ais right, since F13 was free.- Source review 5418876195,
#discussion_r4187339307, and Reply URL#discussion_r4187505083(18:42:45Z, on that thread) pair up. - The resolution subject exists once on the branch.
RESOLVEDis now true.- The intro's "its body confirms the F12 handling and adds no other assertion" is fair to the posted round-3 body. That body prescribed exactly this F12 handling, and its owed list restated the skill's steps.
The record as a whole.
- 13 rows: Copilot's review 5416744478 (F1–F3) and each of this account's posted reviews, 5417753246 (F4–F11), 5418725511 (F12) and 5418876195 (F13).
- Every finding has a matching detail entry with its reply URL.
- All twelve threads are resolved; F11 is
NON_RESOLVABLEby design. - The Processing Log is chronological (15:32 → 18:42) and covers every review up to the last one.
- The record is complete for every review posted so far. The in-repo validator, run offline at this head with the captured comments, reports 13 rows, 7 log entries and 0 failures.
Substance (unchanged). The token-aware environment migration, the shared drain helper's force-close with D7 stating its production effect, the example's signal boundary, the bounded tests and the documents stand as reviewed in rounds 1–3. The new subject has no [#2412] tag, which the round-1 ruling allows. Author and committer times ascend, there are no attribution trailers or banned token, and Cargo.lock is untouched.
Findings. None. Loop F4–F13 are fixed and recorded.
Checked, no finding. The correction's form and times; the F13 row and entry; reply pairing; thread states; log order and completeness; the offline validator; commit hygiene.
Checks
On the loop's compute hub at this head, base develop 050726d46 (receipt server-gates-krkavec-66): pre-commit profile gate exit 0 (229 s), clippy-allow-reasons --base-ref 050726d46 exit 0, tree clean after the gate; linter markdown, linter cspell, linter lychee exit 0; cargo +stable test --all-targets --all-features: the three HTTP packages 121 passed (29 s), torrust-tracker-axum-rest-api-server 64 passed (21 s), the root crate 162 passed, 0 failed; cargo +nightly clippy over the three HTTP packages with -D warnings: 0 diagnostics (12 s); validate-audit-record.py --pr-number 2439 over the live review comments at this head: 13 rows, 7 log entries, 0 failures. GitHub checks at this head at posting time: 1 completed skipped; 8 completed success; 8 in_progress null; 1 queued null.
|
ACK 02d8040 — loop F13 recomputed as fixed by an appended correction with times matching the commit log and the dismissal event, and the audit record checked complete for every posted review (13 rows, every thread resolved, the offline validator clean). |
|
ACK 02d8040 |
…eric conversion allowances b2f1a60 docs(pr-reviews): [#2246] record round-2 findings F6 and F7 on #2440 (Jose Celano) 3b4c7d0 docs(issues): [#2246] log the PR #2440 review-round update in the spec (Jose Celano) bba29c3 docs(pr-reviews): [#2246] audit round-1 review findings on #2440 (Jose Celano) 5040e97 docs(issues): [#2246] name the reverse conversion in the A123 inventory row (Jose Celano) 27aa557 docs(issues): [#2246] embed M1 config and verbatim output in evidence (Jose Celano) e1ba802 docs(issues): [#2246] stamp evidence update time to the minute (Jose Celano) 42ef8ac docs(issues): [#2246] distinguish preserved and changed conversion behaviour (Jose Celano) afb0808 test(torrent-repository-benchmarking): [#2246] cover the checked peer-count boundary (Jose Celano) df4b11a docs(issues): [#2246] cite commit subject instead of branch commit id (Jose Celano) bf5c725 docs(issues): [#2246] record manual verification and completion review (Jose Celano) fb60489 docs(issues): [#2246] reconcile domain conversion outcomes in #2158 inventory (Jose Celano) 7daa60a refactor(torrent-repository-benchmarking): [#2246] check swarm count conversions (Jose Celano) 4afa5b8 fix(primitives): [#2246] reject peer timestamps beyond u64 milliseconds (Jose Celano) 0ff0a7e refactor(tracker-core): [#2246] remove numwant cast_sign_loss allowance (Jose Celano) d25cc58 docs(issues): [#2246] record approved domain conversion review outcomes (Jose Celano) Pull request description: ## Summary Resolves the three domain numeric-conversion Clippy suppressions owned by #2246 (child of EPIC #2243). Each was reviewed against its source/target bounds, and all three allowances are removed. | Entry | Package | Change | | ----- | ------- | ------ | | A129 | `tracker-core` | `PeersWanted::from_client_request` passes the guarded positive value through `Self::only(value.unsigned_abs())`. The `u32` type carries the non-negative invariant, so no `cast_sign_loss` allowance is needed. Behaviour is unchanged and the function stays `const`. | | A099 | `primitives` | `ser_unix_time_value` converts `Duration::as_millis()` with `u64::try_from` and returns a serde error when the value does not fit, instead of silently truncating it. | | A123 | `torrent-repository-benchmarking` | `EntrySingle::get_swarm_metadata` converts seeder/leecher counts through a `peer_count_as_u32` helper using `u32::try_from(..).expect(..)`, mirroring the reverse (`u32 → usize`) conversion in the production `Coordinator::seeders_and_leechers`. | Only A129 preserves behaviour for every input. A099 and A123 change behaviour for out-of-range values only: where the old casts silently truncated or wrapped, they now fail explicitly. A099 returns a serde error for a timestamp that does not fit in `u64` milliseconds (about 584 million years). A123 panics for a peer count above `u32::MAX`, which can only happen on 64-bit targets. Neither value is reachable in production: peer timestamps come from the clock, and A123 is in a benchmarking-only crate. ## Documentation - The #2246 spec records the approved review outcomes and the verification evidence. Its frontmatter is migrated to v1, as required by the frontmatter validator. - The A099, A123, and A129 rows of the #2158 inventory (an already-archived issue) are marked as removed by #2246, following the #2261 precedent. - The EPIC #2243 subissue table marks #2246 as in progress. - Manual scenario M2 (REST API timestamp) was replaced with a note: the REST API peer resource computes its own `u128` timestamps and never calls `ser_unix_time_value`, so M2 could not exercise the change. - Review findings are tracked in `docs/pr-reviews/pr-2440-review/PR-REVIEW.md`. ## Validation - New `unix_time_value_serialization` tests cover a normal timestamp, `u64::MAX` milliseconds, and the first value beyond it. The out-of-range test failed against the old cast before the fix. - New `peer_count_as_u32` tests cover `u32::MAX` and, on 64-bit targets, `u32::MAX + 1` (panics). The panic test fails against a wrapping cast. - Existing `from_client_request` boundary tests (-1, 0, max-1, max, max+1) pass. - Manual scenario M1: a local UDP tracker with `max_peers_per_announce = 2` and four other peers returned 2, 2, 1, 2, 2, and 2 peers for `numwant` 0, -1, 1, 2, 3, and `i32::MAX`. The evidence file in the issue folder embeds the configuration and the verbatim output. - Pre-commit (`linter all`, `cargo machete`, doc tests) and pre-push (nightly fmt/check/doc and the full test suite) pass. Closes #2246 ACKs for top commit: da2ce7: ACK b2f1a60 — round-3 tip rebased onto 29afe94 with all fifteen commits content-equal, no file overlap or broken citation against the merged #2439, audit record byte-identical with all six threads resolved josecelano: ACK b2f1a60 Tree-SHA512: bb39d1947598cae6b27ac34b8576110aa265dd91d0a5e7b49bf1fb34b6814eb14d79557f7a09eca3a794bdb509627448d806e8064f91f4be45a1520002ca15c3
455a370 docs(pr-reviews): record Copilot review on #2443 (Jose Celano) c314e50 docs(issues): refresh SI-16 evidence last-updated-utc after archive (Jose Celano) 541c575 docs(issues): refresh SI-22 EPIC last-updated-utc after link update (Jose Celano) ecbb347 docs(issues): refresh SI-3 draft last-updated-utc after link update (Jose Celano) 74d2bed chore(issues): archive closed issue #2412 spec (Jose Celano) Pull request description: Related to #2412 (closed by #2439) and EPIC #1488. Archives the SI-16 spec after #2439 merged: - Moves `docs/issues/open/2412-1488-si-16-migrate-standalone-http-environment/` to `docs/issues/closed/`. - Spec: `status: done`, `related-pr: 2439`, last checkpoint ticked, closing progress-log entry. - EPIC #1488: roadmap row 12 marked Done; finding 2 now says only the UDP test environment uses `Halted` until SI-17. - Updates links to the old path (SI-3 draft, SI-22 EPIC, PR #2439 audit record, the spec's own frontmatter). Not changed: the PR #2421 audit record mentions the old path as historical verification text. Docs-only; `linter all` passes. ACKs for top commit: josecelano: ACK 455a370 Tree-SHA512: 3be544fe9ae6417fb0413c15f41f3b8b55858c2a9451961a45669f218f91a236d6b280e97a0752f2e0ad36cf22b1ff794ec9234f7b5d8ee00b53064f01f8fab6
…ironment and example to the token lifecycle 888b83b docs(pr-reviews): record da2ce7 rounds 2-4 on #2459 (Jose Celano) 5258a94 docs(pr-reviews): restore the template status and completion blocks in the #2459 record (Jose Celano) 7b7e8c2 docs(pr-reviews): record Copilot and da2ce7 reviews on #2459 (Jose Celano) cd2dcb7 docs(issues): [#2448] mark SI-17 verification done and log the PR review (Jose Celano) 6f70536 docs(issues): [#2448] name reviewed commits by subject in the SI-17 review report (Jose Celano) d31a549 fix(udp-server): [#2448] cancel the UDP environment's tasks when it is dropped without stop() (Jose Celano) be43f31 docs(issues): [#2448] record the Task Reviewer report for SI-17 (Jose Celano) 8a1c1a6 test(udp-server): [#2448] tighten environment test assertions after review (Jose Celano) b0c2d96 docs(issues): [#2448] record SI-17 acceptance review and verification (Jose Celano) 0137612 docs(shutdown): [#2448] record the migrated UDP environment in the task inventory (Jose Celano) 525296f feat(udp-server): [#2448] stop the UDP example on SIGINT or SIGTERM (Jose Celano) 8e2b59c refactor(udp-server): [#2448] migrate the UDP test environment to the token lifecycle (Jose Celano) Pull request description: Closes #2448. Part of EPIC #1488 (SI-17). The UDP counterpart of SI-16 (#2412, PR #2439). ## Changes - **UDP test environment** (`packages/udp-server/src/testing/environment.rs`): starts the server through `Server::start_with_cancellation` with a fresh token per start. The three event receivers are taken before the start, and the listeners are spawned only after it succeeds, so a failed start leaves no detached listener. `stop()` cancels once and joins the receive loop and the three listeners, reporting every failure after all four join; it no longer aborts listeners and has no outer timeout (the receive-loop drain is already bounded). The running state is private, behind the existing `Started`/`Unstarted` aliases. - **Health-check API contract test**: stops the UDP environment with `Environment::stop()` instead of the removed `server` field. - **`udp_only_public_tracker` example**: installs SIGINT and Unix SIGTERM handlers in `main` before printing readiness (Ctrl-C on non-Unix), then calls `Environment::stop()`. - **Task inventory**: findings 4 and 8 record the migrated UDP consumer; the REST API and health-check API test environments (SI-23, SI-24) are the remaining legacy users. - Spec progress, evidence, and the Task Reviewer report under `docs/issues/open/2448-1488-si-17-migrate-standalone-udp-environment/`. ## Behavior change Before: SIGINT made the example panic (exit 101); SIGTERM stopped only the server and left the process running. After: both signals stop it in order, exit 0, and release the socket (evidence V1-V3). ## Tests Five new environment tests replace the sleep-based `it_should_make_and_stop_udp_server`; each was proven by a mutation that makes it fail (aborted listener, listener spawned before the start, pre-cancelled token, early return before joining, `stop()` that does not await the receive loop). Unlike HTTP, the UDP socket is freed only when the receive-loop task ends, so the socket test also guards the await. ## Validation - `cargo test -p torrust-tracker-udp-server`: 216 unit + 12 integration + 1 doc - `cargo test -p torrust-tracker-axum-health-check-api-server`: 3 + 8 - `linter all`, pre-commit, and pre-push checks pass (nightly `rustc 1.101.0-nightly (ea137335b 2026-10-05)`, stable `rustc 1.99.0`) - Manual scenarios M1-M4 in `manual-verification-evidence.md` - Task Reviewer: REVIEW PASSED; findings handled in the spec's progress log ACKs for top commit: da2ce7: ACK 888b83b — the drop guard and the F1/F2 fixes verified in round 2 stand, the audit record verified in rounds 3-4 now carries the rounds 2-4 rows and log entry true to the review capture, and the branch is a clean rebase onto 4603852 josecelano: ACK 888b83b Tree-SHA512: d1291bfc35be9af9a7a19d15aedc639481adee49b8c31126d8699ba07ee03919a5f24dbb747dadd8c7619804ded897284554055f959f394b6777087b29e30ff8
…SI-23 and SI-24 specs 0f5270e docs(pr-reviews): add the PR #2483 review audit (Jose Celano) d9f8b54 docs(issues): refresh the SI-18 and SI-19 update timestamps (Jose Celano) 0d7cf4d docs(issues): describe the SI-23 and SI-24 drop path as cancellation only (Jose Celano) 26e259f docs(issues): restore the #2471 post-green design-review checkpoint (Jose Celano) ce3ac3d docs(issues): record the #2471 reproduction's symptom and hypothesis (Jose Celano) 2801ab2 docs(issues): record D20, independent test-environment tokens (Jose Celano) d0cf7bd docs(issues): require the drop path in SI-23 and SI-24 (Jose Celano) 00c8a9b docs(issues): refresh SI-22 specs with lessons from SI-17 (Jose Celano) 4f456ef docs(issues): add #2471 to the shutdown EPIC roadmap (Jose Celano) e2a0b1e docs(issues): add issue specification for #2471 (Jose Celano) Pull request description: Related to #2471 Spec-only PR. It adds the specification for #2471 and refreshes the SI-22, SI-23 and SI-24 specs with lessons from SI-17 (#2448, #2459) and the recent archive PRs (#2457, #2465). No code changes. ## Summary - **#2471 spec (new):** dropping the HTTP test environment without `stop()` leaves its server running and its port bound. It's a regression from SI-16 (#2439); the UDP environment got the fix in #2459. The bug was reproduced on `develop` with a temporary test, which is recorded in `manual-verification-evidence.md` and was not committed. The fix is a `DropGuard`, as in the UDP environment, and comes in its own PR. - **EPIC #1488 roadmap:** #2471 is inserted as sequence 14, before SI-22, because SI-22 T9 changes the same file. The later rows and the "EPIC position" lines in the SI-22, SI-23, SI-24, SI-18 and SI-19 specs are renumbered. - **SI-22 (#2410, #2413, #2416):** - T9 keeps SI-17's join-all failure reporting, cancels both tokens on drop, and adds the late-event test for UDP as well as HTTP. T9 now waits for #2471. - New decision D20: the test environments use independent server and listener tokens, each with its own `DropGuard`, mirroring `JobManager`'s per-component tokens. The parent-child token option is rejected. - T1 records the test environments' listener chains. - T2a finds links to the moved jobs doc with `rg`, because `lychee.toml` skips `docs/issues/closed/`. Historical records keep the old path (maintainer decision). - T2b adds the `DropGuard` rule to the glossary. - Stale state is updated: spec-only PR #2421 merged, SI-16 and SI-17 done, #2413's branch and parent line. - **SI-23 (#2449) and SI-24 (#2450):** "Drop path: unchanged" was wrong, because moving from the halt sender to a token loses the stop-on-drop behavior, as happened in SI-16. Both specs now require a `DropGuard`, a T1 drop test, and AC7. ## Files Only `docs/issues/`: - `docs/issues/open/2471-1488-fix-http-environment-drop-path/` (new: `ISSUE.md`, `manual-verification-evidence.md`) - `docs/issues/open/1488-overhaul-tracker-shutdown/ISSUE.md` - `docs/issues/open/2410-1488-si-22-process-queued-events-before-listeners-stop/EPIC.md` - `docs/issues/open/2413-2410-si-22-1-document-event-flows-and-draft-adr/ISSUE.md` - `docs/issues/open/2416-2410-si-22-4-stop-producers-before-listeners/ISSUE.md` - `docs/issues/open/2449-1488-si-23-migrate-rest-api-test-environment/ISSUE.md` - `docs/issues/open/2450-1488-si-24-migrate-health-check-api-test-environment/ISSUE.md` - `docs/issues/drafts/1488-si-18-deprecate-legacy-shutdown-api/ISSUE.md` and `docs/issues/drafts/1488-si-19-remove-legacy-shutdown-api/ISSUE.md` (roadmap position only) ## Validation - Pre-commit checks pass for every commit (`linter all`, frontmatter validation, `cargo machete`, doc tests). - Pre-push checks pass (nightly fmt, check and docs; stable test suite). - #2471 is linked as a sub-issue of #1488. ACKs for top commit: josecelano: ACK 0f5270e Tree-SHA512: 59b4bfc4b07c9fc30c44c778f5638c52e2ec85499df0251eaacf0372f653aa0e3c9a470cd1b5ee22046a29afd7678b3da4d29d6c104b3b30daf8b4035d1fb5fa


Summary
Implements SI-16 of EPIC #1488: the HTTP test
Environmentand thehttp_only_public_trackerexample now use the token-aware HTTP server lifecycle, the same shutdown path the tracker runs in production.Closes #2412
Changes
HttpServer::start_with_cancellation_and_health_checkis now public (additive), so the environment keeps its injected health-check seam on the token-aware path. Unit test proves the registry runs the injected callback.Environment(packages/axum-http-server/src/testing/environment.rs):Stopped/Runningstates withUnstarted/Startedaliases (as in the UDP environment);stop()cancels once and joins the server task, drain controller, and statistics event listener, then reports every failure by name; the listener is no longer aborted. Signature unchanged.Environment::stop()and no longer sleep for port release.mainis the OS-signal boundary: SIGINT and Unix SIGTERM (Ctrl-C on non-Unix) stop it in order; exit code 0.graceful_shutdown_on_cancellationrecords the drain polling cost (below).Baseline bug this fixes
Before this change, SIGTERM sent to the example was caught inside the library (legacy
Haltedpath →torrust-server-libglobal_shutdown_signal): the HTTP server stopped but the process kept running, and a later Ctrl-C madeEnvironment::stop()panic (exit 101). Evidence V1 in the issue folder.Notes for reviewers
graceful_shutdown_on_cancellationinaxum-servernow force-closes remaining connections when its drain deadline passes. Before, its graceful phase had no deadline, so afterTimedOuta held connection kept the server task alive and anything joining it waited forever. This affects the HTTP, REST API, and health-check servers; their tests pass.HttpServer::start/stoppath still subscribes to OS signals indirectly until SI-19; no module inpackages/axum-http-server/srcdoes so directly (AC7).cfg(unix)); only the Linux target was available locally.Validation
server.rs, 6 inenvironment.rs, 1 inaxum-server/src/signals.rs; each was proven to fail against a targeted mutation (recorded in the spec).cargo testpasses fortorrust-tracker-axum-http-server(43 + 61),-axum-health-check-api-server(3 + 8),-axum-server(6), and-axum-rest-api-server(6 + 58), which shares the changed drain helper;linter allpasses; pre-commit passed on every commit; pre-push passed on every push.tracker_client http announce, then SIGTERM or SIGINT: orderly stop, exit 0 (evidence V2, V3).agent-review-reports.md. Review rounds on this PR (Copilot, da2ce7) are recorded indocs/pr-reviews/pr-2439-review/PR-REVIEW.md.