Repository navigation
refactor(axum-health-check-api-server): [#2450] migrate the health-check API test environment to the token lifecycle #2652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
josecelano
merged 15 commits into
torrust:develop
from
josecelano:2450-migrate-health-check-api-test-environment
Oct 26, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4830852
refactor(axum-health-check-api-server): [#2450] migrate the health-ch…
josecelano a381a86
docs(issues): [#2450] record T0 baseline, T1 mutation proofs and M1/M…
josecelano 6cf6534
docs(shutdown-process): [#2450] record the health-check test environm…
josecelano 8a09fe5
docs(issues): [#2450] record the prose-first comparison and the post-…
josecelano aa28b3f
test(axum-health-check-api-server): [#2450] assert the stop result in…
josecelano f0656bc
docs(issues): [#2450] record the independent review, resolve its find…
josecelano e810655
test(axum-health-check-api-server): [#2450] document and pin the fixe…
josecelano be0acb8
docs(issues): [#2450] record the fixed-port restart limitation and it…
josecelano 70b2141
docs(issues): [#2450] correct the independent review entry after the …
josecelano c554b24
chore(deps): [#2450] bump torrust-server-lib to 0.4.0
josecelano cb8c34f
fix(axum-health-check-api-server): [#2450] deregister the health-chec…
josecelano 0042a18
docs(issues): [#2450] record the registry deregistration and update t…
josecelano 6c21b1d
docs(issues): [#2450] record the prose-first comparison of the new te…
josecelano 8ed7da2
docs(issues): [#2450] record the independent review of the final tree
josecelano 6c0d9cd
docs(pr-reviews): [#2450] record the review audit of PR 2652
josecelano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
88 changes: 68 additions & 20 deletions
88
.../issues/open/2450-1488-si-24-migrate-health-check-api-test-environment/ISSUE.md
Large diffs are not rendered by default.
Oops, something went wrong.
126 changes: 126 additions & 0 deletions
126
...50-1488-si-24-migrate-health-check-api-test-environment/agent-review-reports.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| --- | ||
| semantic-links: | ||
| related-artifacts: | ||
| - .github/agents/complexity-auditor.agent.md | ||
| - .github/agents/task-reviewer.agent.md | ||
| - .github/agents/pr-reviewer.agent.md | ||
| - docs/agents/orchestration.md | ||
| --- | ||
|
|
||
| # Agent Review Reports - Migrate the Health-Check API Test Environment to the Token Lifecycle (#2450) | ||
|
|
||
| > Append one completed independent-review entry at a time. Do not modify, reorder, or remove | ||
| > earlier entries. A correction is a new entry that names the earlier conclusion. | ||
|
|
||
| ## Reports | ||
|
|
||
| ### 2026-10-26 07:38 UTC - Task Reviewer | ||
|
|
||
| - Invocation scope: pre-PR review of branch `2450-migrate-health-check-api-test-environment` | ||
| against `torrust/develop`: AC1-AC7, the T1 tests, D1-D5, the task inventory, spec hygiene and the | ||
| evidence file. Result: REVIEW PASSED; all seven acceptance criteria are met by the evidence. | ||
| The AC rows stay TODO until the maintainer says to tick them. | ||
| - Findings (all non-blocking, all resolved in the commit that records this entry): | ||
| - **F1 (medium, spec hygiene)** - `ISSUE.md` still showed T0-T4 and M1/M2 as TODO. Resolved: | ||
| T0-T3 and M1/M2 are DONE, T4 is IN_PROGRESS. | ||
| - **F2 (low, stamps)** - the evidence stamp predated its last commit. Resolved: stamps bumped. | ||
| - **F3 (low, evidence)** - V6 claimed `linter all` passed on each commit without a record. | ||
| Resolved: V6 records the exit 0 and names the last production commit. | ||
| - **F4 (low, evidence)** - uneven V2 timestamps, an unexplained M3 gap, and non-reproducible | ||
| figures. Resolved: timestamps made uniform, the M3 gap and the unreproduced figures stated. | ||
| - **F5 (low, test design)** - the binding-release test ignored the stop result. Resolved: the | ||
| test now `expect`s it, in `test(axum-health-check-api-server): [#2450] assert the stop result in the binding-release test`. | ||
|
|
||
| ### 2026-10-26 16:10 UTC - Task Reviewer (correction of the 07:38 UTC entry, `review-finding:pr-2652-f3`) | ||
|
|
||
| This entry corrects the 07:38 UTC entry above, which stays unchanged. | ||
|
|
||
| - Invocation scope: re-assessment, by the PR author, of the conclusions of the 07:38 UTC entry | ||
| after `review-finding:pr-2652-f2` (a stop-then-start on a fixed port) and | ||
| `review-finding:pr-2652-f3` (this entry). Not a new independent review. | ||
| - Inputs: the 07:38 UTC entry, AC4 of `ISSUE.md`, `Environment::start()` and `stop()` in | ||
| `packages/axum-health-check-api-server/src/environment.rs`, `start_with_cancellation()` in | ||
| `packages/axum-health-check-api-server/src/server.rs`, the `Registar` of `torrust-server-lib` 0.3.0, | ||
| and the review threads of #2652. | ||
| - Evidence: the 07:38 UTC entry did not record the commands or files the reviewer ran or read, so | ||
| the scope of what was verified cannot be reconstructed from it. What is now known: the only | ||
| restart test then used port 0 (`it_should_serve_requests_after_being_stopped_and_started_again`). | ||
| On 2026-10-26 a red test on a fixed port, | ||
| `cargo test -p torrust-tracker-axum-health-check-api-server --lib fixed_port`, failed with | ||
| `Registration { source: DuplicateBinding(...) }` raised by `start()`. Cause, read from source and | ||
| confirmed by that test: `start_with_cancellation()` registers the binding, `stop()` returned the | ||
| same `registar` with the entry in it, and `Registar` 0.3.0 has no remove operation. | ||
| - Findings: | ||
| - **Withdrawn:** the 07:38 UTC conclusion that all seven acceptance criteria are met. AC4 ("A | ||
| stopped environment can be started again and serves the health check") was not met for a fixed | ||
| port. This is `review-finding:pr-2652-f2` (Major). | ||
| - **Inaccurate statement:** the 07:38 UTC entry said every finding was resolved "in the commit that | ||
| records this entry". F1 to F4 were resolved in | ||
| `docs(issues): [#2450] record the independent review, resolve its findings and update the spec status`; | ||
| F5 was resolved earlier, in | ||
| `test(axum-health-check-api-server): [#2450] assert the stop result in the binding-release test`. | ||
| - **Missing fields:** that entry had no Inputs, Evidence, Verdict or Follow-up actions; this entry | ||
| supplies the ones that can still be stated. | ||
| - Verdict: REVIEW FAILED, for the tree reviewed at 07:38 UTC and for AC4 only. This is not a verdict on | ||
| the tree after the fix. | ||
| - Follow-up actions: | ||
| - Fix the restart (`Registar::deregister` in `torrust/torrust-server-lib#2`, then `stop()` removes | ||
| its own registration) and replace the fixed-port test with a green one. | ||
| - Run a new independent review on the final tree and append it as a new entry. | ||
|
|
||
| ### 2026-10-26 16:32 UTC - Task Reviewer (final tree after the fixed-port fix) | ||
|
|
||
| This is the new independent review that the 16:10 UTC correction asked for. | ||
|
|
||
| - Invocation scope: branch `2450-migrate-health-check-api-test-environment` against `torrust/develop` | ||
| after the commit `docs(issues): [#2450] record the registry deregistration and update the spec to the final design`: | ||
| AC1 to AC8, the health-check environment code and tests, `Cargo.lock` and `Cargo.toml`, the spec, | ||
| the evidence file (V0 to V7), the retrospective, the task inventory, stamps and commit-id hygiene. | ||
| The reviewer was read-only and ran its mutation checks in a `/tmp` copy of `git archive HEAD`. | ||
| - Inputs: `ISSUE.md`, `manual-verification-evidence.md`, `implementation-retrospective.md`, | ||
| `agent-review-reports.md`, `task-inventory.md`, `environment.rs`, `server.rs`, `contract.rs`, the | ||
| branch diff (15 files) and the published `torrust-server-lib` 0.4.0 source. | ||
| - Evidence (commands the reviewer ran, from its report): | ||
| - `cargo test -p torrust-tracker-axum-health-check-api-server`: 14 lib tests (3 in `server::tests`, | ||
| 11 in `environment::tests`) and 8 integration tests passed. | ||
| - `cargo clippy -p torrust-tracker-axum-health-check-api-server --all-targets -- -D warnings`, | ||
| `cargo check --workspace --all-targets --all-features` and `cargo +nightly fmt --check`: exit 0. | ||
| - `linter all`: exit 0. | ||
| - Mutation M-A (remove the `deregister` call): 3 tests failed. M-B (deregister after the join result | ||
| is checked with `?`): 1 test failed. Both match V7. | ||
| - Production `.register(` call sites counted with grep, excluding each file's test module: 7 in 4 | ||
| packages (this corrected the "eight" in V7 and the retrospective). | ||
| - `git diff torrust/develop...HEAD -- Cargo.lock` changes only the `torrust-server-lib` version and | ||
| checksum; no `[patch]` section remains. | ||
| - The commit-id check of the `open-pull-request` skill printed nothing; stamps of the changed files are | ||
| at or before their last commits; V-range references are consistent. | ||
| - Findings: | ||
| - **F1 (blocker, evidence)** - V5 recorded no prose-first comparison for the three tests added in | ||
| the review round. Resolved in | ||
| the evidence file's V5, by the commit | ||
| `docs(issues): [#2450] record the prose-first comparison of the new tests and fix the review findings`. | ||
| - **F2 (low, accuracy)** - the production call-site count was seven, not eight. Resolved in the | ||
| same commit, in V7 and the retrospective. | ||
| - **F3 (low, evidence)** - V4 was measured at the T1 tree but read as final. Resolved in the same | ||
| commit: V4 is labelled as measured at T1, not re-run. | ||
| - **F4 (low, stamps)** - the 16:23 stamp preceded the 16:24 progress-log entry. Accepted as it was: | ||
| the rule is stamp at or before the commit, which held; the stamps were bumped again by the | ||
| commit above. | ||
| - **F5 (low, metadata)** - `related-pr` was `null` while PR #2652 was open. Resolved in the same | ||
| commit (`related-pr: 2652`). `status: planned` follows the sibling specs and is unchanged. | ||
| - **F6 (low, risk)** - a dropped `stop()` future also leaves the registration. Resolved in the same | ||
| commit, in the "Risks and Trade-offs" section of `ISSUE.md` (read from source, not run). | ||
| - **F7 (low, test)** - the fixed-port test picks a free port by binding `:0` and dropping the | ||
| listener, so another process could take it first. Accepted: the same pattern is used by | ||
| `ServerStartWithDuplicateRegistration` in `server.rs` tests, and the window is a few | ||
| microseconds. | ||
| - No production-code defect was found in `stop()` or `start()`; the reviewer checked the order of | ||
| `deregister` against the join, the failed-task path and every place that builds or pattern-matches | ||
| `CancellationRunning`. | ||
| - Verdict: REVIEW FAILED on the reviewed tree because of F1 (documentation only). All seven low findings | ||
| and the blocker are resolved or accepted as above; AC1 to AC8 are supported by the evidence and stay | ||
| TODO until the maintainer says to tick them. The reviewer asked for a re-check of V5 after the | ||
| fix; the author re-read V5 against `environment.rs`, and the reviewer was not run again. | ||
| - Follow-up actions: | ||
| - Optional: a reviewer re-checks V5 against `environment.rs`. | ||
| - The maintainer decides when to tick the acceptance criteria. | ||
89 changes: 89 additions & 0 deletions
89
...si-24-migrate-health-check-api-test-environment/implementation-retrospective.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| --- | ||
| semantic-links: | ||
| skill-links: | ||
| - write-markdown-docs | ||
| related-artifacts: | ||
| - docs/templates/ISSUE.md | ||
| - .github/skills/dev/planning/create-issue/SKILL.md | ||
| --- | ||
|
|
||
| # Implementation Retrospective — Migrate the Health-Check API Test Environment (#2450) | ||
|
|
||
| ## Purpose | ||
|
|
||
| Record evidence-based process improvements discovered while implementing | ||
| SI-24 (issue #2450). This is a blameless review of the implementation | ||
| approach; it does not replace acceptance-criteria verification. | ||
|
|
||
| ## Outcome | ||
|
|
||
| `Environment` runs the health-check API on the token lifecycle, with private | ||
| `state`, one `DropGuard`, a joined `stop()` that names every failing task, a | ||
| `bind_address()` accessor, and a `stop()` that removes the environment's own | ||
| registration from the `registar`, so a stopped environment starts again also on | ||
| a fixed port. The evidence is in `manual-verification-evidence.md` (V0 to V7). | ||
| One limitation remains: a bare drop cannot await the registry lock, so only | ||
| `stop()` removes the registration. | ||
|
|
||
| ## What Went Well | ||
|
|
||
| 1. The #2449 sibling was a complete model, so the design review of the new | ||
| environment needed no change. | ||
| 2. Every new test was mutation-proven before review. | ||
| 3. Two independent reviewers (Copilot and da2ce7) found the same defect, which | ||
| no earlier check had covered. | ||
|
|
||
| ## What Changed During Implementation | ||
|
|
||
| Copilot's review of #2652 found that restarting on a fixed port panics with | ||
| `DuplicateBinding` (`review-finding:pr-2652-f1`). The legacy | ||
| `server::start` never registered the service, while the token-aware | ||
| `start_with_cancellation` does, so the migration added a registration that | ||
| `stop()` could not remove: `torrust-server-lib` 0.3.0's `Registar` had no remove | ||
| operation. The restart test used `:0`, which hides the problem. | ||
|
|
||
| The first response was a documented limitation plus a pinning test, with a | ||
| registry change left for a follow-up. da2ce7 re-raised the finding | ||
| (`review-finding:pr-2652-f2`) and asked for the fix, because AC4 promised a | ||
| restart without a port condition. A second look found that the registry change was | ||
| small, so the fix went into this PR: `Registar::deregister` in | ||
| `torrust-server-lib` 0.4.0, then `stop()` deregisters its own binding. The first | ||
| decision was reversed, and the pinning test was replaced by a green fixed-port | ||
| restart test. See V7. | ||
|
|
||
| ## Root Cause | ||
|
|
||
| The spec compared the start and stop paths but not the side effects of the | ||
| token-aware start. D4 asked for `RuntimeServiceMetadata` and treated the | ||
| registration as a given, so no task asked what a restart does to the registry. | ||
| The restart test used the one configuration, an ephemeral port, that cannot | ||
| collide. The first fix choice then weighed the registry change as large before | ||
| its size was measured: counting the `register` call sites and reading | ||
| `Registar` showed an additive method was enough. | ||
|
|
||
| ## Improvements for Future Work | ||
|
|
||
| 1. When a spec migrates a lifecycle that keeps a `stop()` then `start()` path, | ||
| add a task that lists every side effect of `start` (registrations, files, | ||
| channels) and says how `stop` undoes each. | ||
| 2. For a restart test, run it on a fixed port as well as on `:0`. | ||
| 3. Before choosing to document a limitation in place of a fix, measure the cost | ||
| of the fix (call sites, API surface) and write it down; an AC that states no | ||
| condition is a promise the limitation breaks. | ||
|
|
||
| ## Avoiding Overcorrection | ||
|
|
||
| The evidence does not justify the receipt-returning `register` (a breaking | ||
| change to seven production call sites for no present need), shutdown-time | ||
| deregistration for real services (the maintainer decided shutdown stays decoupled | ||
| from registration for now), or a rule that every test environment must support a | ||
| restart after a bare drop. | ||
|
|
||
| ## Evidence | ||
|
|
||
| - `manual-verification-evidence.md` V7 (red test, both decisions, mutation proofs) | ||
| - `ISSUE.md` progress log and D6 | ||
| - `torrust/torrust-server-lib#2` (the `Registar::deregister` change) | ||
| - Commit subjects | ||
| `fix(axum-health-check-api-server): [#2450] deregister the health-check test environment on stop` | ||
| and `chore(deps): [#2450] bump torrust-server-lib to 0.4.0` |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.