Repository navigation
SI-5: Deprecate rest-api-core and remove from workspace - #1957
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the now-redundant torrust-tracker-rest-api-core crate from the workspace after the contract-first REST API migration, relocating the remaining DI container wiring into rest-api-runtime-adapter and updating workspace references, publishing workflow, and documentation accordingly.
Changes:
- Moved
TrackerHttpApiCoreContainerintotorrust-tracker-rest-api-runtime-adapterand re-exported it from the crate. - Updated import paths and Cargo dependencies across the tracker binary and
axum-rest-api-server; removedrest-api-corefrom the workspace, deny wrapper rules, and deployment publishing. - Updated documentation/issue specs and added a new
use-rest-apiskill with skill-link markers.
Reviewed changes
Copilot reviewed 30 out of 31 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/container.rs |
Switches container import to torrust-tracker-rest-api-runtime-adapter. |
src/bootstrap/jobs/tracker_apis.rs |
Updates REST API container imports (including test module). |
share/default/config/tracker.development.sqlite3.toml |
Adds skill-link: use-rest-api marker for REST API usage workflow. |
packages/rest-api-runtime-adapter/src/lib.rs |
Exposes the new container module publicly. |
packages/rest-api-runtime-adapter/src/container.rs |
New home for TrackerHttpApiCoreContainer wiring. |
packages/rest-api-runtime-adapter/Cargo.toml |
Adds torrust-tracker-configuration and tokio (sync) for container wiring. |
packages/rest-api-core/src/statistics/services.rs |
Deleted as part of removing rest-api-core. |
packages/rest-api-core/src/statistics/mod.rs |
Deleted as part of removing rest-api-core. |
packages/rest-api-core/src/statistics/metrics.rs |
Deleted as part of removing rest-api-core. |
packages/rest-api-core/src/lib.rs |
Deleted as part of removing rest-api-core. |
packages/rest-api-core/README.md |
Deleted as part of removing rest-api-core. |
packages/rest-api-core/LICENSE |
Deleted as part of removing rest-api-core. |
packages/rest-api-core/Cargo.toml |
Deleted as part of removing rest-api-core. |
packages/axum-rest-api-server/src/v1/routes.rs |
Switches REST API container import to runtime-adapter. |
packages/axum-rest-api-server/src/v1/middlewares/auth.rs |
Adds skill-link: use-rest-api marker in rustdoc header. |
packages/axum-rest-api-server/src/testing/environment.rs |
Switches REST API container import to runtime-adapter. |
packages/axum-rest-api-server/src/server.rs |
Switches REST API container import to runtime-adapter (incl. tests). |
packages/axum-rest-api-server/src/routes.rs |
Switches REST API container import to runtime-adapter. |
packages/axum-rest-api-server/Cargo.toml |
Drops dependency on torrust-tracker-rest-api-core. |
packages/AGENTS.md |
Updates architecture docs to remove rest-api-core references. |
docs/packages.md |
Removes rest-api-core references and documents SI-5 removal. |
docs/issues/open/1943-1938-si-5-deprecate-rest-api-core/ISSUE.md |
New folder-based issue spec with manual verification evidence. |
docs/issues/open/1943-1938-si-5-deprecate-rest-api-core.md |
Removes the old single-file issue spec (replaced by folder format). |
docs/issues/open/1938-rest-api-contract-first-migration/EPIC.md |
Updates SI-5 link to point to the folder-based issue spec. |
deny.toml |
Removes rest-api-core from wrapper rules. |
Cargo.toml |
Removes workspace dependency on torrust-tracker-rest-api-core; adds runtime-adapter entry. |
Cargo.lock |
Removes torrust-tracker-rest-api-core package; updates dependencies accordingly. |
AGENTS.md |
Updates package catalog entry from rest-api-core to rest-api-runtime-adapter. |
.github/workflows/deployment.yaml |
Removes cargo publish -p torrust-tracker-rest-api-core step. |
.github/skills/usage/use-rest-api/SKILL.md |
Adds a new skill describing how to use/verify the REST API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix AGENTS.md: change rest-api-runtime-adapter layer from 'client tools' to 'runtime adapter' - Fix packages/AGENTS.md: add Runtime Adapter layer to diagram, update description - Fix ISSUE.md: update status to 'completed', last-updated-utc, check prerequisites and verification - Fix use-rest-api SKILL.md: add Skill Links section
|
ACK 5dda558 |
da2ce7
left a comment
There was a problem hiding this comment.
This is a post-merge review of the change from #1957 as it stands at e170b9620 on the default branch.
What still runs: the pull request moved TrackerHttpApiCoreContainer out of the removed rest-api-core crate into rest-api-runtime-adapter. It now lives at packages/rest-api-runtime-adapter/src/v1/container.rs (moved into the v1 module by ca1c8ab) and is the type every REST API route receives. Live from the change are the struct with its two constructors, the tokio dependency added for it (packages/rest-api-runtime-adapter/Cargo.toml:32), the udp-server wrapper comment at deny.toml:57 and the two use-rest-api skill-link markers. The application builds the container in AppContainer::tracker_http_api_container (src/container.rs:177); initialize and initialize_from are called only from test code.
[Minor] The ban_service field has no reader. packages/rest-api-runtime-adapter/src/v1/container.rs:40 declares pub ban_service: Arc<RwLock<BanService>>, filled at packages/rest-api-runtime-adapter/src/v1/container.rs:121 and src/container.rs:187, but nothing in axum-rest-api-server, rest-api-application or rest-api-runtime-adapter reads it. Its last consumer was get_labeled_metrics in the rest-api-core statistics module that this change deleted, and that function already discarded the value into _udp_banned_ips_total; the banned-IP count the API reports comes from the UDP server statistics repository (packages/rest-api-runtime-adapter/src/v1/adapters/stats.rs:112). The tokio dependency at packages/rest-api-runtime-adapter/Cargo.toml:32 and the import at packages/rest-api-runtime-adapter/src/v1/container.rs:10 exist only to name this field's type. The published crate therefore carries a dependency for no consumer and gives every holder of the container a write handle to the lock the UDP tracker's ban service runs under (reset_bans and increase_counter take &mut self), against the packages/AGENTS.md guidance to avoid direct tokio::sync coupling between packages. Smallest fix: delete the field and its two initialisers, the RwLock and BanService imports, and the tokio line from the crate manifest.
[Nit] The module documentation at packages/rest-api-runtime-adapter/src/v1/container.rs:1 (lines 1 to 7) records history instead of behaviour. Lines 6 and 7 say the module "was moved here as part of SI-5", which in the published crate's documentation names a crate that no longer exists. Lines 3 and 4 say the module wires the tracker components the Axum server uses, but the running application composes the container from its own shared services at src/container.rs:177, while initialize (packages/rest-api-runtime-adapter/src/v1/container.rs:51) builds a separate swarm registry, a tracker core with its own database connection and a separate UDP server container, so an API built through it sees none of a running tracker's state. Smallest fix: replace lines 6 and 7 with a sentence saying that initialize builds an isolated set of components for tests and standalone use and that the application builds the container from the services it already runs.
[Nit] The marker at packages/axum-rest-api-server/src/v1/middlewares/auth.rs:11 is an inner doc line directly followed by the paragraph "Using the Authorization header:", so the rendered documentation of the module reads "skill-link: use-rest-api Using the Authorization header:" as one sentence. Smallest fix: write the marker as a plain // skill-link: use-rest-api comment, the other form docs/skills/semantic-skill-link-convention.md allows for Rust files.
Checked and found sound: nothing at 5a8e78861 referenced the deleted rest-api-core statistics module, so its removal dropped no live code path; every other container field is read by the v1 routes or the API job; deny.toml:57 matches its wrappers list and adds no edge, because the runtime adapter already depended on udp-server for its statistics adapter; the sync feature is all the moved type needs from tokio; the marker at share/default/config/tracker.development.sqlite3.toml:2 and the one in the middleware both resolve to the repository's use-rest-api skill, which lists both files; the lock file agrees with the manifests; and the crate publish list this change edited has since been replaced by a separate package release workflow.
SI-5: Deprecate
rest-api-coreand remove from workspaceCloses #1943
Summary
After SI-4 migrated the stats context to the contract-first architecture, the
rest-api-corepackage became an empty shell with a single consumer (axum-rest-api-server). This PR:TrackerHttpApiCoreContainer(DI container) intorest-api-runtime-adapterpackages/rest-api-core/directorydeny.tomlwrapper rulesAGENTS.md,docs/packages.md)Changes
Code Changes
TrackerHttpApiCoreContainerfromrest-api-coretorest-api-runtime-adapter/src/container.rsaxum-rest-api-serverandsrc/to userest_api_runtime_adapter::containertokiodependency torest-api-runtime-adapter/Cargo.toml(needed for the container)rest-api-coredependency fromaxum-rest-api-server/Cargo.tomland rootCargo.tomlpackages/rest-api-core/directory (~1100 lines removed)deny.toml— removedrest-api-corefrom 3 wrapper rules.github/workflows/deployment.yaml— removedcargo publishstepDocumentation Changes
ISSUE.md)AGENTS.md,packages/AGENTS.md,docs/packages.mduse-rest-apiskill under.github/skills/usage/Verification
cargo check --workspace)