Skip to content

feat(rest-api): [#2130] add peer updated-at timestamp - #2131

Merged
josecelano merged 8 commits into
torrust:developfrom
josecelano:2130-add-peer-updated-at-ms
Sep 2, 2026
Merged

josecelano merged 8 commits into
torrust:developfrom
josecelano:2130-add-peer-updated-at-ms

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

  • Add the required v1 Peer.updated_at_ms absolute Unix-millisecond timestamp.
  • Deprecate both legacy peer timestamp fields and retain them with equal values for v1 compatibility.
  • Add conversion and raw JSON endpoint contract coverage, update API documentation, and record issue-spec verification evidence.

Validation

  • linter all
  • Focused REST API protocol, runtime-adapter, and Axum REST API tests
  • Axum REST API integration test suite (58 tests)
  • Manual local announce and v1 torrent-response verification
  • Pre-push suite: nightly formatting, workspace check, documentation build, and full stable tests

Closes #2130

Copilot AI lite review requested due to automatic review settings September 2, 2026 08:27
@josecelano josecelano self-assigned this Sep 2, 2026
@codecov

codecov Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.97%. Comparing base (67c437e) to head (3717471).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2131      +/-   ##
===========================================
- Coverage    84.05%   83.97%   -0.09%     
===========================================
  Files          350      351       +1     
  Lines        27958    27988      +30     
  Branches     27958    27988      +30     
===========================================
+ Hits         23501    23502       +1     
- Misses        4063     4086      +23     
- Partials       394      400       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new #2130 issue spec metadata/tracking is internally inconsistent (status + implementation-plan task statuses) and should be corrected before merge.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the v1 REST API peer contract to expose an explicit Peer.updated_at_ms absolute Unix-millisecond timestamp while keeping the two legacy timestamp fields for backwards compatibility, and it adds tests + docs to lock in the wire contract.

Changes:

  • Add updated_at_ms to the v1 Peer protocol DTO and deprecate updated_milliseconds_ago (while keeping updated deprecated).
  • Update the runtime adapter conversion to populate all three timestamp fields from the same domain timestamp, plus add focused conversion + raw JSON contract tests.
  • Update v1 torrent endpoint documentation and add an issue specification file (replacing the previous draft).
File summaries
File Description
packages/rest-api-runtime-adapter/src/v1/conversion.rs Maps updated_at_ms (and legacy fields) from the domain timestamp; adds conversion test coverage.
packages/rest-api-protocol/src/v1/context/torrent/resources/peer.rs Extends v1 Peer DTO with updated_at_ms, updates deprecations/docs, and adds serde round-trip test.
packages/axum-rest-api-server/tests/server/v1/contract/context/torrent.rs Adds raw JSON contract assertion that all three peer timestamp keys exist and are equal.
packages/axum-rest-api-server/src/v1/context/torrent/mod.rs Updates the endpoint docs example and explains the timestamp semantics/migration direction.
docs/issues/open/2130-rename-peer-updated-milliseconds-ago-to-updated-at-ms/ISSUE.md Adds the tracked issue spec and verification record for #2130.
docs/issues/drafts/144-rename-peer-updated-milliseconds-ago-to-updated-at-ms.md Removes the superseded draft spec now that #2130 has an assigned open-issue folder.
Review details

Suppressed comments (1)

docs/issues/open/2130-rename-peer-updated-milliseconds-ago-to-updated-at-ms/ISSUE.md:100

  • The Implementation Plan table still marks all tasks as TODO, but later sections (progress log + acceptance criteria) indicate the work is completed. Update these task statuses to avoid contradictory tracking information.
| T1  | TODO   | Extend the v1 peer DTO         | Add and document required `updated_at_ms`; deprecate the misleading legacy field with a migration note.        |
| T2  | TODO   | Map the domain timestamp       | Update `from_domain_peer` so all three v1 timestamp fields equal `DurationSinceUnixEpoch::as_millis()`.        |
| T3  | TODO   | Protect the REST contract      | Add independent conversion assertions and a raw endpoint JSON assertion for all three keys and equal values.   |
| T4  | TODO   | Update consumer-facing docs    | Add `updated_at_ms` and accurate legacy-field semantics to the torrent endpoint example and API documentation. |
| T5  | TODO   | Validate and review acceptance | Execute automatic and mandatory manual checks, then record acceptance evidence.                                |
  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@josecelano

Copy link
Copy Markdown
Member Author

ACK 3717471

@josecelano
josecelano merged commit 0b95200 into torrust:develop Sep 2, 2026
18 checks passed

This branch was previously deployed

1 inactive deployment
coverage — 3717471e Deployed Sep 2, 2026 by josecelano via Generate Coverage Report #1883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add peer.updated_at_ms to v1 REST API

2 participants