Skip to content

fix(cli): use wall-clock timestamp for repository announcement updates - #2901

Open
hsusul wants to merge 1 commit into
block:mainfrom
hsusul:fix/repo-protect-timestamp-drift
Open

hsusul wants to merge 1 commit into
block:mainfrom
hsusul:fix/repo-protect-timestamp-drift

Conversation

@hsusul

@hsusul hsusul commented Jul 25, 2026

Copy link
Copy Markdown

Linked Issue

Fixes #2876

Observed Failure

When executing buzz repos protect set or buzz repos protect remove on a repository announcement created more than 15 minutes ago, the relay rejects the event with:

relay error 400: invalid: event timestamp too far from server time

Root Cause

build_updated_repo_announcement in crates/buzz-cli/src/commands/repos.rs derived the replacement announcement event's timestamp strictly as existing.created_at + 1.
If the existing repo announcement was published more than 15 minutes ago, the derived timestamp existing.created_at + 1 was also more than 15 minutes in the past relative to server wall-clock time (now).
The relay enforces MAX_TIMESTAMP_DRIFT_SECS = 900 (±15 minutes) on all ingested events, causing any update to an announcement older than 15 minutes to be rejected as stale.

Implementation

Updated build_updated_repo_announcement to calculate the replacement event's timestamp as now.max(existing.created_at + 1):

  • Strictly advances existing.created_at to satisfy NIP-33 parameterized replaceable event requirements.
  • Uses current wall-clock time now when updating older announcements, eliminating timestamp drift rejection at the relay.

Regression Coverage

Added unit test protection_update_uses_wall_clock_time_for_stale_repo_announcements in crates/buzz-cli/src/commands/repos.rs verifying that repo announcements published in the past receive replacement timestamps matching current wall-clock time while advancing past the original timestamp.

Exact Validation Commands & Results

  • . ./bin/activate-hermit && cargo test -p buzz-cli -> 251 tests passed
  • . ./bin/activate-hermit && cargo fmt --all -> Clean formatting
  • . ./bin/activate-hermit && just check -> Passed (clippy, formatting, desktop, web, and mobile checks clean)
  • git diff --check -> Passed with no whitespace issues

Limitations or Untested Platforms

None.

Unrelated Changes

No unrelated changes were included.

@hsusul
hsusul requested a review from a team as a code owner July 25, 2026 22:23
@cameronhotchkies cameronhotchkies added the triage-ready Appropriate for agentic review label Jul 29, 2026
@cameronhotchkies

Copy link
Copy Markdown
Collaborator

🦾 DCO sign-off is failing on this PR. Each commit needs a Signed-off-by trailer matching your GitHub-verified email. See the contributing guide for details. Quick fix: git commit --amend --signoff (single commit) or git rebase --signoff HEAD~N (multiple commits), then force-push.

@hsusul
hsusul force-pushed the fix/repo-protect-timestamp-drift branch from 671e265 to f699ba1 Compare October 15, 2026 22:13
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 7852b1670c7588875fc43ef2613c8348893d5ab6...f699ba125726af4fbb4360783a224ad822da7477.
A new review must complete for this exact range. When manual authorization
is required, a user with write access must comment exactly
@buzz-security-review f699ba125726af4fbb4360783a224ad822da7477 to authorize a new review.
Any previous review applies only to its recorded range.

@hsusul

hsusul commented Oct 15, 2026

Copy link
Copy Markdown
Author

Added the DCO Signed-off-by trailer and force-pushed. The Security check failure comes from RUSTSEC-2026-0216 and RUSTSEC-2026-0219 in the dependency tree, not from this PR, which only changes crates/buzz-cli/src/commands/repos.rs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-ready Appropriate for agentic review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

buzz repos protect set and repos protect remove are rejected by the relay's timestamp drift check on any repo announced more than 15 minutes ago

2 participants