mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
f7496607a8a808cf27119fc9232babad86715f46
3598 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f7496607a8 |
fix(mobile): hash upload payloads off the UI isolate (#9736)
## Summary Move SHA-256 for prepared mobile uploads to a worker isolate with Flutter's `compute`, at all payload sizes. The same digest feeds the `X-SHA-256` header and Blossom authorization. The existing cancellation check runs before each HTTP send, including after the worker returns. ### Related issue No matching open issue or PR found. ### Testing - `just mobile-install mobile-check mobile-test` passed, including `flutter analyze` and the full Flutter suite. - The upload regression verifies that a 2 MiB attachment's `X-SHA-256` header matches the request body's digest. - The composer widget tests wait for the worker while exercising send, progress, cancellation, and error handling. - On Apple M3 Ultra, a host Flutter test ran the production prepared-byte upload path with a stub HTTP transport. Median delay to a queued main-isolate timer over three runs: | Payload | Before | After | | --- | ---: | ---: | | 50 MiB | 330 ms | 3.6 ms | | 100 MiB | 644 ms | 7.5 ms | At 100 MiB, the patched isolate serviced at least 40 callbacks from a 16 ms timer before HTTP send. The baseline serviced zero. Both produced the same hash. This measures host isolate responsiveness. ### Manual check On a phone, attach a large file in a test conversation. Tap Send and immediately scroll the conversation. Scrolling should stay responsive during upload preparation. Open or download the completed attachment and verify that it matches the original. Signed-off-by: Wes <wesb@block.xyz> Co-authored-by: Rocket <0c41329ade659e01801116549bc617351689892a382bc864a1186dc9191293a7@buzz.block.builderlab.xyz> |
||
|
|
e581555bf8 |
perf(relay): serve named-only channel access from the access caches (#9735)
## What
REQ, COUNT, `POST /query` and `POST /count` now take a reader's
named-only channel access (system channels, and any type added later)
from the two access caches they already read. Before, any filter that
opted in to system channels, or named a channel outside the implicit
set, ran `get_readable_named_only_channels` on the writer, uncached, on
every request.
## Why
Clients send such a filter on every connect. buzz-app's system channel
discovery reads `{kinds:[39002], "#p":[me], "#t":["system"]}`. So a
fleet reconnect (rollout, relay restart, network blip) paid one extra
uncached writer read per client, on top of the cached access set. This
read showed up near the top of writer SQL during reconnect herds.
## How
- `get_member_channels_read_at` and `get_listed_open_channels_read_at`
(buzz-db) return every channel type, with their connection checkout
time, and split rows into the implicit set (legacy types) and the
named-only set, with the type. They are the same two queries as before,
without the type filter. `get_member_channel_ids` and
`get_listed_open_channel_ids` keep their results.
- With no names, the two named-only halves together are exactly what
`get_readable_named_only_channels` returns. A new Postgres test pins
that equality for a member and a non-member.
- `AppState::get_channel_access_cached` returns a `ChannelAccess` from
the member cache (per pubkey, 10 s, dropped on every membership write)
and the open cache (1 s, shared reads). It yields the named-only
channels on demand, so a request that uses only the implicit set does no
extra work. `get_accessible_channel_ids_cached` is now a wrapper around
it.
- Both caches' refills are fenced against invalidation by a small shared
`LoadFence` (new `load_fence.rs`), as `MembershipCache` does.
Overlapping misses for a key share one load token, so the first read to
finish publishes. Invalidation drops the token, and a read publishes
only while its token is current. Before, a read that began before a
removal (or an open-to-private change) could finish after it and cache
the old set. That race also affected private stream/forum channels.
- The member snapshot is dated from its read's connection checkout, like
the open set, and a hit older than `MEMBER_CHANNELS_MAX_AGE` (10 s)
reads again. Before, its 10 s started at insert, so a slow read
stretched the bound.
- `readable_named_only_channels_for_filters` uses the cached set when
every channel the request names outside the implicit set is in it. The
system opt-in needs exactly that set. When a request names any other
channel (an unlisted open channel, or one it can't read), it keeps the
uncached read, unchanged.
- A `"consistency": "strong"` `POST /query` takes its named-only access
from the database, so a client that just created a system channel finds
it even on a pod that has not yet seen the invalidation. REQ, COUNT and
`POST /count` keep the cache.
- The thread-window and workflow checks keep the uncached read.
## Staleness
Same as the implicit set's today. Every membership write
(`invalidate_membership`) drops the per-pubkey entry, whatever the
channel type, and the drop is sent to every pod. On the pod that ran the
removal, the next request sees it (the refill fence closes the race). A
missed cross-pod drop keeps a removed member's system channel for up to
10 s after the read began on that pod, as for a private channel. The
open half is used for 1 s.
## What got simpler
No new access cache and no new invalidation trigger. The named-only
access now comes from the same snapshot as the implicit set, so REQ no
longer mixes a cached implicit set with an uncached named-only set.
`get_member_channel_ids` and `get_listed_open_channel_ids` no longer
have their own SQL, and their unused `Db` wrappers are gone. The two
replacement reads keep the old span names (`get_member_channel_ids`,
`get_listed_open_channel_ids`).
## Tests
-
`handlers::system_channels::tests::cached_access_answers_named_only_needs_without_a_database_read`
(unit, unreachable DB): discovery and a cached `#h` name are answered
with no read, the token scope still narrows the result, and a name
outside the cached sets reads the database.
-
`store::unlisted_channels_postgres_tests::cached_channel_sets_match_the_uncached_named_only_read`
(Postgres): the cached halves equal the uncached read and the accessible
set.
-
`state::tests::a_member_read_that_straddles_an_invalidation_is_not_cached`
(unit): a read held open through a per-user or a community-wide
invalidation answers its own request but is not cached.
-
`state::tests::an_open_read_that_straddles_an_invalidation_is_not_cached`
(unit): an open-set read held open through the community's invalidation
answers its own request, and the next request reads again.
- `state::tests::a_member_snapshot_ages_from_its_read_not_its_insert`
(unit): a member snapshot already 10 s old when published is not served.
- `state::tests::overlapping_member_reads_cache_the_first_to_finish`
(unit): a second miss that starts while the first read is in flight does
not stop the first from being cached.
-
`handlers::system_channel_postgres_tests::a_strong_query_sees_a_just_created_system_channel_past_a_stale_cache`
(Postgres): a strong `/query` finds a just-created system channel past a
stale member entry.
-
`handlers::system_channel_postgres_tests::a_token_scope_narrows_system_channels_on_both_access_paths`
(Postgres): token-scoped WS REQ and COUNT, through the cache path and
the database path.
- Must-fail mutants: always take the database branch; keep only legacy
types in the member query; drop the token scope at the REQ call site;
publish without the fence check; drop the open-set token on
invalidation; ignore the member snapshot's checkout age.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Tom Brow <tomb@block.xyz>
|
||
|
|
9bc5740012 |
fix(mobile): stop notification extension sending cookies to Builderlab (#9741)
Builderlab's hosts set Cloudflare's `__cf_bm` cookie on every response. The notification extension's sessions are `.ephemeral`, which keeps an in-memory cookie store, so after the first response every later request to Builderlab sends the cookie back. The NIP-FI assertion issuer refuses any request carrying a `Cookie` header with 401 `session_required`, so the extension's assertions fail and notifications from communities that require NIP-FI fall back to "Open Buzz to view this message". - `BuzzRelayAssertionIssuer` now turns off cookie storage and sending (`httpCookieStorage = nil`, `httpShouldSetCookies = false`) on the configuration it uses for both the identity-binding check and the assertion request, whatever session it is given. - The extension's per-notification relay session gets the same settings, since the relay is also a Builderlab host. - The issuer gains a `startDownload` seam, matching `BuzzNotificationAvatarLoader`'s, and a `BuzzPushKitTests` test checks that the assertion request carries no `Cookie` header after the identity check's response sets one. Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> |
||
|
|
d9c3f4e99e |
Remove personal workflow data and missed event copies (#9675)
## Summary User content cleanup left private hide-list snapshots, saved workflow inputs and notes, unused automation, and some delivery copies behind. This extends the existing per-community content handler to remove them with the same preview, ownership and retry checks. - Delete trusted-relay hidden-DM snapshots and author-signed historical file-metadata events (kind 1063). - Clear recorded event-trigger text/emoji, authenticated manual inputs, and the recorded approver's note while preserving the rest of each run or approval. - Delete unused workflow database definitions and their schedule claims together. Any run, approval or linked claim protects the definition. The entire group must fit the requested batch size, capped at 100 rows, or planning refuses before mutation. - Delete delivery logs under surviving subscriptions before erasing their source events; reject newly arrived dependent rows before committing. Check the whole event batch with hashed membership to avoid repeated work across unrelated delivery history. Run deletion offline with the relay, workflow engine and external writers stopped. Shared history, canvases, artifacts, Git data and device registrations remain outside these additions. Retained runs can subsequently read the cleared inputs; this does not cancel them or claim complete account erasure. Existing signed kind 30620 event cleanup is unchanged. This is an application-only change against existing tables. It adds no migrations, indexes, triggers, functions or foreign keys. Existing per-statement timeouts and community write admission remain in use. ### Related issue Related: #9353. Extends the content handler in #9363. Shared workflow ownership policy remains separate from these personal-field deletions. ### Testing Ran the rebuilt `buzz-admin user-deletions content-batches --community <fixture-community> --pubkey <fixture-user> --batch-size 100` against disposable PostgreSQL 17 fixtures with 100 events, 500,000 unrelated delivery logs, and 9,999 small communities. `--read-only` selected 100; `--delete` removed 100 in 0.39 seconds locally; a second `--delete` selected zero. All 500,000 unrelated same-community delivery rows survived. EXPLAIN used hashed membership under both custom and generic plans. Independent review also exercised stale statistics. Removing the planner safeguard made the regression fail at the executor's actual 3-second timeout. The late-copy test still refuses deletion and preserves the source until retry can include the new copy. Independent agent review completed with no remaining blockers. Earlier command validation on the original patch exercised all agreed additions: preview nine operations, delete nine, retry zero, with whole-row preservation checks for the other community, shared canvas, surviving subscriptions, workflow output/provenance, and other approvers' notes. The repository-wide `just ci` run passed static checks, then stopped on two timeouts in unchanged `buzz-agent` OAuth tests. Both cases passed a serial recheck. The subsequent normal push hooks passed, including the complete Rust unit lane and Tauri checks. Later app build/test recipes were not reached; the full local CI command is not claimed green. Human command verification is pending, so this PR remains draft. On disposable fixtures, run the same preview/delete/retry sequence and verify that only the planned rows/fields change. Generated with Codex --------- Signed-off-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz> Co-authored-by: maincourse <37ce551b493d4a998caf030929c47bce0b6a0e43f1178b3a63c4151d7c16b76e@buzz.block.builderlab.xyz> |
||
|
|
946d9c3467 |
fix(relay): rename target log field to target_pubkey (#9739)
Rename the relay's custom structured log field from `target` to `target_pubkey` at the affected call sites. `tracing` also writes its own `target` field (the module path) after callsite fields, and Datadog keeps the last value. That overwrites the pubkey; using `target_pubkey` preserves it without changing tracing's built-in `target` metadata used by `RUST_LOG` and Vector routing. Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Alia <d32955ad69077062930cc46cfe2df30ca9aaf6f8e76422681265e9e9af704d78@buzz.block.builderlab.xyz> |
||
|
|
379b501124 |
feat(push-gateway): declarative desired-state schema, one file per table (#8328)
## Summary Gives the push gateway a declarative desired-state schema in the same layout the relay uses since #8131: a `\i` manifest plus one file per table, the shape SchemaBot reads. - `crates/buzz-push-gateway/schema/schema.sql`: an ordered `\i` manifest and nothing else. - `crates/buzz-push-gateway/schema/tables/public/<table>.sql`: the end state of migrations `0001`–`0008` for all six gateway tables. That includes `0007`'s `installations.platform` column and `0008`'s dropped delegation → installation foreign key (#9610), so the delegation table declares no `REFERENCES`. Each file holds only its `CREATE TABLE` and plain `CREATE [UNIQUE] INDEX` statements. - `src/postgres.rs`: the six table names are now one `GATEWAY_TABLES` constant shared by readiness and the runtime-role GRANT, instead of two hand-copied lists. - `src/postgres/desired_schema_postgres_tests.rs` adds two tests: - `desired_state_schema_layout_is_complete_and_schemabot_shaped` (no infra needed). It checks that the manifest includes every file exactly once and holds only `\i` lines, that each table file creates exactly one table, and that indexes use a plain `CREATE INDEX` on that table. - `desired_state_schema_matches_migrations` (PostgreSQL lane). It builds one probe database from `schema.sql` through the real `bin/pgschema apply` and another through `GATEWAY_MIGRATOR`. It then requires the two `public` catalogs to match: table set, columns from `pg_attribute` (full type with typmod via `format_type`, default, nullability, identity, generation, collation), table options (persistence, RLS flags, `reloptions`), constraints (`pg_get_constraintdef`) and index shapes (`pg_get_indexdef` + `indoption`). Neither probe may hold functions, non-internal triggers, policies, views, sequences or user types, and the declared table set must equal `GATEWAY_TABLES`. It compares the whole `public` catalog, not a list of tables, so a future migration that changes `public` tables, columns, table options, constraints or indexes without a matching `schema/` change fails CI. It doesn't cover data-only migrations or objects outside `public` (other schemas, roles, database settings). Probe databases are created from `template0` and dropped even when an assertion, `pgschema` or setup fails; the original failure is re-raised unchanged. Connection details, including the password, come from the resolved `PgConnectOptions`, so percent-encoded credentials, `?password=` and Unix-socket URLs reach `pgschema` the way SQLx sees them. `pgschema` 1.7.4 builds an unquoted keyword DSN, so a password or socket path with whitespace, a quote, `=` or a backslash isn't supported (noted in the test). ## Not changed The gateway still migrates itself at startup: bootstrap guard, then SQLx migrations, then runtime-role grants. The guard and grants are operational steps, not desired-state DDL, so they stay in code. No `schemabot.yaml` is added: SchemaBot isn't configured for the relay or the gateway yet, so the yaml for both waits until that server-side setup exists. The manifest header notes that the relay's post-pgschema reconcile step (root `AGENTS.md` gotcha #7) doesn't apply, because the gateway schema has no seed DML or storage parameters. SchemaBot compatibility is not proven here. The parity test shows the files are equivalent under `pgschema`. Since #9610 the gateway schema has no foreign keys, so the earlier inline-FK caveat is gone. `docs/database.md` Rule 4 now lists the gateway `schema/` directory as a schema location. ## What got simpler To read the gateway's schema today you have to replay eight migrations: two CHECK rewrites, two dropped UNIQUE constraints, a dropped column, an added column and a dropped foreign key. After this PR it's one declarative file per table, in the same convention as the relay. There is no new runtime path and no new abstraction, and the duplicated table list in `postgres.rs` collapses to one constant. ## Testing At `c4336392` (rebased on main after #9610; mirrors gateway `0007`/`0008`; reads the `pgschema` password from a copy with a URL-safe host and username, so a `PGHOST` or default-search socket no longer panics and a `/role` username no longer drops the password): - `cargo fmt --all -- --check` and `cargo clippy -p buzz-push-gateway --all-targets -- -D warnings`: pass. - `cargo test -p buzz-push-gateway --lib desired_schema`: pass, including `resolved_password_reads_through_a_socket_host_and_slash_username`. Removing the username normalization makes that test fail. - `scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`: 17/17 passed, including `desired_state_schema_matches_migrations`. At `df3ff104` (password from resolved connect options), same workstation: - fmt, clippy (`-D warnings`, with and without `personal-dev-app-attest`): pass. `cargo nextest run -p buzz-push-gateway`: 80/80, and 82/82 with the feature. `scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`: 13/13. - `?password=`: with `PGPASSWORD` unset, `postgres://<role>:wrong@localhost/postgres?password=<encoded p@ss:w/rd#x>` passes the parity test, so `pgschema` gets the query-parameter password that SQLx uses. A wrong `?password=` is rejected (`28P01`). - The CHECK-bound falsification still fails with `constraint parity mismatch`. Every run leaves 0 probe databases. At `f937924a` (probe cleanup and connection-URL follow-up), on a Linux workstation against PostgreSQL 16 with the repo's pinned `bin/pgschema`: - `cargo fmt --all -- --check`, plus `cargo clippy -p buzz-push-gateway --all-targets -- -D warnings` with and without `--features personal-dev-app-attest`: pass. - `cargo nextest run -p buzz-push-gateway`: 60/60 passed, and 62/62 with `personal-dev-app-attest`. `scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`: 12/12 passed. - Probe cleanup: with a CHECK bound changed (2048→4096), the previous test code fails and leaves both `push_gateway_{desired,migrated}_*` databases behind. The new code fails with the same `constraint parity mismatch` panic and leaves none. A table file that makes `pgschema apply` fail (`no_such_column`) also reports `pgschema apply failed: ... column "no_such_column" does not exist` and leaves none. - Connection URLs: the parity test passes as a role whose password is `p@ss:w/rd#%x`, given percent-encoded in the URL with `PGPASSWORD` unset. It also passes over `postgres://<user>@%2Fvar%2Frun%2Fpostgresql:5432/postgres` (Unix socket, peer auth). Earlier, at `ee2745cb78`: - `scripts/postgres-test-packages.sh` discovers `buzz-push-gateway`. The parity test lives under a `*_postgres_tests` module so the `postgres-ci` nextest filter selects it. - `cargo fmt --all -- --check` and `cargo clippy -p buzz-push-gateway --all-targets -- -D warnings` both pass. - `cargo nextest run -p buzz-push-gateway`: 60/60 passed, including the layout test. - `scripts/postgres-test-run.sh -p buzz-push-gateway`: 12/12 passed, including `desired_state_schema_matches_migrations`. - Falsification checks: - Dropping the partial predicate from `push_gateway_installations_active_token` makes the parity test fail with an index-shape mismatch. - Adding an unmirrored `0007` migration (`ADD COLUMN probe TEXT`) makes the parity test fail with a column mismatch. Mirroring the column in the table file makes it pass again. - Putting `CREATE TABLE` DDL in `schema.sql` makes the layout test fail. - A `0007` adding `probe VARCHAR(64)` mirrored as `VARCHAR(128)` fails with a column mismatch (typmod); mirroring it exactly passes. - An unmirrored `0007` `ALTER COLUMN expires_at TYPE TIMESTAMP` fails with a column mismatch. - An unmirrored `0007` `ENABLE ROW LEVEL SECURITY` fails with a table-option mismatch. - A `0007` creating a function and trigger fails the "only tables and indexes" check. Known gap: `sqlx::migrate!` doesn't notice a *new* migration file on an incremental build. The crate has no `build.rs` `rerun-if-changed`, and neither does any other crate in the workspace. For the `0007` check above I touched `src/postgres.rs` to force the macro to re-expand. Clean CI builds aren't affected. buzz-review-completed --------- Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7e7ec731cd |
test(cli): keep the raw refusal exit test independent of BUZZ_* env (#9733)
## Summary
Follow-up to #9653. Its new test
`cli_exits_nonzero_when_the_relay_refuses_a_raw_publish` went through
`run_from_args`, which resolves credentials from the caller's
environment. With `BUZZ_AUTH_TAG` set (as it is for agents run by the
ACP harness), the test client's key doesn't match the auth tag and the
test exits 3 instead of 2.
The check moves to an integration test,
[`tests/raw_publish_exit.rs`](
|
||
|
|
7bff21e513 |
docs(nip-pm): define pinned messages (#9712)
## Summary Adds NIP-PM, the wire contract for pinned messages in a channel. A Buzz DM is a channel here. - `kind:40010` and `kind:40011`: member-signed pin and unpin commands, one message per command. Each new command carries a fresh `client-id` value, so two commands for one message in the same second are different events. - `kind:30623`: the relay-signed pin list, one addressable event per channel, newest pin first, in the tag shape of NIP-29 `kind:39005` plus an `h` tag. Clients read it with `#h`, which names the channel under NIP-CL. - Relay processing: every change to a channel's list, from a command or from the deletion of a pinned message, applies one at a time in one order. A resent command answers `duplicate:`, pinning an already pinned message changes nothing, and a channel holds at most 250 pins. - Whoever may post a message in the channel may pin and unpin in it. - Deleting a pinned message removes it from the list, whoever deletes it. - A `message_pinned` system message announces each pin and names the command that made it. - A relay does not advertise the NIP. A relay that does not accept the commands refuses them as unknown kinds. The relay implementation follows in a stacked pull request. ### Related issue N/A ### Testing Documentation only. Checked the rendered Markdown, the relative NIP links against the other documents in `docs/nips/`, and that kinds `40010`, `40011` and `30623` are unused in the repository. --------- Signed-off-by: Kalvin Chau <kalvin@block.xyz> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
bc3023a050 |
push-gateway: drop the delegation → installation foreign key (#9610)
## Summary Retire the last foreign key in the push gateway schema: `push_gateway_delegations.installation_id → push_gateway_installations(id)`. This follows `docs/database.md` Rule 2 and the relay FK retirement work (#9399, #9404). - **Gateway migration 0008** drops the constraint. - **Relay migration 0101** drops the relay's legacy copy (Rule 4: gateway schema changes go in both). `schema/tables/public/push_gateway_delegations.sql` loses the inline `REFERENCES`. ## Required stop Every gateway and rollback target must run #9627 (`44cdd9fe`) or later before this merges and deploys. #9627 makes the reaper lock expired installations before it deletes their delegations. Without the FK, an older reaper can leave an orphaned delegation. This is step 2 of the Rule 5 retirement sequence; #9627 is step 1. ## Why the app already enforces the reference | Path | Check | |---|---| | `upsert_delegation` (only delegation insert) | Locks the installation `FOR UPDATE` in the same transaction; rejects a missing or revoked one. | | `create_installation` (replaces expired installations) | Locks the matching installations `FOR UPDATE`, deletes their delegations, then the installations. | | `reap_expired` | Locks expired installations `FOR UPDATE`, deletes their delegations, then the installations (#9627). | | `authorize_delivery` | Reads the installation through the delegation; a missing installation is `Rejected`. | | `revoke_delegation` | Updates the delegation only; an orphan has no effect. | | `revoke_installation`, `rotate_endpoint`, `advance_assertion_counter` | Update the installation; they never delete it. | The relay never reads or writes the `push_gateway_*` tables (the gateway requires its own database), so dropping the relay copy changes no relay behavior. ## Tests The gateway tests run against the migrated schema, which no longer has the FK, so they prove the app check. - `migrated_schema_has_no_foreign_keys` (new): the gateway schema has no foreign keys after migrations. It fails if gateway migration 0008 is removed. - `delegation_for_missing_installation_is_rejected` and `reaper_deletes_delegation_committed_while_it_waits` (from #9627) now run without the FK. - `reaper_retains_revocation_tombstones_until_authority_expiry`: its hand-built schema drops the FK too. - Relay: `push_gateway_delegations` joins the constraint parity check in `admin_schema_parity_between_desired_state_and_migrations`, and the migration count test covers 0101. ## Validation Blox at `33f7df90` (before the rename to 0101; CI covers the rebased head): - `cargo fmt --check`, clippy (`buzz-push-gateway`, `buzz-db`, all targets), gateway unit tests, `buzz-db` migration unit tests: pass. - `scripts/postgres-test-run.sh -p buzz-push-gateway --lib --tests`: 16/16 pass. - `buzz-db` Postgres tests for migrations, parity, push, floor retirement and retained guards: 56/56 pass, including `admin_schema_parity_between_desired_state_and_migrations`. - Must-fail check: with gateway migration 0008 removed, `migrated_schema_has_no_foreign_keys` fails (1 foreign key vs 0). ## Coordination - On main after #8696, #9398 and #9710 (relay 0095–0100). #9627 shipped this PR's reaper fix and tests separately, so this PR is the schema drop only. - Renumbered to relay 0101 after #9710 took 0098–0100 (rename only; file contents unchanged). #9690 and #9621 also add a relay 0098; whichever merges second renumbers. - #8328 adds the gateway's declarative schema with the inline FK. Whichever PR merges second removes it there. ## What got simpler One fewer database object. Every gateway reference check now lives in one place: the gateway's own transactions. buzz-review-completed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: Luke Tornquist <tornquist@squareup.com> Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4079793f99 |
Match desktop unread cues on mobile channel rows (#9715)
## Summary - Honor the synced `seen:<channel>` timestamp in mobile row styling and the **Unreads** filter. Attention keeps its dot regardless of timestamp, and the row's mark-read menu uses the underlying unread state. - Hide the dot when the row shows a mute the relay has confirmed. Confirmation survives reconnects within the same account and relay. The row still exposes unread attention to screen readers. Unmuting on the phone restores any dot supported by retained unread evidence as soon as the bell disappears. - Apply the same `seen:<channel>` timestamp to the app icon badge's ordinary backlog count. Mentions and thread replies keep counting. Includes #9721. This reuses the existing read-state and mute sync. Pending mutes keep the dot visible, and the patch adds no relay requests or read-state writes. ### Related issue No matching issue or open PR found. Earlier mobile sidebar unread parity work is in #1303. ## Testing - `just mobile-install mobile-check mobile-test` - Widget coverage for backlog at and after the desktop cut, mentions on either side of it, the **Unreads** filter, the mark-read menu, pending and confirmed mute, and unmute while the relay still reports muted. - Scripted relay coverage for mute confirmation across reconnects, delayed and older responses, newer confirmations, and relay switches. Read-state tests cover reading a peer's `seen:` context during an ordinary mobile publish. - Badge provider tests cover backlog at and after the cut, plus mentions and thread replies older than the cut. ### Test on a phone with desktop alongside 1. Check out the PR. To install a local debug build, run `./scripts/mobile-worktree-overrides.sh` from the repo root, then run `flutter devices` and `flutter run -d <device-id>` from `mobile/` with Hermit active. Use the device signing setup if needed for a physical iPhone. Sign in to the same account and community on both clients. Use an already initialized mobile account and leave the phone on the channel list. [Device signing setup](https://github.com/block/buzz/tree/main/mobile#ios-push-capability) 2. Have a second account post an ordinary message in a test channel. Wait for its row to become bold on both clients. On desktop, open that channel and switch away quickly, before the 300 ms reading dwell. After sync, the phone row should lose bold. In the phone's section menu, choose **Filter…**, select **Unreads**, and tap **Apply**. The row should disappear. Use **Show hidden channels** and long-press the row to verify that **Mark Read** is still available. Dismiss the menu, tap **Hide filtered channels**, and have the second account send a newer ordinary message. The row should appear bold again. 3. For a mention older than the cut, have the second account @mention you in a different test channel before making the quick desktop visit. After leaving the channel on desktop, the phone should still show its attention dot. For a newer mention, do the quick desktop visit after an ordinary post in a separate channel, wait for its phone row to quiet, then send the @mention. Its phone row should gain a dot. 4. With the mention still unread, mute that channel on desktop. When the phone shows the muted bell, verify that the attention dot disappears. Turn off the phone's network connection, return to the channel list, then reconnect. The dot should stay hidden throughout. On the phone, long-press the row and choose **Unmute channel**. The dot should return as soon as the bell disappears. Keep the phone on the channel list throughout so it does not read the mention. 5. On a phone with app badges enabled, repeat the ordinary-message case in step 2 with that message as the only unread item. After the phone syncs the desktop visit, the app icon badge should clear. A newer ordinary message should bring it back. Device and desktop testing is pending. ### Before and after Before and after captures from the Flutter channel list widget with synthetic rows. The ordinary `desktop-seen` row loses bold, the confirmed-muted mention loses its dot, and the unread control stays bold. | Theme | Before | After | | --- | --- | --- | | Light |  |  | | Dark |  |  | --------- Signed-off-by: Wes <wesb@block.xyz> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> |
||
|
|
286095c937 |
feat(mobile): refresh Huddle speaking styles and iOS controls (#9716)
## Summary Bring mobile Huddle speaking indicators closer to desktop with a close, avatar-colored ring and subtle portrait motion, respecting reduced motion. Use native Liquid Glass for full-screen iOS controls with clear microphone/speaker active states; preserve the minimized sheet. Regular iPhone and Android controls retain their existing positions and sizes. Duo uses a side rail with End Call above minimize, microphone and speaker below, consistent spacing, and extra cover-display status clearance. Participants remain centered across the full display width. Hide the emoji action while retaining reaction support for a future return. ### Related issue No matching open issue found. Earlier mobile control exploration: #9383; invitation changes are outside this PR. ### Testing - Static analysis and pre-push checks passed at `bc5eb34f4`. - Full mobile suite: 5,126 passed; companion suite: 27 passed. - Coverage includes speaking-ring geometry, reduced motion, glass selected states, both Duo rail sides and display sizes, standard-phone control geometry, and minimizing to the original sheet. - Physical Duo previews reviewed during iteration; final build installed on iPhone Air for owner testing. Owner approved proceeding to PR. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> |
||
|
|
5ccbb61190 |
feat(cli): add raw query and publish escape-hatch commands (#9653)
## Summary Agents using the CLI had no way to answer questions like "which channels is key X a member of" (kind 39002 with `#p`) without scanning channels one at a time, which runs into identity-adapter rate limits. This adds a small escape hatch that reuses the CLI's existing credentials (signing key, auth tag, federated identity assertion): - `buzz raw query <filter>`: send one filter object or an array of filters (or `-` for stdin) to the relay's `/query` endpoint and print the relay's JSON as-is (an event array, or an object for filters such as read-state snapshots). - `buzz raw publish`: build, sign and send an arbitrary event, either from `--kind`, repeatable `--tag` (JSON arrays, as in `social set-list`) and `--content`, or from a full `--event-json` template. Signing goes through `sign_event`, so the auth tag is attached as for every other command; a caller-supplied `auth` tag is refused. Ephemeral kinds (20000 to 29999) use the ephemeral publish path, except the NIP-43 leave request (28936), which goes over HTTP because the relay revokes the submitting socket on success. Gift wraps (1059) are refused, since they need NIP-59 signing with a throwaway key. Malformed input (bad JSON, a filter that isn't an object, a bad tag) exits 1 with the usual `user_error` JSON; the relay validates filter fields itself, and its rejection exits 2 as a relay error. A publish the relay refuses (`accepted:false`, over HTTP or the WebSocket) exits 2 with the event id and message. README and TESTING.md list the new commands and their limits (replaceable and addressable kinds replace the whole event; kind-scoped credentials can fail artifact revisions). ## Regressions None expected: this adds a new command group and does not change existing commands. `submit_event` now also gives the relay-admin kinds (9030 to 9033), identity archive and unarchive requests (9035, 9036) and the leave request (28936) the moderation retry policy (no blind resend after an ambiguous outcome). `agents archive` and `agents unarchive` send 9035 and 9036, so after a lost response they now report an unknown outcome instead of resending, which could re-archive over a later unarchive. ### Validation Tried against a live relay as a signed-in user: a kind 39002 `#p` query listed one key's channels, a two-filter array and an `ids` lookup returned the expected events, and `raw publish` sent a typing indicator, a reaction and a deletion of that reaction, all accepted. New tests in [`raw.rs`]( |
||
|
|
03336d0872 |
fix(mobile): only say "Community changed" when the community changed (#9156)
On mobile, a text send that failed for almost any reason showed **"Not sent. Community changed."** The composer caught every `StateError` as a community switch, and relay failures such as a briefly disconnected socket (`RelaySession.publish` throws "Relay session is not connected") are also `StateError`s. So a reconnect blip during a send told the user they had switched communities when they hadn't. The community-switch guards in message, forum and channel-action delivery now throw a dedicated `ActiveCommunityChangedError`, and an unconnected publish throws `RelayNotConnectedError`. Both still extend `StateError`, so every existing `on StateError` caller behaves as before. The composer now reports: | Failure | Message | | --- | --- | | Active community changed mid-send | Not sent. Community changed. | | Relay socket not connected | Not sent. No connection. | | Relay never acknowledged the event (ack timeout) | Not confirmed. The relay didn't respond. | | A relay request timed out before the event was published (e.g. a roster lookup) | Not sent. The relay didn't respond. | | Connection lost after the event was sent, before its acknowledgement | Not confirmed. Connection lost. | | Relay rejected the event, or anything else | Not sent: *relay reason or error text* | The two "Not confirmed" cases may still have been accepted by the relay, so they avoid a definite "Not sent" that would invite a duplicate resend. Pending publishes rejected by a disconnect or backgrounding now complete with a typed `RelayAckLostError` instead of a generic exception, and an unacknowledged publish times out with `RelayAckTimeoutError` (still a `TimeoutException`) so it can be told apart from earlier timeouts. The draft is restored in every case, as before. ### Validation - Added [composer widget tests](https://github.com/block/buzz/pull/9156/files#diff-101740841aadcb902d0717f3909debe16073c672e73be74a5b908bf11dfc8782) for each non-community failure (disconnect, timeout before publishing, ack timeout, connection lost before acknowledgement, relay rejection, other `StateError`), checking the snackbar text, that the draft is restored, and whether the message EVENT was sent. The disconnect, timeout and connection-lost cases run through the real relay session (a pending publish rejected by backgrounding, a history request that times out before any message EVENT). The existing community-switch journey goes through the real channel-action guard. - Simulator (iPhone 17 Pro, debug build of this branch signed in to a test community): opened a channel and sent a message; it was delivered and the composer cleared normally. Limitation: the error paths themselves were exercised only by widget tests, since the simulator shares the Mac's network and I couldn't drop the relay connection for it alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Tom Brow <tomb@squareup.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
4e1d0b27fd |
chore: require relay owner review for the relay and db crates (#9728)
## Summary Make the relay database owners also the code owners for the relay crate, `/crates/buzz-relay/`, and the relay database crate, `/crates/buzz-db/`. This uses the same five owners that #9708 gave the migration and schema paths. The `main` ruleset requires code owner review, so any PR that touches either crate now needs an approval from one of these owners instead of `@block/buzz-oss-team`. Any one of them can approve. The ruleset still requires one approval in total. ### Related issue N/A. Extends #9708. ### Testing `GET /repos/block/buzz/codeowners/errors?ref=wpfleger/relay-crate-codeowners` returns no errors. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> |
||
|
|
42b89f9b5f |
fix(mobile): align Huddle cards and preserve conversation navigation (#9713)
Hide generated private Huddle rooms from mobile channel lists, including cached rooms and older rooms with creator-matched creation receipts. Ended Huddle cards keep **View** available while membership is unknown. Known non-members see disabled **Ended**. Unknown membership is checked with the relay before opening history, and explicit access denials clear cached transcript rows. Opening history never joins audio. Known members can reopen loaded history offline. Already-authorized history stays mounted through a disconnect or transient revalidation failure while the route remains open; reconnects recheck access, and explicit denial clears it. Rooms without sufficient evidence remain visible. Match desktop card colours, borders, 20-point corners, elapsed duration, participant avatars and ended-call icon. Active cards retain headphones and mobile tap targets. Replace the minimized Huddle's full-app UIKit background with Flutter clipping: the native background caused the two-pane iOS conversation to appear blank even though its messages were loaded and scrollable. The owner reproduced the failure and confirmed the Flutter surface restores the timeline on iPhone Duo. Lifecycle updates share one live subscription and merge into history. Start/end discovery has its own query budget and survives a failed participant-history read; avatar rosters use revision and admission metadata for same-second reconnects. Explicit denials propagate without trying a fallback transport. Creation receipts coalesce overlapping list refreshes and reconcile after the list loads, retain verified classifications in scoped snapshots, and stop sending batches after a community switch. Removed the unused native backdrop and bottom-corner options. Validation on `7f1a278dbe`: 5,133 Flutter tests plus 27 companion tests passed (71 skipped), analyzer and file-size checks passed, and the iOS release build passed. The updated Buzz Huddles preview is installed on iPhone Duo. The phone locked before launch, so the exact-revision native journey is still pending. Regressions cover cached-history denial, live-only lifecycle events across recovery, busy-call discovery, same-second rejoining, slow and overlapping receipt lookups, cached classifications, community switching, and HTTP denial with a transient WS failure configured. Both transport-denial and overlapping-refresh regressions were verified failing before the fixes. Tom’s follow-up from #9719 adds held-revalidation, known-member offline reopen and partial-roster failure coverage. The original blank-screen fix was verified by the owner on iPhone Duo; this review revision still needs their on-device minimized-Huddle/two-pane and VoiceOver checks. The surface retains Flutter's existing 24-point shape instead of iOS-adaptive concentric corners. ### Snapshots Synthetic widget previews; no private conversation data. | Active | Ended | Dark mode | | --- | --- | --- | |  |  |  |  --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> |
||
|
|
1ac0b1dad1 |
Match mobile mention chips to desktop styling (#9706)
Mobile mentions now use the desktop chip treatment: neutral rounded pills for other identities, the chat accent for mentions of the viewer, and a contrasting inset fill inside outgoing messages. This applies to message bodies and compact previews, while preserving profile taps and resolving self-highlights by public key. The change reuses the existing chat palette and keeps it stable across parent rebuilds, so unchanged messages retain their parsed Markdown. Mention routing and composer behavior are unchanged. Validation: `just mobile-check mobile-test` passed (5,118 Flutter tests, 71 skipped, plus 27 crypto-package tests). Coverage includes light/dark themes, 2× text, profile taps, live identity switching, outgoing contrast, and Markdown reuse; removing self-highlighting makes the regression fail. A signed iOS build was installed and checked on a physical device, then approved for PR preparation. ### Snapshots Actual Flutter component renders with synthetic identities and the bundled app font. Each shows received/own messages, compact previews, and enlarged text. | Light | Dark | | --- | --- | |  |  | buzz-review-completed Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> |
||
|
|
98e2b7cbbc |
feat(relay): push mentions to people outside a listed channel (#9623)
## Summary A message that `p`-tags someone in a listed channel they haven't joined now sends them a push. Before this, push woke only channel members. This is the relay part of "Let them know", a choice for mentioning people outside a public channel. The client changes are https://github.com/block/buzz-app/pull/3769, https://github.com/block/buzz-app/pull/3771 and https://github.com/block/buzz/pull/9629. - The matcher wakes a non-member only when a `p` tag names them and the channel is open, not unlisted, and a stream or forum. It reuses the channel directory's `LISTED_CHANNEL_SQL`. - Delivery checks again before sending. The channel must still be listed, the event must still mention them, and they must still be able to connect. A ban on them or their agent's owner blocks the push, and so does a missing membership or allowlist entry when the relay requires one. - Members, private and unlisted channels, DMs and system channels are unchanged. **Needs security review.** This decides who gets push wakes. A wake goes only to someone who could already read the event with `REQ`, and it carries no message content. Follow-up: a banned or removed channel member still gets wakes until their lease expires. That predates this PR, and the fix belongs in the ban and removal code. ### Related issue None found. ### Testing - Postgres tests run ingest through delivery against a fake gateway. They cover private, unlisted and system channels, a switch to private before delivery, bans, removal, a missing allowlist entry, and an agent relying on its owner's membership. I made 20 small changes that each broke one of these checks, and each one made a test fail. - On a local relay with a stand-in gateway, an outsider's mention push arrived, and nothing went out after a ban, a removal or a switch to private. With the new delivery check turned off, the banned and removed people got pushes. - Not tested: a real gateway and a phone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Soheyl Vakili <soheyl@squareup.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Tom Brow <tomb@block.xyz> |
||
|
|
9ea57cba2a |
fix(db): undo migration 0097 (#9710)
## What Migrations `0098`–`0100` undo migration `0097` (community artifact expand). The declared schema goes back to its shape before #9650. #9650 added `0097`. The revert, #9689, removed the feature but kept `0097` byte for byte, because databases that auto-migrated recorded its checksum. No code on `main` reads or writes what `0097` added. This PR removes it with forward migrations, as `docs/database.md` requires ("Never edit a merged migration. Fix forward."). `artifact_heads.channel_id` gets `NOT NULL` back in the three steps from *Adding `NOT NULL` to a populated table*: - `0098` checks that the artifact head key is `(community_id, artifact_id)`, then adds `CHECK (channel_id IS NOT NULL) NOT VALID`. - `0099` validates the check under `SHARE UPDATE EXCLUSIVE`, so channel artifact reads and writes continue. - `0100` sets `NOT NULL` from the validated check (no scan), drops the check, drops `artifact_heads_live_type`, `artifact_heads_scoped_identity` and `artifact_revisions_scoped_identity`, and drops `artifact_heads.scope`, `artifact_revisions.scope`, `artifact_revisions.community_event`, `artifact_revisions.redacted` and `communities.artifact_type_policies`. The primary keys don't change. `0097` never changed them. ## Review checklist (docs/database.md) - **Phase:** contract. It follows the expand in #9650 (`0097`) and the code revert in #9689. - **Required stop:** every relay pod, job and rollback target must run #9689 (`sha-a406191`) or later before `0100` runs. The chart's upgrade notes (`deploy/charts/buzz/README.md`) say this, along with how to roll back with auto-migration off. No tagged relay release contains #9650. Only rolling images from `eebf62b6` up to, but not including, `a4061916` are affected. Relays built from #9650 itself read `artifact_heads.scope` and write with `ON CONFLICT` on `artifact_heads_scoped_identity`. Releases before #9650 never read these objects. - **Fails closed:** `0098` refuses a database whose artifact head key is the scoped key from #9650's removed operator contract script or declared schema. That database needs the recovery in #9689's Compatibility section. `0099` fails if any head has a null `channel_id`. Both stop before any cleanup. - No trigger, function, procedure, rule or foreign key is added. No migration changes existing rows. - Every schema location in Rule 4 is updated: `migrations/` and `schema/tables/public/` (`artifact_heads.sql`, `artifact_revisions.sql`, `communities.sql`). No reconcile-script or gateway change applies. - **Currently deployed relay:** a relay from #9689 or later doesn't use these objects, and neither does a relay from before #9650. The populated-table test runs every migration over channel artifact data. - **Locks:** each migration sets `lock_timeout = '5s'` and `statement_timeout = '30s'`. No index is built. ## Tests - `admin_schema_parity_between_desired_state_and_migrations` compares `artifact_heads`, `artifact_revisions` and `communities` across the desired-state and migrated paths. It fails without `0100`. - `populated_artifact_tables_auto_migrate_through_every_migration` checks that a channel head and revision written before `0097` survive with the same channel and event. - `artifact_unexpand_validates_while_channel_heads_are_written`: `0099` completes while a channel head write is still open. It fails if `0099` sets `NOT NULL` directly. - `artifact_unexpand_refuses_scoped_head_key`: `0098` stops on the scoped key and leaves `0097`'s columns in place. ## What got simpler The schema loses 5 unused columns and 3 unused indexes. `artifact_heads.channel_id` is required again, as the channel code assumes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Luke Tornquist <tornquist@squareup.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7361326717 |
fix(mobile): keep glass controls mounted and the wide thread push parallax (#9726)
Fixes three regressions that #9717 (Duo chat switching) introduced. **Glass controls blank when anything covers their route.** #9717 gated `IosGlassNavigationButton` and `IosGlassNavigationAction` on `useNativeRouteControlsVisible`, so every glass control (Home's filter chips, glass Back, Close, Done) unmounted under any dialog, alert or modal sheet and during every push, pop and back swipe, then came back as a new platform view near the end of the transition. This drops the gate from those two widgets, which restores their behaviour from before #9717. The problem #9717 targets is unaffected: under Search and Activity sheets the hook already returns true and the opaque backing hides the controls. Home's gate, the Channels route sync and `IosMessageCreateButton` keep the hook. **The visibility hook rebuilt its host on every animation frame.** It subscribed to the route's animation values but only reads whether the covering animation is at zero and whether the route is reversing. It now uses `useListenableSelector` on those two booleans, so a host rebuilds only when visibility can change. **A wide thread push lost the outgoing chat's slide.** For an immediate wide selection, `_ConversationDetailRoute.buildTransitions` returned its child directly, which also discarded the secondary animation that moves the chat left when a thread is pushed over it. It now builds the platform transition with a completed primary animation, so selection stays immediate and the covered chat keeps its parallax. ### Regressions - Glass controls go back to staying mounted under covering routes, as they did before #9717. Platform-view bleed under non-sheet routes is therefore the pre-#9717 behaviour, not new. - No change to compact navigation or to the Search and Activity sheet composition. ### Validation Added tests: - [native_route_controls_test.dart]( |
||
|
|
bf1cd5500d |
fix(mobile): stabilize Duo chat switching and sheet layering (#9717)
## Summary Selecting a chat or channel in the expanded conversation layout now switches immediately, while opening a deeper thread keeps its navigation animation. The selected chat reuses the native iOS header and blur surface so switching conversations does not flash; each conversation still owns its own editor and timeline state. Search and Activity now slide as opaque sheets over stationary native controls, revealing them progressively on dismissal. Activity keeps its existing title styling with Close in the Duo rail; expanded Search gains top spacing. Compact navigation and the transparent toast composition path are preserved. ## Validation - Final head `bd92c40e86`: full mobile suite 5,132 passed, 71 skipped; 27 crypto tests passed. Required push checks passed. - Native iOS suite: 115 passed. Formatting and analysis clean. - Header-retention regression fails with the retention key removed and passes after restoration. - Recorded repeated native-header switches in a wide iPad simulator fixture, plus Search/Activity transition checks in the Duo simulator. - Owner verified both sheet motion and chat switching on the physical Duo. The final ordinary-iPad Activity guard is covered separately by tests. ## Snapshots Synthetic chat fixture using the actual conversation-pane routes and UIKit header on an iPad simulator. These illustrate two consecutive selections; they are not screenshots of the owner's chats or the Duo rail geometry. Recorded transition frames were also inspected for continuous blur. | Design selected | Mobile selected | | --- | --- | |  |  | --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>mobile-v1.5.0-rc.4 |
||
|
|
65c7d64c94 |
Require relay schema owner review for migrations and schema (#9708)
## Summary Make @TheSentinel454, @wpfleger96, @bradseiler, @salman1993 and @ravarora2 the code owners for the relay database migrations and schema: - `/migrations/` - `/schema/` - `/scripts/reconcile-schema-after-pgschema.sql` - `/.pgschemaignore` The `main` ruleset requires code owner review. So any PR that touches these paths needs an approval from one of these five. Any one of them can approve. When one of them writes a migration PR, another owner approves it. CODEOWNERS uses the last matching line. For these paths, this entry replaces `@block/buzz-oss-team` as the owner. The ruleset still requires one approval in total. What got simpler: nothing. This adds four ownership lines and no code. ### Related issue N/A. No duplicate found. ### Testing `GET /repos/block/buzz/codeowners/errors` on this branch returns no errors. All five users have write access or higher. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Luke Tornquist <tornquist@squareup.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>mobile-v1.5.0-rc.3 |
||
|
|
4704fbafb6 |
fix(relay): resurface a hidden DM when someone else messages it (#9678)
## Summary A DM hidden with **Hide conversation** (kind 41012) stayed out of the sidebar for good, even after new messages arrived. The only way back was New message → same people → Send. This makes the relay clear the hide when *another* member posts a message (kinds 9 / 40002 / 40008) in the DM, like Slack does. The author's own hide is kept, so replying from another device doesn't resurface it. - `buzz-db` `dm.rs`: `unhide_dm_for_recipients` clears `hidden_at` for every other active member. `lock_dm_visibility` takes the same advisory lock that replacing the viewer's kind 30622 snapshot uses, then reads that viewer's hidden DMs and latest snapshot time. - `side_effects.rs`: `persist_dm_message` stores the message, clears the hides and replaces each affected viewer's snapshot in **one transaction**, then fans out after commit. A snapshot that doesn't land rejects the message, so the client's resend tries again. When someone hid the DM, the message takes the DM's membership lock before its insert, as a removal does, so it can't deadlock against a removal or reopen. The hide/open path (`publish_dm_visibility_snapshot`) shares the same lock → read → write seam. - Used by both message paths: client ingest (`ingest.rs`) and relay-signed workflow messages (`workflow_sink.rs`, author resolved via `effective_message_author`). - `NIP-DV.md`: documents the rule. **Deploy order:** relay first. The client companion is block/buzz-app#3889, which rereads visibility from the writer when a message lands in a hidden DM. Against an older client the row returns on the next roster refresh. ### Related issue N/A. None found. ### Testing - New Postgres test `dm_message_from_someone_else_unhides_it` (`membership_notice_postgres_tests.rs`): hide → the viewer's own message keeps it hidden → a peer's message whose snapshot is blocked by a trigger is rejected, not stored and not delivered → its resend, parked at fan-out, already shows the DM visible and is delivered once. It is `#[ignore]` (needs Postgres) and runs in Backend Integration CI. It was not run locally. - Pre-push `rust-tests` lane (`just test-unit`) and local clippy pass; `observability_source` source-policy test updated for the new transaction seam. - Reviewed by the Royal Court agents. Their findings (atomicity, lock-before-read, workflow path) are fixed in follow-up commits. - Human test pending. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5f08ed2511 |
fix(deploy): pin self-host installs to relay 0.3.0 (#9714)
## Summary - Pin the Compose fallback and example environment to `ghcr.io/block/buzz:0.3.0`. Document how to opt into rolling `:main` builds and how to update the image tag before running `./run.sh upgrade`. - Set the Helm chart's default relay image to `0.3.0` through `appVersion` and bump the chart and quickstart to `0.1.12`. - Add a relay release checklist step to update both deployment defaults after each stable image is available. The existing chart release workflow publishes the bumped chart after merge. ### Related work [#2824](https://github.com/block/buzz/pull/2824) also touches self-host Compose. This PR covers release tags and upgrade instructions. ### Testing - Rendered Compose with the example environment, the fallback, and explicit image overrides. A fresh isolated Compose install reached readiness with `ghcr.io/block/buzz:0.3.0` and returned `ok` from `/_liveness`. - Passed Helm lint and all 85 unit tests. Rendered all four chart fixtures, verified the default image and an override, and packaged chart `0.1.12` with app version `0.3.0`. - The repository-wide `just ci` run passed. It started at `cf357b241`, and the final commit changes only the Compose upgrade text. --------- Signed-off-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz> Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>chart-v0.1.12 |
||
|
|
83eb59c631 |
fix(mobile): keep open shared sessions in Solo (#9704)
Sharing a Solo session as View only changes its access to open. Mobile incorrectly required private access to recognize Solo, moving these sessions into Channels. Recognize labeled Solo streams independently of visibility, retaining their existing project placement and membership/ownership checks. Apply the same rule to iOS notification classification so reply routing agrees with Flutter. Add regression coverage for open owned/shared Solo sessions and exclusion from Channels. This changes presentation only; access settings remain unchanged. Validation: mobile-install and mobile-check passed; Solo regressions passed in the full Flutter run (5,095 passed, 71 skipped, one failure in community_provider_test.dart: startup and credential replacement discard orphan snapshots and image caches). All 81 BuzzPushKit tests passed. Independent agent review completed with its notification-routing finding fixed. Device workflow and human testing remain pending. To verify: share a Solo session as View only, reopen mobile, and confirm it remains in its Solo project and is absent from Channels. Verify notification replies return to the same conversation. Follow-up to #9348. Pre-push rerun: analysis passed, but the Flutter compiler ran out of disk space and the stalled test process was interrupted. The hook subsequently returned success after 27 crypto-package tests passed; that is not a full Flutter pass. The earlier complete Flutter result above remains the applicable evidence. Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> |
||
|
|
68d367cf23 |
fix(mobile): align channel indicators and Duo section menus (#9703)
Align the mobile channel-list indicators to one trailing column. The unread dot stays at the right, with the temporary clock and mute indicator to its left when present. Duo's native menus for built-in and custom sections now place their ellipsis in the same 20-point slot while preserving the full 44-point tap target and native menu behavior. Validation: full mobile suite (5,098 passed, 71 skipped), 27 crypto tests, clean Flutter analysis, native UIKit menu geometry/hit-target checks, and a successful iOS release build. Installed on iPhone Air and Duo using existing saved state; inspected the Duo's native section-menu placement. Regression coverage checks row alignment, clock ordering, native bridge geometry, and the full menu hit area. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> |
||
|
|
7d116da335 |
fix(mobile): allow person mentions in Solo chats (#9705)
## Summary Mobile Solo rejected a human member mention with “Not sent. Community changed.” because it checked every recipient for agent ownership. Explicit mentions now accept current chat members, matching desktop; the implicit header agent still requires ownership. Fresh membership and community checks remain in place. This improves human-only and mixed person/agent sends without changing default agent selection, nonmember invitation rules, or thread drafts. It also fixes existing private shared Solo chats. ### Related issue Separate follow-up to #9704; no dependency on its classification change. Searched open issues/PRs: #9156 addresses misleading send-error wording and #9699 addresses mention editing; neither changes this Solo recipient ownership check. ### Testing `just mobile-install mobile-check mobile-test` passed (5,122 Flutter tests, 71 existing skips; 27 crypto package tests), along with `just file-size-check` and diff checks. Regression coverage drives the actual composer on iOS and Android and checks explicit-recipient removal/community-switch boundaries, plus existing implicit-agent ownership checks. Before the fix, the new composer journey retained the human-mention draft on both platforms. Manual check: in an owned shared Solo with a human member, send an explicit mention of that person, then a mixed person/agent mention. Each should send and clear its draft. Untagged messages should still use the selected agent. Native device/live-relay testing and human confirmation remain pending; this PR stays draft under AGENTS.md. Signed-off-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> |
||
|
|
8306e38742 |
fix(mobile): let code scroll under the code block copy button (#9612)
## What changed The copy button on a message code block reserved a fixed 40px column beside the horizontal scroller, so every line was clipped about 40px short of the block's right edge. This was most visible on narrow phones. The fix matches buzz-app desktop (`Markdown.module.css`, `.codeActions`): - The horizontal scroller now spans the whole block. - The copy button floats in the top-right corner on an opaque chip, so code scrolled under it never collides with the icon. On an own-message bubble the chip is the code tint blended over the outgoing fill, so it matches the block. - The end padding moves inside the scroll content, so every line end can still be scrolled clear of the button. - The language label keeps its right inset, so it never runs under the button. ## Why nothing gets worse Same tap target, icon, copy behavior and block insets. The only visual change is that code now uses the width the gutter used to take. Long lines in the button's row pass under the opaque chip while scrolled, as they do on desktop. ## Testing - `message_content_test.dart` "renders code block with language tag" now asserts that the scroller spans the block inside its border and that the copy button overlaps the scroller. Without the production change it fails (`Expected: 798.0, Actual: 746.0`), and it passes with it. - Before/after captures were rendered with the real fonts and the mobile appearance theme at iPhone width, for received and own (Chartreuse) bubbles, at rest and scrolled to the end. They are in the screenshots comment. - Pre-commit and pre-push hooks passed. - Not yet exercised in the native app on a device. The iOS "Copy and Delete" screenshot paste issue from the same report is still being diagnosed and is not in this PR yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5bd9d2c5d2 |
Transcribe Bestie hold recordings into text on device (#9645)
Hold Bestie to record with the waveform and slide-up cancel interaction from #8665, then release to send an on-device transcript as a normal text message. Stay on Home with a loader inside Bestie until delivery succeeds, then open chat. Failures expose Retry/Discard; saved recordings and signed messages remain recoverable without duplicate sends. Saved audio is excluded from OS backup. Existing composer voice notes are unchanged. Separate exploration from #8665. Transcription requires iOS 26 and a supported language. Android reports unavailable before capture because its generic recognizer cannot guarantee saved-file input. Validation: at `b5dc83bbf5`, 5,046 Flutter tests (71 skipped), 27 crypto tests, analysis and required push checks pass. Prior native changes at `30a397f83c`: Android build and 33 tests pass; iOS simulator compilation and backup-exclusion test pass, with one unchanged document-picker timeout passing on isolated rerun. Earlier iPhone preview was tested with saved profile preserved; these latest fixes have not been installed on the physical phone. --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Co-authored-by: corey <2dafccf60ea6d431a568f6d67fc600160d92a51e415e09dc8b213b8e360663d5@buzz.block.builderlab.xyz> |
||
|
|
b68c4edda5 |
feat(cli): show and search verified identity in users get (#9647)
## Summary `buzz users get` reads only kind:0 profiles, so the CLI can't find or confirm a person by their verified username. This adds relay-verified profiles (kind:30382) to `users get`. - `--pubkey` adds a `verified` object (`username`, `display_name`, `full_name`, `issuer_label`, `verified_at`) for subjects that have one. A requested person with a verified profile but no kind:0 is still returned. - `--name` uses the relay's `POST /profiles/search` when the community advertises verified profiles with `searchable: true`, so it matches verified names (word prefix). Otherwise, or for queries over the endpoint's 100-character limit, it runs the existing NIP-50 substring search and attaches verified profiles where the community advertises them. Verified profiles are read only when NIP-11 advertises `federated_identity.public_profile`. A projection is trusted only if it is kind 30382, signed by the relay's `self` key with a valid signature, and follows the NIP-FI projection rules the mobile client applies: empty content, exactly the projection tags (each once with one value), `p` equal to `d`, `active` set to `true`, a valid username, names of 1–64 characters with no surrounding whitespace or control characters (looser than mobile, which also requires NFC and rejects more Unicode categories), and a decimal `verified_at` no later than `created_at`. The newest projection per subject wins (the lower id breaks a same-second tie), so a retraction clears the verified name. Any `verified` key in user-authored kind:0 content is dropped on every path, so only a relay-signed projection can set it. `users get` now makes one NIP-11 request. If that request fails, the advertisement is malformed, or the kind:30382 lookup fails, it still prints the kind:0 results and writes a `verified_profiles_unavailable` warning to stderr. This applies to `--pubkey`, no args, and `--name`. ### Related issue Related: #8745 (verified profile spec), #9624 (verified-name mentions in workflows). ### Testing - `cargo test -p buzz-cli` passes, with tests for trust checks, retraction, both lookup paths, search without the advertisement, and a forged `verified` object in kind:0 (no advertisement, impostor-only projection, and a valid projection replacing it). - `cargo fmt` and `cargo clippy -p buzz-cli -D warnings` are clean. - An earlier revision of the built CLI was run against a live community with verified profiles: `--name <verified username>` found a user whose kind:0 name differs, and `--pubkey` returned the expected `verified` objects. --------- Signed-off-by: damienrj <damien@squareup.com> |
||
|
|
39ffc3dcc5 |
fix(mobile): keep agent poster up until the iOS video draws (#9688)
On iOS, an animated agent avatar (a preset character with a transparent
video) blinks out for one to three frames right after navigation
settles. Opening a Solo chat blanks the header avatar; going back to
Messages blanks the bestie bubble.
The cause is the hand-off from the still poster to the video. While a
route animates, `PresetAgentAvatar` shows the poster; once it settles it
replaced the poster with a native `AVPlayerLayer`, which draws nothing
until its first video frame arrives. The avatar picker and the
create-agent page already covered this by passing a preloaded poster;
the DM and Solo header and the bestie bubble pass none, so they went
straight to the bare player.
Now every iOS caller gets that hand-off, using its own poster when it
passes none: the poster stays up, below the player, until playback
advances in that showing, then fades out over 160 ms. The poster sits
below the native layer rather than over it, because a Flutter overlay
above a platform view also costs a blank frame when the view first
appears. Each showing starts covered again and waits for playback to
advance from where the player actually is, so coming back to a chat from
a page above it doesn't blink either. The poster is keyed by its URL, so
when the avatar changes to another character (for example a synced
bestie change) it never shows the previous character's poster. Android
is unchanged; it already waits for a presented frame.
### Validation
Measured on an iPhone 17 Pro simulator, recording at 60 fps and checking
the avatar region frame by frame, opening a Solo chat with an animated
agent and going back:
| | Header blank on open | Bubble blank on back |
| --- | --- | --- |
| main, 3 runs | 1 frame every run | 2 to 3 frames every run |
| this PR, 3 runs | none | none |
Before (left) and after (right), slowed 4x: the Solo header on open,
then the bestie bubble on back.
<video
src="https://github.com/user-attachments/assets/4ddf16c0-bb8d-4d77-b53e-84f83ff45e98"
width="480"></video>
Added test: [iOS keeps the poster over a new player until playback
advances](
|
||
|
|
008d72a133 |
test(relay): stop bridge cancel_fixture tests timing out on the first replica connect (#9691)
## Problem All seven tests that share `cancel_fixture` in `crates/buzz-relay/src/api/bridge.rs` got a replica pool with a 1 s `acquire_timeout`. Only `shed_history_read_maps_to_503_on_every_bridge_branch` needs that budget: it holds the replica full and measures how fast a read sheds. sqlx applies `acquire_timeout` to opening connections as well as to waiting for a free one, so the budget also governed the fixture's initial connect and every later acquire that had to open a connection. A transient Postgres stall on the shared CI server therefore failed tests that never hold the replica full. CI showed `connect scratch: PoolTimedOut` at `bridge.rs:10309` in `aborted_history_read_logs_events_already_queued` and `failed_history_read_closes_and_reconnect_replays_the_history` (run 44205074529 shows eight tests finishing together after a ~3 s gap, which is the stall). Pools with sqlx's 30 s default waited the stall out; the 1 s replica did not. No connection leaked and the pool was not too small. The replica's 300 ms database-level `statement_timeout` had the same flaw: migrations and seeding ran under it, so a stall during setup failed `seed community` with 57014. ## Fix (test code only) - The six non-shed tests now use default pool budgets. - Only the shed test asks for the short budget, via `budgeted_reader`. That helper pre-opens all of the reader pool's connections under the 30 s default, and does not ping on acquire, so the 1 s budget covers only the wait for a free connection. - sqlx still pings each connection on release and closes it if the ping fails, so `budgeted_reader` waits until `num_idle()` equals `max_connections` before returning. A fill-and-drain loop (acquire to `max_connections`, drop, re-check) reopens any connection a failed release ping closed, under one 30 s deadline, and panics with the `N of M idle` count if the deadline passes. - The replica's `statement_timeout` is applied after migrations and seeding, and the replica is reopened so new sessions pick it up. - The shed test asserts each shed `/query` case completes in under 10 s, so a silent fallback to the 30 s default fails instead of passing slowly. ## Verification Reproduced locally by pausing the Postgres container for 2 s at random intervals while running `api::bridge::postgres_tests` at CI's 8 threads: `connect scratch: PoolTimedOut` appeared in 1 of 4 runs before the fix and in 0 of 8 after. With the fix, the 62 bridge postgres tests passed at 8 threads against a local Postgres (`--ignored`, including the shed, statement-cancel, and both history-read tests). `cargo fmt` is clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: mtoohey <mtoohey@squareup.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a406191694 |
Revert "feat(relay): support community-scoped NIP-AR artifacts" (#9689)
Reverts #9650 (squash commit `eebf62b6`), except for migration `0097` and the channel artifact sync fences it added. Community scope adds a relay access gate based on community admission rather than channel membership, a new relay-admin command kind (`9034`) and an operator-run key transition. Its design and NIP-AR text need relay maintainer review before they ship. Two integration gaps also remain: - Media download authorization looks up references only in `events`, so an attachment referenced only by a community artifact is unreadable when media-read enforcement is on. - User erasure retires a community head in the database without signaling live syncs, so members who are already syncing keep the erased copy. The feature can return as a new PR once those are resolved. ## Kept from #9650 - **Migration `0097`, byte for byte.** Published images already include it, and databases that auto-migrated have recorded it. Dropping it would stop those relays from starting. It only adds columns and indexes that the channel code ignores. The declared schema matches that expanded shape and keeps the `(community_id, artifact_id)` primary key, so the operator key transition no longer exists. - **Channel artifact sync fences.** Snapshot and live sends check for a pending resync and for connection cancellation under the queue lock. A reader who loses access, or whose content is redacted, while a frame is in flight therefore receives no further payload. Handler-backed tests cover a resync recorded while a snapshot payload waits for queue room and one recorded after a live head read. ## Compatibility This revert supports databases that applied only migration `0097`, which is all that auto-migration runs. A database that ran #9650's operator contract script, or was bootstrapped from #9650's declared schema, has no `(community_id, artifact_id)` key, so channel artifact writes fail there. Before deploying to such a database, check that `artifact_heads_pkey` is on `(community_id, artifact_id)` and that `artifact_heads` has no rows with `scope = 'community'`; if either check fails, it needs a separate recovery step. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Paul <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@buzz.block.builderlab.xyz> |
||
|
|
db40da87b4 |
feat(relay): add conditional Solo member role updates (#9667)
**Category:** improvement **User Impact:** Solo chat owners can lower the access of any current non-owner, including people and agents. **Problem:** Using invitations to change Solo chat access can restore a removed member, reject a downgrade because of the target’s invitation policy, or show a join notice for a role change. **Solution:** Add signed role updates that require an active member at the expected role when the relay commits the change. A Solo owner can downgrade any current non-owner. Moving a viewer to Participating requires a verified agent, and granting Admin requires ownership of that agent. The relay refreshes signed group state without emitting a join notice. Companion to [block/buzz-app#3704](https://github.com/block/buzz-app/pull/3704). The [app review](https://github.com/block/buzz-app/pull/3704#pullrequestreview-5962147206) identified the need for conditional writes, verified agent identity and live relay validation. [#9592](https://github.com/block/buzz/pull/9592) introduced the atomic removal that uses the same membership lock. <details> <summary>File changes</summary> **crates/buzz-core/src/kind.rs** Register signed Solo role updates as kind 9050. **crates/buzz-db/src/store/channel_members.rs** Authorize the transition under the channel membership lock and commit the active row update and signed event together. **crates/buzz-relay/src/handlers/event.rs** Give the new command a bounded metrics label. **crates/buzz-relay/src/handlers/ingest.rs** Use the shared signed ingest path and require the channel administration scope. **crates/buzz-relay/src/handlers/mod.rs** Register the command handler and its PostgreSQL test. **crates/buzz-relay/src/handlers/solo_member_role.rs** Parse the command, route it to the conditional write, and refresh signed group state after commit. **crates/buzz-relay/src/handlers/solo_member_role_postgres_tests.rs** Exercise human and agent changes, restrictive invitation policy, promotion authorization, stale and removed membership, duplicate receipt, and signed roster updates through the relay’s production ingest path. **docs/solo-mobile-contract.md** Describe the wire format, permitted transitions, and handling when an older relay rejects the command. </details> ### Try it 1. Run the updated relay and the companion app against a disposable Solo chat with a current human and agent. Open **Chat access** as the owner. 2. Lower the human to **Viewing only**. Reopen **Chat access** and confirm the saved role. A role change should produce no join notice. 3. Downgrade an agent with a restrictive invitation policy. Confirm its role changes. Check that **Admin** can be granted only to your own verified agent. 4. Run `solo_owner_edits_active_members_and_publishes_the_new_roster` with PostgreSQL to check that a pending change for a removed member is refused and the signed roster stays clear of that member. ### Validation - The PostgreSQL regression passes at relay commit `405f7d1da`. It covers role and invite-policy enforcement, signed roster refresh, duplicate receipts, and rejection after removal. - The companion app at `a470947dc6` passes 138 administration tests. Its production command builder, validator, and signed roster reader also passed over WebSocket against a local relay backed by PostgreSQL and Redis. A human moved from Admin to Participating to Viewing only, then was removed. The app preflight and relay both refused a further role edit, and the signed roster still excluded the member. - The live check exercised the app’s relay code headlessly. The UI walkthrough is pending. --------- Signed-off-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@feedback.communities.buzz.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> |
||
|
|
fd436af846 |
feat(mobile): add saved channel section filters (#8479)
**Category:** new-feature **User Impact:** Mobile users can filter each channel section by unread or recent activity and save their choices to their account. **Problem:** Mobile sections do not expose the account's saved All, Unreads and Active filters, making long channel lists harder to navigate on mobile. **Solution:** Add per-section view settings with shared sheet chrome, checked choices, inline Active duration and Apply/Cancel. Preserve access to filtered channels through inline recovery and confirm encrypted filter writes on relay readback. **Known desktop and web sync limitation:** Mobile uses the encrypted `channel-filter` record. The separate current desktop and web build reads and writes `channel-workspace-filter` and falls back to the legacy record only before a workspace filter exists. Once the workspace record exists, filter changes are independent across the builds. The interoperability tests below cover the older companion format from [block/buzz-app #1297](https://github.com/block/buzz-app/pull/1297). Current desktop and web interoperability is follow-up work. <details> <summary>File changes</summary> **mobile/README.md** Document section controls, recovery and preference behavior. **mobile/lib/features/channels/channel_filter/channel_filter_activity.dart** Read verified message activity with bounded concurrency and lifecycle/live invalidation. **mobile/lib/features/channels/channel_filter/channel_filter_manager.dart** Preflight, publish and confirm encrypted preference changes, retaining rollback and errors. Skip no-op deletion cleanup and allow best-effort cleanup after local section removal. **mobile/lib/features/channels/channel_filter/channel_filter_provider.dart** Scope preference ownership and cache to the current account and relay. **mobile/lib/features/channels/channel_filter/channel_filter_store.dart** Preserve companion-compatible registers, durations, reset tombstones and unknown fields; define filter predicates and salvage malformed supported-v1 siblings from authenticated relay records. **mobile/lib/features/channels/channels_page.dart** Connect the filter owners and shared sheet header to channel navigation. **mobile/lib/features/channels/channels_page/body.dart** Apply filters using the same readiness predicate as unread highlights, retain the selected channel and expose activity retry. Delete sections locally before best-effort filter cleanup. **mobile/lib/features/channels/channels_page/filters.dart** Provide one draft settings sheet with checked rows, duration, pending guards and retry. Announce retained-draft failures in a visible live region beside the footer. **mobile/lib/features/channels/channels_page/sections.dart** Open section options directly and reveal hidden channels in the existing roster. **mobile/lib/features/channels/channels_provider.dart** Invalidate activity for self-authored and muted messages independently of unread state. **mobile/test/features/channels/channel_filter/channel_filter_test.dart** Cover record preservation, confirmed writes, malformed sibling repair and the actual activity-provider/predicate composition, including future-dated history. **mobile/test/features/channels/channels_page_test.dart** Cover staged saves, cancellation, failed drafts, saved duration and read-only recovery at enlarged text. **mobile/test/features/channels/channels_provider_test.dart** Verify self-authored activity invalidates filters without changing unread timestamps. **mobile/lib/features/channels/channel_sections/channel_sections_provider.dart** Emit local deletion immediately so offline removal updates the list without waiting for a relay event. **mobile/test/features/channels/channels_page_test/filter_feedback_tests.dart** Verify pre-seed unread consistency and offline section deletion through the real section provider and persistent storage, without filter publication. **mobile/test/features/channels/channel_filter/channel_filter_interop_test.dart** Exercise encrypted desktop/mobile golden payloads and crossed writes that converge on one complete winning record. **mobile/test/fixtures/channel_filter_desktop.json** Retain signed, encrypted synthetic-key payloads from the companion desktop implementation and mobile manager for protocol regression coverage. </details> ### Reproduction 1. Open a channel section's options. Select Active and 7 days, then Apply; reopen to see the saved choices checked. 2. Confirm older channels are hidden. Expand Show hidden channels to navigate without clearing the filter. 3. Change a draft and Cancel. Confirm the saved filter remains unchanged. 4. With preferences unavailable, delete an unfiltered custom section. It should disappear and remain deleted locally without publishing a filter reset. 5. Make a filter save fail. The draft should remain selected and the error should be visible beside Retry and exposed as a live region. ### Validation and limits - Follow-up fixes at `f38bf9b273402dd86e93476dde02f468747fa65a`, with main `a93f3282c` integrated. Required pre-push checks passed on that head: 3,742 Flutter tests passed, 16 skipped; four unconfigured-push tests passed. Analyzer, formatting, file-size and branch-skew checks passed. - Repaired v1 metadata now contains exactly `v` and `g`, preserving unknown top-level extensions. The pinned companion at `475e2afef` verified, decrypted and adopted the repaired mobile head without rewriting it. Sort-only Apply preserves late-loaded filters and publishes no filter write; the existing signed-read sheet journey covers this race. - Affected pre-integration journeys/protocol tests: 97 passed. Removing the production fixes produces six failures across unread readiness, offline deletion, malformed siblings, activity classification and accessible failed-save status; sources restored afterward. - Protocol exercise: actual `block/buzz-app` browser-host filter code at `475e2afef` produced the signed NIP-44 desktop golden head; the mobile manager adopted it and published a sibling choice; desktop decrypted/adopted that mobile write and preserved both durations on its next edit. These are production-code exercises with synthetic keys and a fake relay boundary, not two packaged clients exchanging against a live relay. - Whole-record last-write-wins applies to both mode and duration. Preflight preserves observed sibling choices; crossed writes can overwrite an unseen edit, even in another section. Readback checks the requested pair, and refresh adopts the retained winner. Per-section conflict-free merging is not promised. - Supported-v1 malformed siblings are salvaged from the authenticated relay head, with canonical repair published only by an explicit confirmed save. Oversized records and unsupported schema versions remain read-only; display cache never grants repair authority. - Section deletion is local first. Unfiltered sections skip publication; failed cleanup can leave unreachable settings for a never-reused section ID. No offline filter-save queue or automatic cleanup retry is introduced. - Earlier iPhone 17 / iOS 26.5 testing exercised section options, Cancel/reopen and Active/7-day filtering. The normal-flow screenshot below predates these review fixes. Failure-path runtime/screen-reader checks, Android, dark mode, packaged cross-device workflow and human acceptance remain unverified. - Preferences refresh on load/resume/pull-to-refresh; no instant cross-device sync promise. Sort retains its existing asynchronous persistence and is not atomic with the separate filter record. - On `85949bcde`, 5,095 Flutter tests passed with 71 skipped, plus 27 secp256k1 tests. GitHub's required checks cleared. The duration animation was tested on the iPhone 17 simulator against a local relay, and the same animation is included in this head. The separate non-required Codex Security Review run was canceled before publishing a review. ### Screenshots Actual iOS simulator capture, cropped to the section settings surface. | Section view settings | | --- | |  | --------- Signed-off-by: Taylor Ho <taylorkmho@gmail.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> |
||
|
|
eebf62b61d |
feat(relay): support community-scoped NIP-AR artifacts (#9650)
## Summary NIP-AR clients can store community-scoped artifacts and subscribe to live changes for one exact artifact type. Community and channel artifacts share revision and retry semantics and use separate identity scopes. Community owners and admins can choose whether a type accepts edits from all admitted members or only administrators. This PR combines the protocol from #9638 with the relay implementation. [Protocol]( |
||
|
|
b544fcea4a |
feat(mobile): add a diagnostics test report and test crash to Settings (#9676)
A way to check that a build's diagnostic reporting works end to end, per
[mobile diagnostic
reporting](https://github.com/block/buzz/blob/main/docs/mobile-diagnostic-reporting.md).
A build with a reporting destination shows a Diagnostics card in
Settings with **Send test report** and **Test crash**. A build without
one, which includes every build from this repository alone, never shows
it and still reports nothing.
| Before | After |
| --- | --- |
| 
| 
|

### What's in it
- The reporter gains `reporting` (whether the build has a destination),
`sendTestReport()` and `crashForTest()`. The do-nothing reporter returns
false and does nothing.
- **Send test report** sends a fixed `DiagnosticTestError` tagged with a
new `testReport` operation. It passes through the same filter as every
report.
- **Test crash** asks for confirmation, then crashes in native code
through the SDK, so native crash reports can be checked too. The report
goes out the next time the app opens.
- The spec gains a "A way to check a build" decision.
### Regressions
None expected: builds without a destination render Settings exactly as
before.
### Validation
Added widget tests for the card being absent without reporting, sending
a test report, and the crash happening only once confirmed, plus a test
of what a sent test report contains and one that a second tap sends a
second report. The screenshots come from simulator builds of main and
this branch, both with the same placeholder destination.
A full-app simulator run at
|
||
|
|
44e97e96f4 |
fix(pubsub): round the rate-limit retry hint up from PTTL (#9552)
## Summary The Redis rate limiter built its `retry in Ns` hint from `TTL`, which truncates to whole seconds. With 400 ms left in the window, a denied request was told `retry in 0s`, and a client that sleeps for exactly the hint retried straight into another refusal. This reads `PTTL` and rounds the milliseconds up to whole seconds, so the hint is never 0 while the window is still open. The no-expiry repair path is unchanged. ## Testing - New `rate_limiter::tests::retry_hint_rounds_a_partial_second_up` (`#[ignore = "requires Redis"]`, like the other Redis tests in this crate) seeds an exhausted window with 400 ms left and asserts the denial reports 1 second. Against the old `TTL` code it fails with `left: 0, right: 1`; with this change it passes. - `cargo nextest run -p buzz-pubsub --lib`: 38 passed. Ignored Redis `rate_limiter` and `nip98_replay` tests: 5 passed against a local Redis. - `cargo nextest run -p buzz-relay --lib` with local Postgres and Redis: 1762 passed. The relay `rejection::`/`admission::` lane with `--run-ignored all`: 16 passed. - Pre-push hooks (including rust-tests) passed. CI note: the Redis-backed pubsub tests only run in CI when they are named in `.github/workflows/_ci-relay.yml`, so the new test isn't selected there yet. Adding `or test(/^rate_limiter::tests::/)` to the "Pubsub subscriber reconciliation regression" filter would cover it. I left that out here because this branch can't push workflow file changes. --------- Signed-off-by: Wes <wesb@block.xyz> Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz> Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz> |
||
|
|
bf9ce1432e |
feat(mobile): add diagnostic reporting module with crash capture (#9613)
Step one of [mobile diagnostic reporting](https://github.com/block/buzz/blob/main/docs/mobile-diagnostic-reporting.md), first piece: the reporting module, plus capture of crashes and uncaught errors. A build given a `BUZZ_SENTRY_DSN` now reports native crashes, Flutter framework errors and uncaught asynchronous Dart errors to that Sentry project, attributed to the signed-in member's public key. A build without one (every build made from this repository alone) uses a do-nothing reporter and never initializes the SDK, as [ADR 0007](https://github.com/block/buzz/blob/main/docs/adr/0007-diagnostic-reporting-follows-the-destination.md) requires. A destination the SDK cannot parse is treated as none, so a configuration mistake never stops the app from starting. ### What's in it - **One interface** in `mobile/lib/shared/diagnostics/`: report an error, count a networking event, leave a breadcrumb, and set the member. It has a Sentry-backed and a do-nothing implementation. Only this folder imports the SDK. The explicit error reports and the networking counts that use it come in the next PRs. - **Startup** wraps `runBuzzApp` and installs the SDK's crash and error handlers only when a usable destination is set: one with an HTTP(S) host, a public key and a project, which the native SDKs also require. On Android, the manifest removes the SDK's startup performance provider, which would otherwise run before that check. - **Member:** set from the active community's key, changed when the account switches, cleared on sign-out. Adding the Builderlab origin and account subject is left to a later PR. Every report also carries a random per-install identifier the app creates on first launch, as its own `install.id` tag, signed in or not, so a device's reports can be matched to its members. It lives in a file that device backups and transfers skip, so a phone restored from another gets its own: on Android in the app's files directory, excluded in both backup rule sets; on iOS in an Application Support folder that a small native call marks as excluded from backup (not the caches folder, which iOS can clear when storage runs low). Set on the SDK scope, it also reaches native crash and hang reports. With no member set (before sign-in or after sign-out), the SDK also fills the report's user with its own random per-install identifier, on Dart and native reports alike. - **One filter** runs on every Dart report, breadcrumb and count before it leaves the device: - It replaces every error's own text with fixed wording, since an error can quote its input, a server's response body or a URL. The error keeps its type, mechanism type and stack trace. - It drops what the SDK adds about the failing platform call (`mechanism.data`) and the failing widget (`flutter_error_details`), which can quote what is on screen. - It removes URL query strings and fragments, and keeps only tags and count attributes on the allowed list. - It drops every breadcrumb except networking events and the SDK's foreground/background entries. - **SDK options:** personal data, screenshots, view hierarchy, replay and tracing stay off. The SDK's session records stay on, for a crash-free rate. A session begins each time the app starts or returns after 30 seconds or more in the background; the SDK sends a record when it begins, an update each time an error is counted, and a last one when it ends, carrying the start time, error count, outcome, time from start to end, release, environment and the random per-install identifier. Native auto-breadcrumbs, Android's network-change breadcrumbs (VPN state, signal strength, bandwidth; turned off in the manifest, since the Flutter bridge leaves them on), Cocoa's network breadcrumbs (which keep each request's query and reach native crash reports) and print breadcrumbs are off. With print breadcrumbs on, the SDK would replace `debugPrint` in non-debug builds with one that prints nothing. - **Main-thread hangs:** iOS app hang tracking, Android ANR detection and iOS watchdog-termination tracking are set on explicitly, at the SDK's default thresholds. iOS reports the main thread blocked, fully or mostly, for 2 s or more while the app is active, including freezes it recovers from; a hang still going when the system kills the app is sent on the next launch as a fatal hang, and watchdog-termination tracking reports a foreground run that ended with nothing else to explain it. Android reports only system-declared ANRs: on Android 11 and later, the most recent one that ended the process (read on the next launch, when the system kept a thread dump); before 11, after 5 s once the system marks the app not responding. So recoverable freezes are reported on iOS, and on Android only before 11 once the system marks the app not responding. Dart runs on the main thread, so blocking Dart work shows up with the main thread's stack; Dart frames need the Dart debug symbols at the destination, as crashes do. The spec now has a bullet and a user story for this. - **What the filter does not cover:** native crashes and app hangs are captured and sent by the native SDKs, which never call the Dart filter. They carry stack traces and, for a native exception, its reason text. No app code puts content in a native exception today. The spec now says this. - **Reporting never blocks the app or reaches it with an error:** every call returns at once, and a failure inside reporting is dropped with a `debugPrint`. ### Regressions None for builds without a destination, which includes every build from this repository: they run the same startup with one extra synchronous check, and the SDK is never initialized. The SDK still adds to the app's binary size on both platforms. With a destination, the first frame waits for the SDK to start, native SDK included, and for the install ID to be read from (or, on first launch, written to) a small file. On a debug simulator build the first frame came about 0.3 s later (median of 6 cold launches: 768 ms with a destination, 431 ms without), measured before the install ID was added. Device builds will differ. Uncaught errors still reach Flutter's default handling, and the SDK sends in the background. ### Validation Added tests (`test/shared/diagnostics/diagnostic_reporting_test.dart`): - A table of inputs run through the production Sentry options callbacks: SDK HTTP and navigation breadcrumbs are dropped, network breadcrumbs keep only their four attributes, URLs lose their query string and fragment, unknown tags and count attributes are dropped, and the privacy and breadcrumb options stay off. - Errors sent through a real SDK hub, with the SDK's own platform-error processor and Flutter error integration, into an in-memory transport: for a parse failure, a bad argument, a server response and a platform failure, the serialized event keeps the type and stack but none of the error's text; a real framework build error leaves out the widget text. - A release-mode check that `debugPrint` keeps printing with reporting on. - A build with no destination, one the SDK cannot parse, one without a public key or one without an HTTP(S) host starts the do-nothing reporter and the SDK stays disabled. - Reporting calls whose SDK calls throw, either synchronously or asynchronously, never reach the caller. - Hang detection is on and its thresholds equal the SDK's defaults. - An installation keeps one install ID across launches, a new installation gets a new one, and the filter keeps the `install.id` tag. - Signing in, switching accounts and signing out change the member that later reports are attributed to. I checked that each guard is real by removing it: the print-breadcrumb setting, the destination check, the error-text replacement, the `mechanism.data` and `flutter_error_details` removal, the network-breadcrumb setting, the dropped-failure catch and the tag filter each made a test fail. End to end on an iPhone 17 Pro simulator, with a local server standing in as the destination and a throwaway probe (not committed) that made an HTTPS request with a secret in its query, then raised an uncaught Dart error and a framework error with secrets in their text, then crashed natively: - All four reports arrived (two Dart, one framework, one native crash on the next launch), and none of the secrets appeared in any envelope. - Dart reports carried only the foreground/background breadcrumb; the native crash carried none. - As a control, a build with Cocoa's network breadcrumbs switched back on put the request's secret query and fragment into the native crash report, so that setting is what keeps them out. - `debugPrint` lines still appeared in the device log. Hangs, on a fresh iPhone 17 Pro simulator with no debugger attached and the same local server: a throwaway probe busy-looped the main isolate for 5 s after the first frame. The SDK sent an `App Hang Fully Blocked` event ("App hanging between 5.7 and 6.5 seconds", mechanism `AppHang`) carrying the main thread's stack: Flutter engine frames around 12 frames of Dart code. This was a debug build, where Dart is compiled just in time, so those frames have no image to symbolicate against; in release builds they fall in the app's compiled Dart framework and need its debug symbols at the destination. Install ID, rechecked after moving it to its own file, on a fresh simulator with the same local server, launched twice with a probe that raised a Dart error and then crashed natively: both Dart errors and the native crash carried the same `install.id`, while the signed-out user was the SDK's own identifier. The ID file was in the backup-excluded `Library/Application Support/Diagnostics` folder, not in the app's preferences. The merged Android debug manifest has neither of the SDK's startup providers and has the network-change setting off. The NDK preload provider is still merged in, but it does nothing unless its own manifest flag is set, and it isn't. Full mobile suite passes. Dart errors are captured in the main Flutter engine only; the iOS sheets that start their own engine are out of scope for this PR (native crashes while they are open are still caught), as the spec now says. iOS simulator and Android debug builds with a destination set both build; on iOS the SDK resolves through Swift Package Manager. --------- Signed-off-by: Tom Brow <tomb@squareup.com> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> |
||
|
|
b624eb0f20 |
fix(mobile): recover stuck read-state updates and stale Mark Read (#9492)
## Summary Mobile read-state fixes within the current NIP-RS text. - **Stuck pending update.** When the relay refuses a pending update with `invalid: event timestamp too far from server time` and the update is older than the relay's 15-minute window by the device clock, the update is retired. The next pass reads a fresh snapshot and sends a strictly newer successor, journaled before it is sent, unless the relay already holds that update or an own-slot update covering every key in it. The marks come from the journaled local state, so nothing is lost. A refusal of an update that is not old by the device clock reports `ReadStateClockSkewError` and keeps the exact signed bytes. Unknown outcomes (timeouts, lost acknowledgements) still retry the exact bytes. - **Mark Read from the channel actions sheet.** The sheet is the only owner of the action, for custom-section channels too. It marks through the newest message known at the tap (the listed `lastMessageAt` or a newer observed unread event), not the `Channel` captured when the menu opened, so messages arriving after the tap stay unread. With no known message time it only releases forced-unread flags. - **Failed snapshot.** A failed snapshot, during startup or inside a publish, retries with backoff (5 s doubling to 5 min) while connected and on app resume; the retry re-syncs and sends journaled marks. When a publish's own snapshot read succeeds first, the pending retry is cancelled, the backoff resets to 5 s and the superseded snapshot error is cleared. A reconnect still re-syncs as before. The channels list shows a tappable "Unread status isn't syncing" notice while sync is failing. - **Marks in the manager gap.** A mark, seed or forced unread made after a dependency change retired the manager, but before the rebuild, now runs the pending rebuild and reaches the current manager instead of being dropped. The session-wide publishing switch-off after an unsupported-kind or missing-scope refusal is unchanged: marks stay journaled and the next manager (restart, re-authentication or community switch) publishes them. In that state the notice offers no retry and says to sign in again or restart Buzz. ## Tests - `read_state_manager_test.dart`: expired update with only partial coverage is renewed with a newer successor carrying every mark; expired update the relay already holds is retired with no new send; clock-skew refusal keeps the exact update and reports the skew error; failed snapshot retries on the backoff timer and stops after recovery; a snapshot failure inside a publish retries on its own and sends the marks; after an explicit flush whose snapshot read succeeds, no extra snapshot is read and the next failure retries after 5 s, whether the write succeeds or fails. - `channel_actions_sheet_test.dart`: Mark Read covers a message that arrived while the sheet was open; with no known message time it only releases forced unread. - `read_state_provider_test.dart`: a mark made between a community switch and the next manager's build is kept. Each new test fails without its fix. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: Hayt <211b96e6a2b7f45fd4047988976c7bbbeeda0c15f3ae7b32eec20834b5a55118@buzz.block.builderlab.xyz> Co-authored-by: Tom Brow <tomb@block.xyz> |
||
|
|
8d613ce0e8 |
test(relay): refresh the author's membership cache after the stray-h private channel insert (#9640)
Fixes `handlers::ingest::postgres_tests::reaction_and_deletion_h_must_name_the_target_channel`, which fails on main in the PostgreSQL Tests jobs. The test creates its private channel directly in the database after the author has already published, so the per-user membership cache (`is_member_cached`) still holds the author's snapshot from before that channel existed. The author's post to the new channel is then refused with `restricted: not a channel member`. The test now drops the author's cached membership after the insert, so the channel's owner is seen as a member. The test's assertions are unchanged. Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> |
||
|
|
c18bed1f46 |
fix(mobile): name the cause of account-unavailable sign-in errors (#9628)
## Problem Organization sign-in can fail with `Couldn't sign in (account-unavailable)`. That code covers several different failures, so a screenshot can't tell them apart: - the account server can't be reached at all (DNS, connection, or TLS failure, or a timeout), for example when a required VPN profile isn't applied to the app; - a redirect, since the client doesn't follow redirects, so an access-proxy login page lands here; - a 5xx from the server. ## Change - `BuilderlabAccountClient` records why a request failed as `unavailable`, in `lastUnavailableCause`, and logs it. It follows the existing `lastRejectedRequest` pattern. The cause is one of: - a transport category: `unreachable`, `insecure`, `timedOut` (reusing `transportFailure`), or `network` as the fallback; - the status code, such as `http302`. - `OrganizationSignIn` saves the cause at the moment the exchange fails, so later account requests can't change it. It adds the cause to the failure code, for example `account-unavailable-http302` or `account-unavailable-unreachable`. Each new attempt clears it. - The organization sign-in page now ends its failure message with advice for that cause instead of "Try again.": - unreachable, timeout, TLS failure, redirect: "Check your network or VPN connection, then try again." - a 5xx: "The sign-in service is unavailable. Try again later." - The in-app banner keeps "Try again.": its capsule clips longer messages at default text size, and the existing banner layout test caught that. - Unexpected statuses are classified as soon as the headers arrive, so a slow or oversized error body can't hide the status. | Before | After | |---|---| |  |  | The log line contains only the host, route, and cause. It has no headers, credentials, or response bodies. ## Validation - A new journey test in `organization_sign_in_test.dart` covers an exchange that fails with a 302, a 503, and a client exception, then a successful retry. With the cause capture removed, the test fails (`Expected: 'account-unavailable-http302'`, `Actual: 'account-unavailable'`). - The same test checks the advice for each cause. The internal-build landing tests pass with `--dart-define=BUZZ_DISTRIBUTION=internal`. - The screenshots come from the real `PairingPage` rendered in a scratch widget test with a 390×844 surface, cropped. The scratch test isn't committed. - `just mobile-check` passes, and the full `flutter test` run passes: +5018, 71 skipped. - Not yet done: a device run that reproduces an unreachable account server and captures the new message on screen. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Diem Nguyen <diem@squareup.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7cf19b713c |
perf(db): bound deep keyset history pages by the cursor timestamp (#9549)
## Problem `query_events` and `get_channel_window` page history with a composite `(until, before_id)` cursor under `ORDER BY created_at DESC, id ASC`. The cursor predicate was only: ```sql created_at < $u OR (created_at = $u AND id > $bid) ``` PostgreSQL cannot use that OR as the start of an index range, so a page deep in a channel walks the `(community_id, channel_id, created_at DESC, id)` index from the newest row and filters every newer row before it reaches the page. The cost of a page grows with its depth. ## Fix Add the redundant bound `created_at <= $u` next to the OR in both queries (`store/event.rs` and `store/thread.rs`). It does not change which rows match; it gives the planner an `Index Cond` range start at the cursor. This is the same bound the thread window query already carries (`store/thread_window.rs`). `api/bridge.rs` has the pattern only in a test fake that emulates `query_events_on`; the bridge itself routes cursors into these two store functions, so it needs no change. ## EXPLAIN before / after `EXPLAIN (ANALYZE, BUFFERS)` of the `query_events` page shape, `LIMIT 51`, kind 9, by cursor depth. Copy of a real channel (2,277 messages), custom plan, shared buffers hit: | Depth | Before | After | | ---: | ---: | ---: | | 50 | 96 | 96 | | 300 | 311 | 84 | | 1,000 | 969 | 80 | | 1,500 | 1,443 | 92 | | 2,100 | 2,006 | 89 | At depth 2,100: execution 0.709 ms to 0.058 ms, rows removed by filter 2,101 to 42. With a generic plan the after numbers are also flat (80 to 96 buffers at every depth). Synthetic table (one channel with 20,000 kind-9 rows plus 20 other channels of 2,000 each): | Query | Depth | Before | After | | --- | ---: | ---: | ---: | | `query_events`, custom plan | 10,000 | 701 | 11 | | `query_events`, generic plan | 50 | 874 (7.5 ms) | 11 (0.11 ms) | | `query_events`, generic plan | 10,000 | 444 | 11 | | `get_channel_window`, custom plan | 10,000 | 1,006 (2.35 ms) | 312 (0.49 ms) | | `get_channel_window`, custom plan | 19,940 | 1,690 (4.35 ms) | 314 (0.47 ms) | For `get_channel_window` at depth 19,940 the events index scan went from 1,385 buffers and 19,941 rows removed by filter to 9 buffers and 4 rows; the rest of its plan is the thread metadata join, which is unchanged. On the small 2,277-row channel the planner picks a sequential or bitmap scan for the window query, so its plan is unchanged there. ## Tests New Postgres test `store::event::postgres_tests::deep_keyset_pages_read_from_the_cursor`: - Inserts 1,000 kind-9 rows into one channel, two per second, so the cursor lands on same-second ties. - Turns off sequential and bitmap scans for the session, so the small fixture uses the ordered index walk a large channel uses, then reads one 50-row page at depth 900 through both `query_events_on` and `get_channel_window_on`. It asserts each page equals the expected rows and that each read touched at most 150 event rows (summed `seq_tup_read + idx_tup_fetch` over the `events` partitions). - Pages the whole channel through both paths and asserts every row comes back once, in order. Checked by reverting each half of the fix: - `event.rs` bound removed: `events page at depth 900 read 950 rows for 50` - `thread.rs` bound removed: `window page at depth 900 read 1000 rows for 50` - With the fix: passes (5 of 5 under `--stress-count 5`), reading 52 and 53 rows. Runs: - `scripts/postgres-test-run.sh -p buzz-db --lib --tests`: 763 run, 756 passed. The 7 failures were the new test before its final fixture change (it now passes) and 6 that fail the same way on unmodified `main` in my environment because they spawn a host `psql` binary that isn't installed there: `migration_schema_media_prebuild_waits_for_old_transactions_during_creation_and_cleanup`, `script_stops_at_the_first_auth_refusal`, `script_renames_each_planned_channel_once_whatever_its_name`, `desired_event_follow_up_contract_app_only`, `desired_event_follow_up_contract_dual`, `migration_schema_event_follow_up_contract_app_only`. CI's Postgres lane is the authoritative run for those. - On the final head: the new test plus every `channel_window` Postgres test, 9 of 9 passed. - `cargo nextest run -p buzz-db --lib` (no infrastructure): 216 passed. `--test observability_source`: 28 passed. Doc tests: 5 passed. - `scripts/test-postgres-test-discovery.sh`: passed. - Pre-push `rust-tests` lane: passed. ## How to test 1. Run `scripts/postgres-test-run.sh -p buzz-db --lib -E 'test(deep_keyset_pages_read_from_the_cursor)'`. 2. Optionally, in a database with a channel of a few thousand messages, open the channel in a client and scroll back through history. Older pages should load as quickly as the first ones, and no message should be skipped or repeated across page boundaries. ## Related No duplicate PR or issue found. Related: #1787 (keyset index for thread replies) and #6004 (CLI wiring for the composite cursors). Signed-off-by: Wes <wesb@block.xyz> Co-authored-by: Groot <f4c08302591916fb4b80926bf7e18d22eef8aa0c877e4e841acc46405a45700b@buzz.block.builderlab.xyz> |
||
|
|
11970789eb |
feat(cli)!: consistent channels list/get/search output (type, visibility, labels, real created_at) (#9617)
Closes #6390 ## Summary `buzz channels list`, `get` and `search` each projected kind:39000 channel metadata differently. `list`/`get` dropped the classification tags, so a script couldn't tell a Solo chat from a stream or a private channel from an open one. The three commands also disagreed on field names, defaults and empty values, and `created_at` reported the last-edit time (#6390). All three now print one `ChannelSummary`, with `pubkey` added on `get`: | Field | Source | |---|---| | `channel_id`, `name` | `d`, `name` tags | | `channel_type` | first `t` tag (`stream`, `forum`, `dm`, `workflow`, `system`) | | `visibility` | `open` for `["public"]`, `private` for `["private"]` | | `labels` | the `t` tags after the first, e.g. `["buzz.solo"]` | | `archived` | `["archived","true"]` | | `description` | NIP-29 `about` tag | | `topic`, `purpose`, `ttl_seconds` | `topic`, `purpose`, `ttl` tags | | `created_at` | the channel's `created_at` tag (NIP-CL), or `null` when absent | | `updated_at` | the event's own `created_at`, which is the last metadata change | Compact `list` output (`{channel_id, name}`) is unchanged. ### Breaking output changes These are intentional, and they were discussed with a maintainer before this change: - **`search`:** `about` is renamed `description`, matching `list`/`get` and `create`/`update --description`. - **`list`/`get`/`search`:** `created_at` is now the real creation time. The old value, the last-edit time, moves to the new `updated_at`. - **`list`:** archived channels are hidden by default, as `search` already did. The new `--include-archived` flag shows them. `get --channel <id>` still returns an archived channel. `--limit` (and `--visibility`) count the channels printed: `list` reads past filtered channels, bounded by `MAX_QUERY_PAGES` on the default path and by 10,000 memberships with `--member`. - **Missing values:** they print `null` instead of `""`. This mainly affects `description`. - **`visibility`:** it prints `open`/`private`, the values `--visibility` takes, instead of the raw `public` tag. `search` printed `public` before. No in-repo consumer reads the renamed fields or the `public` value. The benchmarks read `search`'s `channel_type`, `visibility == "private"`, `archived` and `ttl_seconds`, all of which are unchanged. ### Related - Closes #6390. - Overlaps with #5664 and draft #6353, which add type and visibility to `list`/`get`. This PR covers both: it uses `open` like #6353, plus labels, archived, parity and the `created_at` fix. A maintainer may want to close them as superseded. Unlike #6353, it doesn't error on missing or contradictory visibility tags, so one malformed channel can't fail a whole `list`. ### Testing - `cargo test -p buzz-cli`: 699 passed. Clippy is clean. The tests build events from the captured `test-fixtures/solo-creation.json` identity tags and pin the full JSON shape, including the all-`null` case. They also cover the production `listed_channels` and `search_matches` filters: archived hiding, `--visibility`, and search's name and ID requirement and ordering. - An agent ran the changed commands against a live relay: - `get` and `search --exact` return identical fields for the same channel. - Over 2,000 channels, `list` hides 162 archived channels unless `--include-archived` is passed. - `--visibility open` returns only `open` channels. - 1,777 channels have `created_at < updated_at`. - No `description` is `""`. - Compact output is unchanged. - `list --limit 10` and `--member --limit 5` return exactly 10 and 5 non-archived channels, and `--limit 2000` returns 2,000 with none archived. - An independent agent review found no blockers. Its one cheap nit, `get` printing `pubkey: ""`, now prints `null`. - The pre-push workspace `rust-tests` lane was skipped for this push. When the push was made, `origin/main` didn't compile `buzz-db`'s lib tests, which is unrelated to this `crates/buzz-cli`-only diff. That breakage has since been fixed on main, so CI runs the full workspace. buzz-review-completed 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Jemiah Westerman <jemiah@squareup.com> Co-authored-by: Son of Anton <8e0ef2ab02d69a7ac089ef5eca90d1a3fbbdc546f6322dc34d0c4f3deecea7f4@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f04fdef31f |
ci(docker): publish the push gateway only when its inputs change (#9658)
## Why
Every main push that rebuilds the relay image also published a new push
gateway image. A staging environment that promotes each published
`main-<commit UTC>-<7>` gateway image then rolls out identical gateways.
In one 29-hour window, main got 43 image-eligible commits, and only 2 of
them changed the gateway. The gateway crate depends on no other
workspace crate, so the other 41 images could not differ in behavior.
## What
- New `push-gateway-inputs` job in `docker.yml`. It runs
`scripts/push-gateway-image-inputs-changed.sh`. On a main push, the
script reads the `org.opencontainers.image.revision` label of the
current `ghcr.io/block/buzz-push-gateway:main` image. It then compares
the gateway's build inputs at that revision and at HEAD:
`crates/buzz-push-gateway`, `Cargo.toml`, `Cargo.lock`, `.cargo`,
`rust-toolchain.toml`, `Dockerfile.push-gateway`, `.dockerignore`,
`docker.yml` and the script itself. Every other event prints
`build=true`. The step appends the script's output to `$GITHUB_OUTPUT`,
so a failing check fails the run instead of skipping the build.
- `push-gateway-build` and `push-gateway-personal-dev` run only when
those inputs changed. When the build is skipped, `push-gateway-merge` is
skipped too.
- `push-gateway-merge` now moves `:main` in its own step, after
provenance is attested. The first publication sets every other tag. So
`:main`'s source label always names a completed publication, and a
failed attestation is retried on the next run.
- It compares with the published image, not `github.event.before`. Main
runs share one concurrency group, so a newer push replaces a pending
run, and a failed run publishes nothing. In both cases the next run
still sees the gateway change.
- When in doubt, it builds: an unreadable image, an unknown source, or a
source that isn't an ancestor of HEAD.
- `scripts/test-relay-image-eligibility-workflow.sh` pins the job
gating, the decision step, and `:main` moving after attestation. It runs
the script against a fixture repository with `docker` stubbed:
multi-platform and single-platform `:main` at HEAD, a non-main event, a
lookup failure, relay-only, toolchain-only, a gateway change behind a
later relay-only commit, a missing source, and a non-ancestor source. I
checked that each assertion fails when its production line is broken.
## Risk
- A base image update (`rust`, `debian:bookworm-slim`) alone no longer
publishes a new gateway image. The next gateway input change picks it
up. A manual dispatch at a `relay-v*` tag still builds.
- `:main` now moves a few seconds after the other tags on main pushes.
Deployments that follow `main-<commit UTC>-<7>` are unaffected.
- The relay image and its triggers are unchanged.
## Simpler
There are fewer published gateway images, and every one of them changes
the gateway. No new configuration.
## Testing
- `scripts/test-relay-image-eligibility-workflow.sh` passes locally.
Mutations of the script and the job gating fail it.
- `actionlint .github/workflows/docker.yml` passes.
- Checked locally that the `docker buildx imagetools inspect … --format
'{{json .Image}}'` + `jq` read returns the current `:main` gateway
source revision.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: Luke Tornquist <tornquist@squareup.com>
Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
3689241672 |
feat(mobile): reply to a message from its iOS notification (#9439)
On iOS, a notification that shows a channel or DM message now offers
**Reply**. The user types a reply in the notification and sends it
without opening the app.
- The reply goes in a subthread under the notified message (its thread
root is the message's own root, or the message itself when top-level). A
Solo chat takes no thread replies, so there it goes at the chat's top
level.
- It always mentions the notified message's sender, so the person or
agent being answered is notified. Typed `@name` text stays plain, since
a notification has no mention autocomplete.
- It is sent by the app's own send path. iOS starts the Flutter engine
when it wakes the app in the background, and the reply reopens the relay
connection (closed after the background grace period), waiting a bounded
time for it before sending.
- A sent reply marks the conversation read **up to the notified
message** (newer messages stay unread) and clears that notification and
earlier ones from the same conversation.
- An unsent reply (offline, relay error, timeout, a channel the user
isn't in) keeps the typed text as a draft, after any draft already
there, and shows a "Reply not sent" notification that opens the
conversation.
For now only notifications from the community selected in the app offer
Reply: replying must not switch communities, and the app can only reach
the selected one. Forum posts and fallback notifications that show no
message offer none. The design and the options considered are in
`docs/adr/0004-notification-reply.md`.
### Before / after
Long-pressing a message notification (synthetic names and text). Before
has no reply field (captured by sending the notification without its new
reply category, which is how main presents it); after shows one with
Send.
| Before | After |
| --- | --- |
|

|

|
### Demo
With the app backgrounded past the relay grace period, replying from the
notification lands the reply in a subthread under the message:
https://github.com/user-attachments/assets/37df7e28-aa46-4521-938e-8af5faa77b83
### Regressions
Nothing existing changes unless the user taps Reply. Notifications gain
a category and a small reply context in `userInfo`; tapping a
notification still opens the conversation as before. The relay reconnect
only happens for a pending reply and then falls back to the normal
background disconnect, so idle background behavior and network use are
unchanged. Reply failures end in a draft and a "Reply not sent"
notification rather than touching other state.
### Validation
- End to end on an iOS 27 simulator against a real community: with the
app backgrounded past the relay grace period, replied from the
notification; the reply appeared in a subthread under the message,
mentioning its sender. The demo above was recorded before the review
fixes (session hold, community fence, origin-community drafts, composer
draft sync); the same run was repeated on the current head,
|
||
|
|
a5b3dbc00d |
fix(mobile): stop reporting saved images as failed on iOS (#9599)
On iOS, **Save image** in the image viewer reported a failure for a save that worked. It asks only for permission to add photos. With that permission the image landed in Photos, but the app showed "Could not save image" and iOS then asked for full library access. After choosing **Keep Add Only**, every later save did the same: saved, and reported as failed. Now the save reports what actually happened, and add-only permission is all it needs, so iOS never asks for full access. | Before | After | | --- | --- | | <img src="https://github.com/user-attachments/assets/5926b595-6a2d-4382-83e5-89329c009159" alt="Before: full access prompt over a "Could not save image" message" width="300"> | <img src="https://github.com/user-attachments/assets/3b797c3e-43c4-4766-950b-8bef415ae2e0" alt="After: "Saved to Photos" message" width="300"> | Before: https://github.com/user-attachments/assets/e4f88b29-cabc-4c43-9967-d8481e434551 After: https://github.com/user-attachments/assets/ca3631a5-c988-4082-898a-426867788051 ### Cause `photo_manager`'s `saveImage` returns the saved asset, so its iOS code fetches the new asset back after writing it. PhotoKit does not let an add-only app fetch assets: the fetch makes iOS show the full-access prompt and comes back empty, and the plugin reports an error for a write that succeeded. The latest release (3.12.0) has the same code. On iOS the image is now written by a small native saver (`PhotoLibrarySaver`) that creates the asset and reports the result of that write, without reading the library. Android keeps using `photo_manager`, and the permission request is unchanged on both platforms. ### Regressions None expected. - The write is the same PhotoKit creation request the plugin made, with the same original filename, so saved images are unchanged. - Real failures still show "Could not save image": a denied permission, a failed download and a failed write all still surface. - Android and the rest of the app's photo library use (the composer's photo picker) are untouched. ### Validation - Added test: the image actions journey saves on iOS with a photo library that grants add-only access and rejects every read, and expects "Saved to Photos", one write with the downloaded bytes and filename, and an add-only permission request. A failed write then shows "Could not save image". It fails without the fix. - Full mobile suite and the iOS Runner unit tests pass. - Full-app run on an iOS 27 simulator, on a fresh install with no photo permission, comparing this branch with unmodified `main`: - `main`: first save adds the image, shows "Could not save image" and the full-access prompt; a second save after **Keep Add Only** adds another copy and shows the error again. - This branch: first and second saves each add one image and show "Saved to Photos", with no full-access prompt, and only add permission is granted afterwards. - This branch, other paths: **Don't Allow** shows "Could not save image" and saves nothing; saving with full access already granted works; **Share image** still opens the share sheet. - Not covered: a physical device, and Android (its code path is unchanged). --------- Signed-off-by: Tom Brow <tomb@squareup.com> Co-authored-by: judge <7615ec4b7ddf99f0bb48e913297f99f8f772d289a1c9ef54e1d906dd55a93ba8@buzz.block.builderlab.xyz> |
||
|
|
493cb4cc13 |
perf(db): stop per-id planning of wide #e reads (#9591)
Thread pages fetch the reactions, edits and deletions of ~200 ids at once. Until a pooled connection has run that `#e` read about five times, Postgres plans it with the values: ~12 ms per plan (one estimate per id per partition) against ~2 ms to run it. Past 8 ids the arrays now go through a scalar subquery, so planning is one estimate (~1.5 ms) and still uses the tags GIN index; narrower reads are unchanged. On an 830-reply local thread, one viewer's full scan drops from 119 to 59 ms p50; with 50 viewers p50 holds at 242 ms, p99 drops from 664 to 413 ms, and the read's planning time falls from 13 s to 0.6 s per minute. --------- Signed-off-by: Sanket Kanjalkar <sanketk@squareup.com> |
||
|
|
bc3afbb293 |
[buzz] fix(ci): link relay image indexes to their source (#9637)
The relay image index includes the qualified Git revision. Add the source repository URL beside it so OCI registry clients and deployment tools can link the image to the exact source commit. The manifest assembly step derives the URL from GitHub Actions' server and repository variables. The release workflow contract checks that the index includes both the source and revision annotations. Signed-off-by: Helen Tian <htian@squareup.com> |
||
|
|
25b58ab98f |
feat(push-gateway): verify Android Key Attestation (#9562)
## What and why Ticket 3 of the Android push plan ([design PR #9555](https://github.com/block/buzz/pull/9555)). The gateway now verifies Android Key Attestation at enrollment instead of rejecting every Android chain, and rate limits signed installation calls per attested key. Stacked on [#9560](https://github.com/block/buzz/pull/9560) (Android enrollment and FCM wakes). This PR's base is that branch; it will be retargeted once that merges. - **Chain.** It must end at a configured Google attestation root (Google's [published hardware roots](https://developer.android.com/privacy-and-security/security-key-attestation#root_certificate) are built in, pinned by public key), with valid signatures and issuer links, CA issuers above the attestation key certificate, and no SHA-1 signatures. The attestation key certificate itself is exempt from the CA flags, because some factory keyboxes issue it with CA:FALSE and digitalSignature only (Google's Sony Xperia 10 III sample); a Keystore leaf still cannot act as an issuer, since the extension is refused above the leaf. Validity is enforced for Remote Key Provisioning chains; Google tells verifiers to keep trusting the long-expired factory chains, which the revocation list covers instead. The attestation extension must be in the leaf and nowhere else. The leaf key must be EC P-256; it becomes the installation's signing key. - **KeyDescription.** Attestation and KeyMint security levels must be TrustedEnvironment or StrongBox. The challenge must equal SHA-256 of the enrollment transcript. Key properties (generated, EC, P-256, sign-only) and the root of trust come only from the hardware-enforced list. The bootloader must be locked, and the boot state Verified, or SelfSigned with a verified boot key on an operator-configured list. The application id (the one software-enforced value) must name exactly the configured package with a configured signing digest. - **Revocation.** A background task fetches Google's status list at startup and then on its cache lifetime (5 minutes to 1 day), with a 30 second timeout, an 8 MiB size cap, capped exponential backoff and jitter. Any REVOKED or SUSPENDED serial in the chain is rejected. With no list yet, or a list older than the grace period, enrollment fails closed. Enrollment reads an in-memory snapshot and never waits on a fetch. - **Rate limit.** Signed installation calls (delegate, revoke delegation, rotate endpoint, revoke installation, on both platforms) are limited per attested key. A call is counted only after its signature verifies, so forged requests cannot spend another installation's allowance. Counters are in memory per replica, bounded to 100,000 keys. - **Dependencies.** None added. `x509-parser` gains its `verify-aws` feature, which uses the `aws-lc-rs` the crate already depends on. ## Configuration All optional; Android stays off unless the ticket 2 settings are present. Documented in `docs/push-gateway-deployment.md` and `.env.example` with example values only, and passed through `deploy/charts/buzz-push-gateway` (disabled by default, schema-checked, covered by `tests/runtime-options.sh`). - `BUZZ_PUSH_ANDROID_BOOT_KEY_DIGESTS`: SHA-256 digests of verified boot keys accepted with a SelfSigned boot state. Empty by default, so a default gateway accepts stock Android only. - `BUZZ_PUSH_ANDROID_ATTESTATION_ROOTS_PATH`: PEM bundle replacing the built-in roots, for a reviewed root rollout. In the chart, `android.attestationRoots.secretName` and `secretKey` mount it from a Secret; an empty name keeps the built-in roots. - `BUZZ_PUSH_ANDROID_REVOCATION_GRACE_SECONDS`: default 604800 (7 days), minimum 3600. - `BUZZ_PUSH_SIGNED_CALL_WINDOW_SECONDS` and `BUZZ_PUSH_SIGNED_CALL_MAX_CALLS`: defaults 60 and 30. ## Tests - `cargo test -p buzz-push-gateway` (all pass, 18 ignored), `cargo fmt --all --check`, `cargo clippy -p buzz-push-gateway --all-targets -- -D warnings`, and the chart tests (`render.sh`, `release-contract.sh`). - Key Attestation chains are generated in the tests with a test root injected as the configured root, and run through the production verifier. One table rejects: unlocked bootloader, Unverified, Failed, SelfSigned with an unlisted key, boot key only in the software list (two variants), key properties only in the software list, extra key purposes, wrong curve, wrong package, two packages, wrong signing digest, wrong challenge, software-backed key (two variants), unknown root, forged leaf signature, expired provisioned intermediate, extension repeated above the leaf, non-P-256 leaf, a CA:FALSE certificate issuing the attestation key certificate. Another accepts Verified with any boot key, SelfSigned with a listed key, StrongBox and TrustedEnvironment, an expired factory intermediate, and a CA:FALSE, digitalSignature attestation key certificate. Revoked leaf, intermediate and root, a missing list and a stale list are rejected. The status list parser and refresh (backoff, cap, keeping the last list through failures) run against a scripted fake source; no test touches the network. - The per-key rate limit runs through the public router: forged calls do not spend the allowance, the fourth authentic call is refused whatever its kind, and another installation is unaffected. - Break check: disabling the locked-bootloader guard and the rate limit turned `rejected_attestations` and the rate limit test red; restored. ## Not here The app side (ticket 7) generates the Keystore key and sends the chain. The end to end run on a physical Android phone against a test gateway is also still to do. --------- Signed-off-by: Tom Brow <tomb@squareup.com> |
||
|
|
b769d5bee8 |
fix(relay): remove an owner's agents with the owner (#9575)
## What this changes When someone is removed from a community, their agents' live sessions already closed, but the agents kept their own membership rows and could reconnect as members. This PR removes those agents with their owner. - **Cascade.** `delete_member_with_acceptances` locks and deletes the target, then locks and deletes the `join_policy_acceptances` and `relay_members` rows of every member of the same community whose `users.agent_owner_pubkey` is the target and whose role is not `owner`. All of it runs in the same transaction, before the roster snapshot is written. Admin removal (kind 9031), self-leave and `buzz-admin remove-member` all go through it. An agent goes with its owner whatever its role, so an admin who removes a member also removes that member's admin-role agent. A direct 9031 target is still limited to `member` for admins. - **Owner recording.** The relay records a verified NIP-OA owner on every admitted sign-in, whatever the relay mode or `allow_nip_oa_auth`: on WebSocket AUTH, and for HTTP in the shared admission step after the denial checks, so `/events`, `/query`, `/count` and member POSTs all record it in one place. Before, it recorded only on open relays, so on closed relays the cascade and owner bans missed agents added directly. A request refused before recording writes nothing. Once the owner-signed tag is verified and the first admission checks pass, the relay may record the owner even if a final check, a cancellation or a token revocation then refuses the sign-in. The record still can't be changed. Over HTTP, a different stored owner refuses the request with 403 (invite creation keeps its `invite_owner_mismatch` code), and storage trouble refuses it with 503. A recorded owner can also manage the agent (channel management, channel-add policy, invites). - **CLI.** `buzz-admin remove-member` publishes clusterwide disconnects (`ConnControl::DisconnectPubkey`) for the target and its recorded agents on every run, including when the member is already gone. If publication fails or no relay server is subscribed, it exits 6 after the removal commits. Rerunning the same command retries the disconnect. - **Spec.** NIP-FI states the rule. ## Rollout limit An agent is covered only if its owner was recorded before the owner is removed. An agent whose owner was removed before the agent signed in with a NIP-OA tag after deploy, or an agent that never signs in with one, stays a member and needs a manual removal. The relay holds no proof of ownership for those agents, so there is nothing to backfill. Supersedes #6098 and #6078. --------- Signed-off-by: Will Pfleger <wpfleger@block.xyz> Co-authored-by: Duncan <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@buzz.block.builderlab.xyz> |