Merge remote-tracking branch 'origin/main' into codex/bundled-goose

Signed-off-by: Salman Mohammed <smohammed@squareup.com>
This commit is contained in:
Salman Mohammed
2026-09-28 17:09:52 -04:00
143 changed files with 19540 additions and 3796 deletions

View File

@@ -155,9 +155,9 @@ run_unit_tests() {
run_test_step "buzz-acp unit tests" \
cargo test -p buzz-acp --lib -- --nocapture
# Mirror the three infra-free relay handler modules in `just test-unit`'s
# nextest expression. Keep the side-effects filter pinned to `::tests::` so
# it does not select the sibling Postgres-backed test module.
# Mirror the relay filters from `just test-unit`: the three handler modules,
# storage-snapshot helpers, readiness and router unit suites, and the single
# scoped admission regression in state::tests, plus the REQ lifecycle tests.
run_test_step "buzz-relay channel authorization tests" \
cargo test -p buzz-relay --lib handlers::channel_authz:: -- --nocapture
@@ -169,6 +169,29 @@ run_unit_tests() {
run_test_step "buzz-relay storage snapshot tests" \
cargo test -p buzz-relay --lib storage_sweep::tests:: -- --nocapture
# Infra-free REQ subscription-lifecycle tests, by exact name: the rest of
# handlers::req needs a database.
run_test_step "buzz-relay REQ subscription lifecycle tests" \
cargo test -p buzz-relay --lib -- --exact --nocapture \
handlers::req::tests::timed_out_historical_read_deregisters_before_closed \
handlers::req::tests::superseded_timeout_leaves_replacement_intact \
handlers::req::tests::search_claim_retires_live_and_yields_to_replacement \
handlers::req::tests::concurrent_claims_and_stale_teardowns_keep_the_last_owner \
handlers::req::tests::timeout_closed_is_emitted_before_a_replacement_can_claim \
handlers::req::tests::revoke_then_replacement_keeps_replacement_whole \
handlers::req::tests::claims_after_connection_cleanup_are_refused \
handlers::req::tests::dropped_terminal_frame_cancels_connection \
handlers::req::tests::revoke_dropped_terminal_frame_cancels_connection
run_test_step "buzz-relay readiness tests" \
cargo test -p buzz-relay --lib readiness::tests:: -- --nocapture
run_test_step "buzz-relay router tests" \
cargo test -p buzz-relay --lib router::tests:: -- --nocapture
run_test_step "buzz-relay admission regression test" \
cargo test -p buzz-relay --lib state::tests::neither_a_confirmed_inactive_community_nor_a_failed_lookup_admits_the_socket -- --nocapture
}
# ---- DB / integration tests (infra required) --------------------------------

62
scripts/seed-long-thread.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Seed one long thread on the local dev relay, for reproducing and eyeballing
# long-thread loading in the apps.
#
# just relay # stock local relay on ws://localhost:3000
# just seed-long-thread 187 # or: scripts/seed-long-thread.sh [replies]
#
# Targets SEED_RELAY_URL (default: .env RELAY_URL, else ws://localhost:3000)
# and refuses non-loopback relays. Ambient BUZZ_RELAY_URL/BUZZ_PRIVATE_KEY are
# ignored so an agent or shell session can never seed its real relay. Posts
# with SEED_PRIVATE_KEY (default: a fresh throwaway key) into a new open stream
# channel, or into SEED_CHANNEL if that key may post there.
#
# Every write (channel, root, replies, reactions) counts against the relay's
# 60 human messages/min, so writes are paced SEED_DELAY seconds apart (default
# 1.05): the default run takes ~3-4 minutes on a stock relay. Set SEED_DELAY=0
# when BUZZ_RATE_LIMIT_HUMAN_MESSAGES_PER_MIN is raised on the relay.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${REPO_ROOT}"
if [[ -f ".env" ]]; then
set -o allexport
# shellcheck disable=SC1091
source .env
set +o allexport
fi
REPLIES="${1:-187}"
REACTIONS="${SEED_REACTIONS:-20}"
export BUZZ_RELAY_URL="${SEED_RELAY_URL:-${RELAY_URL:-ws://localhost:3000}}"
export BUZZ_PRIVATE_KEY="${SEED_PRIVATE_KEY:-$(openssl rand -hex 32)}"
unset BUZZ_AUTH_TAG
if [[ ! "$BUZZ_RELAY_URL" =~ ^wss?://(localhost|127\.0\.0\.1|\[::1\])(:[0-9]+)?/?$ ]]; then
echo "refusing non-local relay: $BUZZ_RELAY_URL" >&2
exit 1
fi
BUZZ="${BUZZ_CLI:-cargo run -q -p buzz-cli --}"
DELAY="${SEED_DELAY:-1.05}"
write() { $BUZZ "$@"; sleep "$DELAY"; }
channel="${SEED_CHANNEL:-}"
if [[ -z "$channel" ]]; then
channel="$(write channels create --name "long-thread-$$" --type stream --visibility open | jq -er .channel_id)"
fi
root="$(write messages send --channel "$channel" --content "long thread root ($REPLIES replies)" | jq -er .event_id)"
ids=()
for i in $(seq 1 "$REPLIES"); do
ids+=("$(write messages send --channel "$channel" --reply-to "$root" --content "reply $i" | jq -er .event_id)")
done
if (( REPLIES > 0 )); then
for i in $(seq 1 "$REACTIONS"); do
write reactions add --event "${ids[$(( (i * 7) % REPLIES ))]}" --emoji "👍" >/dev/null
done
fi
echo "channel=$channel"
echo "root=$root"
echo "replies=$REPLIES reactions=$(( REPLIES > 0 ? REACTIONS : 0 ))"

View File

@@ -55,14 +55,15 @@ echo "Test MP4: ${FILE_SIZE} bytes, sha256=${SHA256:0:16}..."
echo ""
# ── Helper: build Blossom auth header ──────────────────────────────────────────
# Creates a kind:24242 event with t=upload, x=<sha256>, expiration=+5min.
# Creates a kind:24242 event with t=upload, x=<sha256>, expiration=+60s, server=<relay>.
blossom_auth() {
local sha256="$1"
local now exp auth_event auth_b64
local now exp server auth_event auth_b64
now=$(date +%s)
exp=$((now + 300))
exp=$((now + 60))
server=$(echo "$RELAY_URL" | sed -E 's|^https?://||' | cut -d'/' -f1)
auth_event=$(nak event \
--sec "$NSEC" \
@@ -71,6 +72,7 @@ blossom_auth() {
-t t=upload \
-t "x=$sha256" \
-t "expiration=$exp" \
-t "server=$server" \
2>/dev/null)
auth_b64=$(echo -n "$auth_event" | base64 | tr -d '\n')