buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(cli): stamp repo announcement updates with max(head+1, now)

Open redirwin opened this issue 3 months ago • 1 comments

Summary

build_updated_repo_announcement stamps replacement announcements at the observed head's created_at + 1 (an anti-leapfrog guard), while the relay's ingest gate rejects any event more than ±15 minutes from server time (buzz-relay/src/handlers/ingest.rs). Once an announcement is older than that window, every update built from it — repos protect set, repos protect remove, and repos bind — is rejected with event timestamp too far from server time, so branch protection becomes permanently unchangeable 15 minutes after a repo is announced.

This stamps updates with max(head + 1, now) instead: still strictly after the head the update was derived from (a peer-clock-ahead head within the drift window keeps winning by +1), but never in the past, so the relay accepts it.

Reproduced live today on a 0.4.x relay: a byte-fresh protect set against a day-old announcement was refused; re-announcing via repos create (which stamps wall clock) and re-running protect set within the window succeeded — consistent with the diagnosis in #2876.

Related issue

Fixes #2876 Fixes #4431 Fixes #4432

No existing fix PR found (searched open PRs for "timestamp announcement" / "created_at repos").

Testing

  • Adjusted the two unit tests that pinned the old head + 1 behavior on stale heads (created_at 100) to assert wall-clock stamping.
  • Added update_of_fresh_head_stays_monotonic_over_it: a head 100 s in the future still yields head + 1, preserving the monotonicity guarantee the original comment protects.
  • Local cargo test -p buzz-cli was not runnable on the authoring machine (Windows, no Rust toolchain; hermit shims are POSIX-only) — relying on CI for the run. The change is confined to one timestamp expression plus tests; flagging this explicitly rather than claiming a local pass.

redirwin avatar Aug 03 '26 10:08 redirwin

max(head+1, now) is the right stamp for the relay drift window — the fresh-head monotonic test covers the leapfrog case well.

chessing234 avatar Aug 03 '26 11:08 chessing234